EmbarkStudios / server-framework

Framework for running network services, opinions included
Apache License 2.0
36 stars 4 forks source link

Add `server-framework-tonic` crate #35

Open LucioFranco opened 2 years ago

LucioFranco commented 2 years ago

This adds a proposal for how this (and potentially other thick server framework) crates could support many different sub-libraries (ex tonic, axum, warp, etc) without having to make a breaking change/version bump for each breaking change of the sub-libraries. This works by having external crates or the actual sub-library crate implement the default settings via an extension trait.

Example

use server_framework::{Config, Server};
use server_framework_tonic::ServerExt;

#[tokio::main]
async fn main() {
    init_tracing();

    let config = Config::default();

    let service = GreeterServer::new(MyGreeter);

    Server::new(config)
        .with_tonic(service)
        .always_live_and_ready()
        .serve()
        .await
        .expect("server failed to start");
}
LucioFranco commented 2 years ago

cc @davidpdrsn