Struct mz_service::grpc::GrpcServer
source · pub struct GrpcServer<F> { /* private fields */ }
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.
Implementations§
source§impl<F, G> GrpcServer<F>
impl<F, G> GrpcServer<F>
sourcepub async fn serve<S, Fs>(
listen_addr: SocketAddr,
version: Version,
client_builder: F,
service_builder: Fs
) -> Result<(), Error>
pub async fn serve<S, Fs>( listen_addr: SocketAddr, version: Version, client_builder: F, service_builder: Fs ) -> 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<R, O, T> CopyOnto<ConsecutiveOffsetPairs<R, O>> for T
impl<R, O, T> CopyOnto<ConsecutiveOffsetPairs<R, O>> for T
source§fn copy_onto(
self,
target: &mut ConsecutiveOffsetPairs<R, O>
) -> <ConsecutiveOffsetPairs<R, O> as Region>::Index
fn copy_onto( self, target: &mut ConsecutiveOffsetPairs<R, O> ) -> <ConsecutiveOffsetPairs<R, O> as Region>::Index
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
.