pub struct GrpcApi<H> { /* private fields */ }Expand description
Builder for the tonic task API.
Authentication and metrics are optional.
server installs the public message-size limit.
§Example
let svc = GrpcApi::new(adapter).server();
solti_api::tonic::transport::Server::builder()
.add_service(svc)
.serve("0.0.0.0:50052".parse()?)
.await?;§See Also
ApiHandlerdefines the backend operations.ApiErrordefines the gRPC status mapping.
Implementations§
Source§impl<H> GrpcApi<H>where
H: ApiHandler,
impl<H> GrpcApi<H>where
H: ApiHandler,
Sourcepub fn with_auth(self, token: Token) -> Self
pub fn with_auth(self, token: Token) -> Self
Requires a bearer token on every call.
The expected metadata is authorization: Bearer <token>.
Missing or invalid credentials return Unauthenticated.
Rejected calls do not reach the handler.
Authentication is disabled when this method is not called.
Sourcepub fn with_metrics(self, metrics: ApiMetricsHandle) -> Self
pub fn with_metrics(self, metrics: ApiMetricsHandle) -> Self
Attaches a metrics backend.
The default backend ignores every update.
Sourcepub fn server(self) -> GrpcServer<H>
pub fn server(self) -> GrpcServer<H>
Builds the configured gRPC service.
Encoded and decoded messages are limited to
MAX_REQUEST_BYTES.
The returned service always contains BearerAuth.
Auto Trait Implementations§
impl<H> !RefUnwindSafe for GrpcApi<H>
impl<H> !UnwindSafe for GrpcApi<H>
impl<H> Freeze for GrpcApi<H>
impl<H> Send for GrpcApi<H>
impl<H> Sync for GrpcApi<H>
impl<H> Unpin for GrpcApi<H>
impl<H> UnsafeUnpin for GrpcApi<H>
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
Mutably borrows from an owned value. Read more
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>
Wrap the input message
T in a tonic::Request