Struct mz_service::grpc::GrpcServer
source · pub struct GrpcServer<F> {
state: Arc<GrpcServerState<F>>,
}
Expand description
A gRPC server that stitches a gRPC service with a single bidirectional
stream to a GenericClient
.
It is the counterpart of GrpcClient
.
To use, implement the tonic-generated ProtoService
trait for this type.
The implementation of the bidirectional stream method should call
GrpcServer::forward_bidi_stream
to stitch the bidirectional stream to
the client underlying this server.
Fields§
§state: Arc<GrpcServerState<F>>
Implementations§
source§impl<F, G> GrpcServer<F>
impl<F, G> GrpcServer<F>
sourcepub fn serve<S, Fs>(
metrics: &GrpcServerMetrics,
listen_addr: SocketAddr,
version: Version,
host: Option<String>,
client_builder: F,
service_builder: Fs,
) -> impl Future<Output = Result<(), Error>>
pub fn serve<S, Fs>( metrics: &GrpcServerMetrics, listen_addr: SocketAddr, version: Version, host: Option<String>, client_builder: F, service_builder: Fs, ) -> impl Future<Output = Result<(), Error>>
Starts the server, listening for gRPC connections on listen_addr
.
The trait bounds on S
are intimidating, but it is the return type of
service_builder
, which is a function that
turns a GrpcServer<ProtoCommandType, ProtoResponseType>
into a
Service
that represents a gRPC server. This is always encapsulated
by the tonic-generated ProtoServer::new
method for a specific Protobuf
service.
sourcepub async fn forward_bidi_stream<C, R, PC, PR>(
&self,
request: Request<Streaming<PC>>,
) -> Result<Response<ResponseStream<PR>>, Status>
pub async fn forward_bidi_stream<C, R, PC, PR>( &self, request: Request<Streaming<PC>>, ) -> Result<Response<ResponseStream<PR>>, Status>
Handles a bidirectional stream request by forwarding commands to and responses from the server’s underlying client.
Call this method from the implementation of the tonic-generated
ProtoService
.
Auto Trait Implementations§
impl<F> Freeze for GrpcServer<F>
impl<F> !RefUnwindSafe for GrpcServer<F>
impl<F> Send for GrpcServer<F>
impl<F> Sync for GrpcServer<F>
impl<F> Unpin for GrpcServer<F>
impl<F> !UnwindSafe for GrpcServer<F>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.source§impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
source§fn plus_equals(&mut self, rhs: &&'a S)
fn plus_equals(&mut self, rhs: &&'a S)
std::ops::AddAssign
, for types that do not implement AddAssign
.