pub struct Server<'a, F> { /* private fields */ }Expand description
A function server with options beyond the command-line Args. Create
it with Server::new, chain the options, then call Server::serve;
with no options it serves exactly like serve. New options arrive as
new methods, so code that builds a server keeps compiling.
function_sdk_rust::Server::new(function, args)
.ready(async { Ok::<(), std::io::Error>(()) })
.serve()
.awaitImplementations§
Source§impl<'a, F: FunctionRunnerService> Server<'a, F>
impl<'a, F: FunctionRunnerService> Server<'a, F>
Sourcepub fn new(function: F, args: &'a Args) -> Self
pub fn new(function: F, args: &'a Args) -> Self
Creates a server for function, configured by the command-line args.
Sourcepub fn ready<R, E>(self, ready: R) -> Self
pub fn ready<R, E>(self, ready: R) -> Self
Holds the function back until ready completes, for a function that
must finish loading before it can run. The server listens at once,
but reports NOT_SERVING on the gRPC health service and answers
RunFunction with UNAVAILABLE. Ok flips the function to SERVING; an
error or a panic stops the server, and Server::serve returns it
as Error::NotReady.
Sourcepub fn metrics_registry(self, registry: Registry) -> Self
pub fn metrics_registry(self, registry: Registry) -> Self
Serves registry at /metrics, like function-sdk-go’s
WithMetricsRegistry: register the function’s own series in it
first, and the SDK adds its grpc_server_* series at the root. With
--metrics-address empty nothing is served.
Build the registry and its metrics with a prometheus-client version
that is semver-compatible with the SDK’s own dependency on it (while
prometheus-client is 0.x, the same minor version). Cargo then resolves
both to one copy of the crate; a registry from an incompatible version
is a different type and does not compile here.
Auto Trait Implementations§
impl<'a, F> !RefUnwindSafe for Server<'a, F>
impl<'a, F> !Sync for Server<'a, F>
impl<'a, F> !UnwindSafe for Server<'a, F>
impl<'a, F> Freeze for Server<'a, F>where
F: Freeze,
impl<'a, F> Send for Server<'a, F>where
F: Send,
impl<'a, F> Unpin for Server<'a, F>where
F: Unpin,
impl<'a, F> UnsafeUnpin for Server<'a, F>where
F: UnsafeUnpin,
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> 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