pub struct ClientBuilder { /* private fields */ }Expand description
Builder for configuring and creating a Procwire client.
Use the fluent API to register handlers and events, then call start()
to begin the client lifecycle.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn handle<F, T, Fut>(self, method: &str, handler: F) -> Selfwhere
F: Fn(T, RequestContext) -> Fut + Send + Sync + 'static,
T: DeserializeOwned + Send + 'static,
Fut: Future<Output = HandlerResult> + Send + 'static,
pub fn handle<F, T, Fut>(self, method: &str, handler: F) -> Selfwhere
F: Fn(T, RequestContext) -> Fut + Send + Sync + 'static,
T: DeserializeOwned + Send + 'static,
Fut: Future<Output = HandlerResult> + Send + 'static,
Register a method handler with “result” response type.
The handler receives deserialized payload and a context for responding.
Sourcepub fn handle_stream<F, T, Fut>(self, method: &str, handler: F) -> Selfwhere
F: Fn(T, RequestContext) -> Fut + Send + Sync + 'static,
T: DeserializeOwned + Send + 'static,
Fut: Future<Output = HandlerResult> + Send + 'static,
pub fn handle_stream<F, T, Fut>(self, method: &str, handler: F) -> Selfwhere
F: Fn(T, RequestContext) -> Fut + Send + Sync + 'static,
T: DeserializeOwned + Send + 'static,
Fut: Future<Output = HandlerResult> + Send + 'static,
Register a method handler with “stream” response type.
Use ctx.chunk() to send stream chunks and ctx.end() to finish.
Sourcepub fn handle_ack<F, T, Fut>(self, method: &str, handler: F) -> Selfwhere
F: Fn(T, RequestContext) -> Fut + Send + Sync + 'static,
T: DeserializeOwned + Send + 'static,
Fut: Future<Output = HandlerResult> + Send + 'static,
pub fn handle_ack<F, T, Fut>(self, method: &str, handler: F) -> Selfwhere
F: Fn(T, RequestContext) -> Fut + Send + Sync + 'static,
T: DeserializeOwned + Send + 'static,
Fut: Future<Output = HandlerResult> + Send + 'static,
Register a method handler with “ack” response type.
Use ctx.ack() to send the acknowledgment.
Sourcepub fn event(self, name: &str) -> Self
pub fn event(self, name: &str) -> Self
Register an event that this client can emit.
Events are fire-and-forget messages to the parent.
Sourcepub fn max_concurrent_handlers(self, limit: usize) -> Self
pub fn max_concurrent_handlers(self, limit: usize) -> Self
Set the maximum number of concurrent handlers.
When this limit is reached, new requests will be dropped with a warning. Default: 256
Sourcepub fn max_pending_frames(self, limit: usize) -> Self
pub fn max_pending_frames(self, limit: usize) -> Self
Set the maximum pending frames for backpressure.
When this limit is reached, response methods will wait until backpressure clears or timeout. Default: 1024
Sourcepub fn channel_capacity(self, capacity: usize) -> Self
pub fn channel_capacity(self, capacity: usize) -> Self
Set the writer channel capacity.
Default: 1024
Sourcepub fn backpressure_timeout(self, timeout: Duration) -> Self
pub fn backpressure_timeout(self, timeout: Duration) -> Self
Set the backpressure timeout.
Default: 5 seconds