pub struct SubcConsumer { /* private fields */ }Expand description
Managed Rust consumer for subc route calls.
Implementations§
Source§impl SubcConsumer
impl SubcConsumer
Sourcepub async fn reserve(
&self,
route: &RouteHandle,
deadline: Instant,
) -> Result<RequestReservation, CallError>
pub async fn reserve( &self, route: &RouteHandle, deadline: Instant, ) -> Result<RequestReservation, CallError>
Reserve an ordinary request on an already-open route. A caller recording
sends in its own database (for example, SQLite) must await this method
before opening its transaction, so no write lock is held across a wait.
First validate the body with
RequestBody::new, then await reserve, then call
RequestReservation::send inside the transaction without awaiting.
Checks the route, waits for route credit and writer capacity, and assigns
a correlation id. deadline is an absolute Tokio deadline for reservation
and the eventual reply. No frame is queued until send is called.
Source§impl SubcConsumer
impl SubcConsumer
Sourcepub fn route_target(&self, handle: &RouteHandle) -> Option<RouteOpenTarget>
pub fn route_target(&self, handle: &RouteHandle) -> Option<RouteOpenTarget>
Target authority captured on this live route’s open reply. An older daemon, an incomplete target, or a retired handle provides no target authority. Catalog entries are discovery facts, not a substitute for this value.
Sourcepub async fn catalog_watch(&self) -> Result<CatalogSubscription, CallError>
pub async fn catalog_watch(&self) -> Result<CatalogSubscription, CallError>
Follow catalog generations on channel 0. The first response carries the current generation; later advances may coalesce. Reconnect ends the feed: open a new watch and refresh the catalog rather than assuming no changes.
Source§impl SubcConsumer
impl SubcConsumer
Sourcepub async fn config_status(&self) -> Result<ConfigStatus, CallError>
pub async fn config_status(&self) -> Result<ConfigStatus, CallError>
Read configuration protection and its diagnostics without prompting (config.status).
Use Self::connect_local for the daemon’s owner-user check.
Sourcepub async fn config_modules(&self) -> Result<ConfigModulesResponse, CallError>
pub async fn config_modules(&self) -> Result<ConfigModulesResponse, CallError>
List gated and ungated modules without prompting (config.modules).
Status strings are open; display unknown statuses as raw text. Like all
settings calls, this can refuse with owner_required on a nonlocal connection.
Sourcepub async fn config_schema(
&self,
module_id: impl Into<String>,
) -> Result<ConfigSchemaResponse, CallError>
pub async fn config_schema( &self, module_id: impl Into<String>, ) -> Result<ConfigSchemaResponse, CallError>
Read an admitted schema (config.schema), never prompting. Expect
unknown_module for an unknown id or module_ungated for one without a schema.
Sourcepub async fn config_show(
&self,
module_id: impl Into<String>,
project_id: Option<String>,
through: Option<ConfigThrough>,
) -> Result<ConfigShowResponse, CallError>
pub async fn config_show( &self, module_id: impl Into<String>, project_id: Option<String>, through: Option<ConfigThrough>, ) -> Result<ConfigShowResponse, CallError>
Read approved settings, or current file settings at generation zero when
unstamped (config.show). through limits the merged layers. Expect
unknown_module, module_ungated, or unknown_project for unavailable selectors.
Sourcepub async fn config_plan(
&self,
base_generations: Option<BTreeMap<String, u64>>,
edits: Option<Vec<ConfigEdit>>,
) -> Result<ConfigPlanView, CallError>
pub async fn config_plan( &self, base_generations: Option<BTreeMap<String, u64>>, edits: Option<Vec<ConfigEdit>>, ) -> Result<ConfigPlanView, CallError>
Prepare a reviewable plan without prompting (config.plan). Pass both
arguments as None to plan file drift (requires a stamp, otherwise
config_gated), or supply edits and each touched
module’s config.show base generation. Missing bases are invalid_params;
moved bases are config_changed_since_review. Field refusals (including
layer_not_served for workspace/project edits) are in view.refusals and
block the whole plan. Sent once, never retried.
Sourcepub async fn config_plan_get(
&self,
digest: Digest,
) -> Result<ConfigPlanView, CallError>
pub async fn config_plan_get( &self, digest: Digest, ) -> Result<ConfigPlanView, CallError>
Retrieve the pending review view by its full digest (config.plan_get).
unknown_plan means it was applied, discarded, expired or superseded.
Sourcepub async fn config_plan_discard(&self, digest: Digest) -> Result<(), CallError>
pub async fn config_plan_discard(&self, digest: Digest) -> Result<(), CallError>
Drop a pending plan without applying or prompting (config.plan_discard).
Expect unknown_plan if gone or plan_in_review while being approved.
Sent once, never retried.
Sourcepub async fn config_apply(
&self,
digest: Digest,
) -> Result<ConfigApplyResponse, CallError>
pub async fn config_apply( &self, digest: Digest, ) -> Result<ConfigApplyResponse, CallError>
Apply exactly the reviewed digest (config.apply). Unstamped installs
apply immediately; stamped installs wait for trusted operator approval.
The timeout adds the daemon’s 290-second OPERATOR_RESPONSE_BUDGET to the
consumer’s control-call timeout, as ck config apply does. Expect
plan_unknown, plan_refused, config_changed_since_review, or approval
refusal codes. Sent once: after a timeout or connection loss, re-read
settings before deciding what to do, because the apply may have committed.
Sourcepub async fn config_watch(
&self,
modules: Option<Vec<String>>,
) -> Result<ConfigSubscription, CallError>
pub async fn config_watch( &self, modules: Option<Vec<String>>, ) -> Result<ConfigSubscription, CallError>
Watch module settings rows (config.watch), optionally filtered by id.
Every watch starts with a resync; any later resync replaces all state.
Re-read settings/schema on changes. A reconnect ends the subscription;
open another watch for a fresh resync. Daemon refusals arrive through
ConfigSubscription::next and retain their code; inspect
ConfigSubscription::ended for the complete terminal reason.
Sourcepub async fn config_watch_projects(
&self,
modules: Option<Vec<String>>,
) -> Result<ConfigSubscription, CallError>
pub async fn config_watch_projects( &self, modules: Option<Vec<String>>, ) -> Result<ConfigSubscription, CallError>
Watch settings rows including projects, optionally filtered by module id.
The daemon must advertise config.settings.projects/v1 to include project
rows. A resync replaces every row, including project rows; key the rows by
(module_id, project_id). See Self::config_watch for stream semantics.
Source§impl SubcConsumer
impl SubcConsumer
Sourcepub async fn supervisor_health(
&self,
) -> Result<SupervisorHealthResponse, CallError>
pub async fn supervisor_health( &self, ) -> Result<SupervisorHealthResponse, CallError>
The supervisor’s stored health record for every module
(supervisor.health). Answered from the daemon’s cache; nothing is
probed.
Sourcepub async fn supervisor_provenance(
&self,
module_id: Option<String>,
) -> Result<SupervisorProvenanceResponse, CallError>
pub async fn supervisor_provenance( &self, module_id: Option<String>, ) -> Result<SupervisorProvenanceResponse, CallError>
Daemon and module provenance (supervisor.provenance), for every
module or only module_id.
Sourcepub async fn supervisor_routes(
&self,
module_id: Option<String>,
) -> Result<Vec<SupervisorRouteModule>, CallError>
pub async fn supervisor_routes( &self, module_id: Option<String>, ) -> Result<Vec<SupervisorRouteModule>, CallError>
The live routes each module serves (supervisor.routes): every
module’s when module_id is None, otherwise only that module’s.
Sourcepub async fn supervisor_stderr_tail(
&self,
module_id: impl Into<String>,
max_lines: Option<u32>,
max_bytes: Option<u32>,
) -> Result<StderrTailResponse, CallError>
pub async fn supervisor_stderr_tail( &self, module_id: impl Into<String>, max_lines: Option<u32>, max_bytes: Option<u32>, ) -> Result<StderrTailResponse, CallError>
The module’s retained stderr (supervisor.stderr_tail), oldest entry
first, capped by max_lines and max_bytes when given.
Sourcepub async fn supervisor_health_probe(
&self,
module_id: impl Into<String>,
) -> Result<HealthProbeResponse, CallError>
pub async fn supervisor_health_probe( &self, module_id: impl Into<String>, ) -> Result<HealthProbeResponse, CallError>
Asks one module for its health now (supervisor.health_probe), the
probe ck health <id> sends. Unlike the cached view, the metrics are
complete.
Sourcepub async fn supervisor_terminals(
&self,
module_id: impl Into<String>,
) -> Result<TerminalHistory, CallError>
pub async fn supervisor_terminals( &self, module_id: impl Into<String>, ) -> Result<TerminalHistory, CallError>
The module’s retained process exits (supervisor.terminals), with
what the supervisor did after each.
Sourcepub async fn server_describe(&self) -> Result<ServerDescription, CallError>
pub async fn server_describe(&self) -> Result<ServerDescription, CallError>
The daemon’s description of itself (server.describe).
Sourcepub async fn supervisor_restart(
&self,
module_id: impl Into<String>,
drain_timeout_ms: Option<u64>,
) -> Result<SupervisorAck, CallError>
pub async fn supervisor_restart( &self, module_id: impl Into<String>, drain_timeout_ms: Option<u64>, ) -> Result<SupervisorAck, CallError>
Restart one module (supervisor.restart), the request ck module restart sends. drain_timeout_ms overrides the module’s drain budget
for this restart; None keeps the configured one. Sent once, never
retried.
Sourcepub async fn supervisor_set_enabled(
&self,
module_id: impl Into<String>,
enabled: bool,
) -> Result<SupervisorAck, CallError>
pub async fn supervisor_set_enabled( &self, module_id: impl Into<String>, enabled: bool, ) -> Result<SupervisorAck, CallError>
Sends supervisor.set_enabled for one module: enabled: true starts
it and false stops it, the same request ck module start and
ck module stop send. This method sends the request once and never
retries it.
Sourcepub async fn supervisor_rescan_checked(
&self,
preview: bool,
candidate: Option<String>,
expect: Option<RescanExpect>,
) -> Result<SupervisorRescanResult, CallError>
pub async fn supervisor_rescan_checked( &self, preview: bool, candidate: Option<String>, expect: Option<RescanExpect>, ) -> Result<SupervisorRescanResult, CallError>
Sends supervisor.rescan_checked and returns the daemon’s rescan
result. With preview: true and the full candidate config text, the
daemon previews that text and writes nothing; the result carries what
each module would do and the expect value an apply must send. With
preview: false and that expect, the daemon applies its config file
only if the file and its staged state still match the preview. Any
other combination is refused by the daemon. A refusal, such as
invalid_daemon_config for a candidate the daemon can’t load, comes
back as CallError::Module.
Send this only to a daemon whose server.describe lists
rescan-candidate-preview/v1. A preview is retried on transport
failures like the other reads; an apply is sent once and never retried,
because one whose outcome is unknown may already have applied.
Source§impl SubcConsumer
impl SubcConsumer
Sourcepub async fn connect(
connection_file: &Path,
opts: ConsumerOptions,
) -> Result<Self, ConsumerError>
pub async fn connect( connection_file: &Path, opts: ConsumerOptions, ) -> Result<Self, ConsumerError>
Connect through an explicit connection-file path. The initial connection generation uses epoch 1; each reconnect advances it. In a supervised process, the module’s primary registration connection mints a fresh self claim for every connection, including reconnects. Mint/presentation failure is an error, never a direct connection: dropping the binding would change the caller’s authority. Unsupervised processes retain the legacy behavior.
Sourcepub async fn connect_local(
connection_file: &Path,
opts: ConsumerOptions,
) -> Result<Self, ConsumerError>
pub async fn connect_local( connection_file: &Path, opts: ConsumerOptions, ) -> Result<Self, ConsumerError>
Connect only to the connection file’s same-user Unix socket or Windows pipe.
Each connection attempt, including reconnects, reads the current local
endpoint and key from the same owner-checked file. A missing
local_endpoint returns ConsumerError::NoEndpoint; a local connect
failure retains its endpoint and I/O error. Neither case falls back to TCP.
Sourcepub async fn connect_default(
opts: ConsumerOptions,
) -> Result<Self, ConsumerError>
pub async fn connect_default( opts: ConsumerOptions, ) -> Result<Self, ConsumerError>
Discover the daemon’s connection file, authenticate, and start the I/O loop.
Sourcepub async fn connect_default_local(
opts: ConsumerOptions,
) -> Result<Self, ConsumerError>
pub async fn connect_default_local( opts: ConsumerOptions, ) -> Result<Self, ConsumerError>
Discover the daemon’s connection file and connect only to its local endpoint.
Uses Self::connect_local, including its per-attempt file reads and
refusal to fall back to TCP.
Sourcepub async fn connect_operator_app(
opts: ConsumerOptions,
) -> Result<Self, ConsumerError>
pub async fn connect_operator_app( opts: ConsumerOptions, ) -> Result<Self, ConsumerError>
Connect the desktop operator app to the installed daemon without reading environment variables for discovery or consumer identity.
Tries crate::operator_app_candidates in order on every attempt,
selecting the first existing owner-checked file. Uses the
same per-attempt file reads and local-only transport as
Self::connect_local, never falling back to TCP. Requests omit implicit
consumer identity, including after reconnect; explicit identities in
CallOptions and CloseRouteOptions are still honoured.
Sourcepub async fn connect_operator_app_plain(
opts: ConsumerOptions,
) -> Result<Self, ConsumerError>
pub async fn connect_operator_app_plain( opts: ConsumerOptions, ) -> Result<Self, ConsumerError>
Open the desktop operator app’s plain connection over TCP.
Selects and owner-checks the installed daemon’s connection file with the
same crate::operator_app_candidates policy as
Self::connect_operator_app, then connects to the file’s first TCP
endpoint instead of its Unix socket or Windows named pipe.
The daemon recognises a connection as the operator app only when it
arrives over its Unix socket or named pipe, so this connection never
carries the operator_app stamp and can’t skip the daemon’s
confirmation. Its privileged requests follow the daemon’s configured
policy like any other client’s. The caller decides which actions to send
here, for example those made through assistive technology. This API
doesn’t classify input.
When the daemon supports connection.describe,
Self::describe_connection reports this connection with
local() == false. There, local means the Unix socket or named pipe,
not loopback.
Like Self::connect_operator_app, it reads no environment variable for
discovery or consumer identity, including after reconnect, and never
falls back to the local endpoint.
Sourcepub async fn open_route(
&self,
target: RouteTarget,
identity: BindIdentity,
opts: CallOptions,
) -> Result<RouteHandle, CallError>
pub async fn open_route( &self, target: RouteTarget, identity: BindIdentity, opts: CallOptions, ) -> Result<RouteHandle, CallError>
Open or reuse an unscoped managed route and return a handle tied to its
current connection (stale after a reconnect).
A scope in opts is an argument error; use Self::open_route_scoped.
Sourcepub async fn open_route_scoped(
&self,
target: RouteTarget,
identity: BindIdentity,
scope: ScopeSelector,
opts: CallOptions,
) -> Result<RouteHandle, CallError>
pub async fn open_route_scoped( &self, target: RouteTarget, identity: BindIdentity, scope: ScopeSelector, opts: CallOptions, ) -> Result<RouteHandle, CallError>
Open or reuse a managed route admitted under scope, and return a handle
tied to its current connection (stale after a reconnect).
This is how a carrier opens its onward route for a session. The daemon
admits the open only when the opener (the consumer identity in opts,
or the supervised module’s own identity from the environment) is the
scope’s owner or one of its listed carriers, and it stamps the
provider’s bind with the scope. scope.scope_epoch must be set: the
daemon refuses an open without it (scope_epoch_required).
The route is cached under the whole selector (owner, ref and epoch) as
well as the target and identities, so a route opened under one scope or
epoch is never returned to a caller asking for another, and a scoped
route is never returned by Self::open_route (nor an unscoped one
here). Once the route closes, the next call with the same selector opens
a fresh route under that selector. Close it early with
Self::close_handle.
Refusals: scope_not_synced (the owner has not synced since the daemon
started) and scope_changed (the scope changed while the bind was in
flight) are retried within the call’s deadline, like a module reload.
scope_ended, scope_not_live, scope_epoch_required and
scope_not_carrier end the call at once as CallError::NotSent, with
the daemon’s code in CallError::route_open_refusal.
When the daemon later closes the route because its scope ended or the
opener’s authority under it was revoked, Self::control_pushes
delivers route.closed with a scope_* reason. Its
RouteCloseReason::disposition is
RouteCloseDisposition::MustNotReopen: the session the route served is
over, so callers should stop work for that session. The SDK does not
cache a tombstone: a later explicit open or managed call with the same
selector attempts a fresh open. The daemon refuses it as scope_ended
if the ref is live at another epoch, or scope_not_live if the ref is gone.
A selector in opts.scope must equal scope, or the call fails locally
as an argument error before opening a route.
Sourcepub async fn open_route_with_admission_facts(
&self,
target: RouteTarget,
identity: BindIdentity,
facts: Value,
) -> Result<RouteHandle, CallError>
pub async fn open_route_with_admission_facts( &self, target: RouteTarget, identity: BindIdentity, facts: Value, ) -> Result<RouteHandle, CallError>
Open one admitted route without entering the managed route cache.
Admitted routes are never cached or reopened after a connection drop. If this call fails or the route later closes, the caller must perform admission again and call this method with fresh facts.
The route declares no reverse-request capabilities, so the provider cannot
send it requests. Use Self::open_route_with_admission_facts_and_options
when the provider asks the consumer questions on the route (elicitation).
Sourcepub async fn open_route_with_admission_facts_and_options(
&self,
target: RouteTarget,
identity: BindIdentity,
facts: Value,
opts: CallOptions,
) -> Result<RouteHandle, CallError>
pub async fn open_route_with_admission_facts_and_options( &self, target: RouteTarget, identity: BindIdentity, facts: Value, opts: CallOptions, ) -> Result<RouteHandle, CallError>
Open one admitted route, with the reverse-request handlers, capability
declarations and timeout in opts.
The route declares the method families of handlers registered on
opts.reverse_requests, together with any provider-contract declarations
in the extra declarations reported by opts.consumer_capabilities(). For example, tool-result/v1 declares the
tool-provider content result format. These are unverified declarations,
not privilege grants. Requests the provider sends back (elicitation,
sampling) reach the registered handlers, exactly as on a managed route.
Handlers must be registered before this call: the registry is sealed
when the route opens, because the declared method families are what the
provider was told.
Like Self::open_route_with_admission_facts, the route is never cached
or reopened; after a failure or a close the caller performs admission again.
A non-None opts.scope is rejected as an argument error.
Sourcepub async fn describe_connection(
&self,
) -> Result<Option<ConnectionFacts>, CallError>
pub async fn describe_connection( &self, ) -> Result<Option<ConnectionFacts>, CallError>
Describe this connection without prompting or granting any privilege.
An older daemon’s unknown_control_op refusal returns None: that daemon
doesn’t support this query, which says nothing about recognition.
Sourcepub async fn app_open(&self, app: &str) -> Result<AppOpenReply, AppOpenError>
pub async fn app_open(&self, app: &str) -> Result<AppOpenReply, AppOpenError>
Ask the daemon to open a known installed app. Starting it grants nothing. Future success statuses and refusal codes are preserved for the caller.
Sourcepub async fn catalog_list(&self) -> Result<CatalogList, CallError>
pub async fn catalog_list(&self) -> Result<CatalogList, CallError>
Fetch the daemon’s module catalog over channel 0. Transport retries use the consumer’s reconnect backoff and call deadline.
Sourcepub async fn supervisor_list(&self) -> Result<SupervisorListResponse, CallError>
pub async fn supervisor_list(&self) -> Result<SupervisorListResponse, CallError>
Fetch the supervisor’s configured module list over channel 0. Transport retries use the consumer’s reconnect backoff and call deadline.
Sourcepub async fn spawn_snapshot(&self) -> Result<SpawnSnapshot, CallError>
pub async fn spawn_snapshot(&self) -> Result<SpawnSnapshot, CallError>
Fetch the supervisor’s atomic spawn snapshot (supervisor.spawn_snapshot)
over channel 0: the live processes with their spawn generations, and the
cursor at which they were observed.
A daemon refusal comes back as CallError::Module, so its code is readable
through CallError::code. Transport failures are retried until the
consumer’s call deadline with its reconnect backoff, as for
SubcConsumer::catalog_list.
Sourcepub async fn query_activity(
&self,
request: ActivityQueryRequest,
) -> Result<ActivityQueryResponse, CallError>
pub async fn query_activity( &self, request: ActivityQueryRequest, ) -> Result<ActivityQueryResponse, CallError>
Query the newest-first activity ledger. The reply preserves entries, the
continuation cursor and the head to subscribe from without a query/follow gap.
Except for operator-app connections, identity is filled from the supervised
launch environment, as for route.open; without one the daemon treats the
caller as Direct. Refusals retain their code
through CallError::code. Transport retries are paced to the call deadline.
Sourcepub async fn subscribe_activity(
&self,
since: Option<ActivityCursor>,
) -> Result<ActivitySubscription, CallError>
pub async fn subscribe_activity( &self, since: Option<ActivityCursor>, ) -> Result<ActivitySubscription, CallError>
Follow durable activity entries after since, or from now if absent.
The launch identity is filled as for Self::query_activity. Refused cursors
and subscriber lag are terminal stream errors whose daemon code is readable
through crate::ActivityStreamError::code. On reconnect the stream ends;
recover with a query and subscribe from its head.
Sourcepub async fn spawn_subscribe(
&self,
since: Option<SpawnCursor>,
) -> Result<SpawnSubscription, CallError>
pub async fn spawn_subscribe( &self, since: Option<SpawnCursor>, ) -> Result<SpawnSubscription, CallError>
Follow the supervisor’s spawn event stream (supervisor.spawn_subscribe) over
channel 0, from just after since (a cursor copied from a snapshot or an event),
or from now when since is None.
The request is held open: the returned SpawnSubscription yields each event
until the stream ends. A cursor the daemon refuses, and the daemon dropping a
subscriber that fell behind, arrive as the stream’s terminal error (see
SpawnStreamError). A reconnect ends the stream; the caller resubscribes from
the last cursor it received. Sending is retried until the consumer’s call
deadline, as for SubcConsumer::spawn_snapshot.
Sourcepub async fn resolve_provider(
&self,
capability: &str,
) -> Result<String, CallError>
pub async fn resolve_provider( &self, capability: &str, ) -> Result<String, CallError>
Resolve the sole catalog claimant for a capability.
Resolution is deliberately based only on the static capabilities mirror in
catalog.list; module ids and role names are not fallback claims. Calling
this method expresses singular intent, so a plural catalog result is an
explicit ambiguity rather than an arbitrary choice.
Sourcepub async fn resolve_providers(
&self,
capability: &str,
) -> Result<Vec<String>, CallError>
pub async fn resolve_providers( &self, capability: &str, ) -> Result<Vec<String>, CallError>
Resolve every catalog claimant for a capability in module-id order.
The identifier is validated before any channel-0 request is made, so a typo cannot become a network-dependent “unprovided” result.
Sourcepub async fn request(
&self,
handle: &RouteHandle,
body: Vec<u8>,
opts: CallOptions,
) -> Result<Vec<u8>, CallError>
pub async fn request( &self, handle: &RouteHandle, body: Vec<u8>, opts: CallOptions, ) -> Result<Vec<u8>, CallError>
Send one request using an already-opened route handle.
opts.scope must be None: the handle’s scope was selected at route open.
Sourcepub fn request_cancellable(
&self,
handle: &RouteHandle,
body: Vec<u8>,
opts: CallOptions,
) -> (CancelHandle, impl Future<Output = Result<Vec<u8>, CallError>> + Send + '_)
pub fn request_cancellable( &self, handle: &RouteHandle, body: Vec<u8>, opts: CallOptions, ) -> (CancelHandle, impl Future<Output = Result<Vec<u8>, CallError>> + Send + '_)
Like Self::request, with explicit cancellation of the in-flight request.
The returned future is lazy and has the same result and deadline as request.
Calling CancelHandle::cancel sends at most one header-only Cancel on the
request’s route; it does not stop waiting for the provider’s Response or Error.
Dropping the handle sends nothing. Dropping the future only removes its
pending registration, without sending Cancel.
let (cancel, reply) = consumer.request_cancellable(
route, b"work".to_vec(), subc_client_rs::CallOptions::default());
tokio::pin!(reply);
tokio::select! {
result = &mut reply => { let _body = result?; }
() = turn_stopped => {
cancel.cancel().await;
let _body = reply.await?; // Keep any final Response body.
}
}Sourcepub async fn subscribe_route(
&self,
handle: &RouteHandle,
body: Vec<u8>,
opts: SubscribeOptions,
) -> Result<Subscription, CallError>
pub async fn subscribe_route( &self, handle: &RouteHandle, body: Vec<u8>, opts: SubscribeOptions, ) -> Result<Subscription, CallError>
Start a held-open request using an already-opened route handle.
opts.scope must be None: the handle’s scope was selected at route open.
Sourcepub async fn poll_route(
&self,
handle: &RouteHandle,
kind: PollKind,
timeout: Duration,
) -> Result<RoutePollResult, CallError>
pub async fn poll_route( &self, handle: &RouteHandle, kind: PollKind, timeout: Duration, ) -> Result<RoutePollResult, CallError>
Poll status or liveness for exactly this route handle.
A daemon refusal is returned as CallError::Module with its original body.
Sourcepub fn dropped_route_frames(&self) -> u64
pub fn dropped_route_frames(&self) -> u64
Locally observed count of unknown or stale route frames dropped by layer-2 validation.
Sourcepub fn push_events(
&self,
handle: &RouteHandle,
) -> Result<Receiver<PushEvent>, CallError>
pub fn push_events( &self, handle: &RouteHandle, ) -> Result<Receiver<PushEvent>, CallError>
Register a receiver for provider-originated Push frames on exactly one live route.
Registering another receiver for the same route replaces and closes the prior receiver.
The receiver closes when its route closes or the connection drops. A FULL buffer drops
the overflowing push and counts it on pushes_dropped_receiver_full while the
subscription survives (issue #40; push is a lossy latency optimization and polling
remains the correctness backstop). The reader never waits for an application that is
not draining pushes.
Sourcepub fn pushes_dropped_no_receiver(&self) -> u64
pub fn pushes_dropped_no_receiver(&self) -> u64
Number of Push frames dropped because their live route has no active receiver.
Push is a one-way latency optimization, not a durable feed: the client does not acknowledge it, and callers retain polling as their correctness backstop. Counting intentional default-path drops makes an application that has not opted in observable.
Sourcepub fn pushes_dropped_receiver_full(&self) -> u64
pub fn pushes_dropped_receiver_full(&self) -> u64
Pushes dropped because the registered receiver’s bounded buffer was full.
The subscription SURVIVES a burst (the receiver stays registered); this
counter is the trace the burst leaves. Distinct from
pushes_dropped_no_receiver because the remedies differ: full means
drain faster or register with more capacity, no-receiver means nobody
subscribed.
Sourcepub fn control_pushes(&self, capacity: usize) -> Receiver<ControlPush>
pub fn control_pushes(&self, capacity: usize) -> Receiver<ControlPush>
Register the consumer-level receiver for daemon-originated channel-0
control pushes (route.closing, route.closed, and any op added
later). Advisory by contract: GOODBYE remains the load-bearing
route-death signal and nothing in the client’s own lifecycle consumes
these. Unrecognized ops are DELIVERED (the must-ignore choice belongs
to the consumer); unparseable bodies are dropped and counted. The
receiver survives reconnects. Registering again replaces the prior
receiver; a full or closed receiver drops the push and counts it
rather than blocking the reader.
Sourcepub fn control_pushes_dropped(&self) -> u64
pub fn control_pushes_dropped(&self) -> u64
Always-present count of dropped channel-0 control pushes (no receiver
registered, receiver full or closed, or unparseable body). Emitted as a
counter rather than silence so an application that has not opted in is
observable, mirroring pushes_dropped_no_receiver.
Sourcepub async fn call(
&self,
target: RouteTarget,
identity: BindIdentity,
body: Vec<u8>,
opts: CallOptions,
) -> Result<Vec<u8>, CallError>
pub async fn call( &self, target: RouteTarget, identity: BindIdentity, body: Vec<u8>, opts: CallOptions, ) -> Result<Vec<u8>, CallError>
Managed unary call. Route-open failures happen before the body is sent and are
classified as NotSent; module handler Error frames are the only Module errors.
A daemon refusal that proves the module never received the request
(unknown_channel, stale_route_epoch, or module_reloading while the
module drains for a restart, reload or disable) evicts the cached route,
reopens it and resends the request once, within the call deadline and
only if the call has not been cancelled. Reopening during a drain waits
out the daemon’s route.open refusals until the replacement process
registers, so the resend reaches the new process. A second such refusal
is returned as CallError::Module.
Sourcepub async fn call_with_reply(
&self,
target: RouteTarget,
identity: BindIdentity,
body: Vec<u8>,
opts: CallOptions,
) -> Result<CallReply, CallError>
pub async fn call_with_reply( &self, target: RouteTarget, identity: BindIdentity, body: Vec<u8>, opts: CallOptions, ) -> Result<CallReply, CallError>
Like Self::call, retaining the terminal Response’s binary flag as well
as its unchanged body bytes. A StreamEnd yields an empty, non-binary reply.
Sourcepub fn call_cancellable(
&self,
target: RouteTarget,
identity: BindIdentity,
body: Vec<u8>,
opts: CallOptions,
) -> (CancelHandle, impl Future<Output = Result<Vec<u8>, CallError>> + Send + '_)
pub fn call_cancellable( &self, target: RouteTarget, identity: BindIdentity, body: Vec<u8>, opts: CallOptions, ) -> (CancelHandle, impl Future<Output = Result<Vec<u8>, CallError>> + Send + '_)
Managed unary call with explicit cancellation, like Self::request_cancellable.
Uses the same route opening, options, errors and deadline as Self::call.
Once cancellation is requested, a dead-route or module_reloading refusal is
returned rather than retrying work the caller has asked to stop. Cancellation during route opening
is remembered and sent after the Request is queued. Dropping either value
sends no Cancel; dropping the future removes its pending registration.
Sourcepub fn call_cancellable_with_reply(
&self,
target: RouteTarget,
identity: BindIdentity,
body: Vec<u8>,
opts: CallOptions,
) -> (CancelHandle, impl Future<Output = Result<CallReply, CallError>> + Send + '_)
pub fn call_cancellable_with_reply( &self, target: RouteTarget, identity: BindIdentity, body: Vec<u8>, opts: CallOptions, ) -> (CancelHandle, impl Future<Output = Result<CallReply, CallError>> + Send + '_)
Like Self::call_cancellable, retaining the terminal Response’s binary
flag and unchanged bytes in CallReply. Cancellation, retries, deadlines
and drop behavior are identical. A StreamEnd yields an empty, non-binary reply.
Sourcepub async fn call_framed_with_reply(
&self,
target: RouteTarget,
identity: BindIdentity,
head: Value,
payload: Vec<u8>,
opts: CallOptions,
) -> Result<CallReply, CallError>
pub async fn call_framed_with_reply( &self, target: RouteTarget, identity: BindIdentity, head: Value, payload: Vec<u8>, opts: CallOptions, ) -> Result<CallReply, CallError>
Sends a framed JSON object head and opaque payload with FLAG_BINARY.
Only use this for management operations that declare operation_payload.
The caller enforces the operation’s limit; the codec only bounds the head.
Sourcepub fn call_framed_cancellable_with_reply(
&self,
target: RouteTarget,
identity: BindIdentity,
head: Value,
payload: Vec<u8>,
opts: CallOptions,
) -> (CancelHandle, impl Future<Output = Result<CallReply, CallError>> + Send + '_)
pub fn call_framed_cancellable_with_reply( &self, target: RouteTarget, identity: BindIdentity, head: Value, payload: Vec<u8>, opts: CallOptions, ) -> (CancelHandle, impl Future<Output = Result<CallReply, CallError>> + Send + '_)
Cancellable companion to Self::call_framed_with_reply, with the same
lazy send, cancellation, retry and deadline behavior as other managed calls.
Sourcepub async fn subscribe(
&self,
target: RouteTarget,
identity: BindIdentity,
body: Vec<u8>,
opts: SubscribeOptions,
) -> Result<Subscription, CallError>
pub async fn subscribe( &self, target: RouteTarget, identity: BindIdentity, body: Vec<u8>, opts: SubscribeOptions, ) -> Result<Subscription, CallError>
Open a held-open subscription on a managed route.
This opens or reuses the same (target, identity, consumer_identity, consumer_capabilities, role_versions, scope) route as
SubcConsumer::call, sends one Request that the provider keeps open, and
returns a Subscription whose event receiver yields each matching
StreamData payload. The request holds one route flow-control permit until
StreamEnd, an Error frame, route teardown or connection loss. On negotiated
routes, local backpressure and unsubscribe keep credit until a wire terminal.
Reconnects reject the
subscription; callers that need durable replay should resubscribe with their
own cursor after observing the failure.
Sourcepub async fn close_route(
&self,
target: RouteTarget,
identity: BindIdentity,
opts: CloseRouteOptions,
)
pub async fn close_route( &self, target: RouteTarget, identity: BindIdentity, opts: CloseRouteOptions, )
Tear down ONE route, keyed by its route-open identity tuple — the parity of the TS
client’s closeRoute. For a long-lived consumer that opens unbounded distinct
routes (one per session), this releases a route on session-end without dropping
the whole consumer: it drops the cached route, settles in-flight requests on it
at-most-once (OutcomeUnknown if already sent, NotSent otherwise), and queues a
route GOODBYE so the daemon releases it and notifies the module. When closing
a cached route returns, its GOODBYE is queued ahead of any frame sent later on
this connection, so the caller may release its per-route budget. If the
connection died instead, the daemon releases all its routes on disconnect.
opts.scope selects only that scope’s cache entry; None selects only
the unscoped entry. Calls and subscriptions use the same route cache.
Idempotent: a no-op if the route was never opened or is already closed (callers
over-call on session-end). NOT a permanent tombstone — a later call() for the
same key opens a fresh route. The close-beats-reopen guard ensures a close that
races an in-flight route.open WINS (the opened channel is GOODBYE’d, not cached).
§Cancel safety
Once the cached route is removed, dropping this future abandons any drain wait but still settles pending requests and queues its GOODBYE in the background. The handle stays installed until GOODBYE is queued, unless the connection dies. Cancellation does not queue a second GOODBYE if the close already completed.
Sourcepub async fn close_handle(
&self,
handle: &RouteHandle,
opts: CloseRouteOptions,
) -> Result<(), CallError>
pub async fn close_handle( &self, handle: &RouteHandle, opts: CloseRouteOptions, ) -> Result<(), CallError>
Close exactly this route handle. A stale connection token fails locally and emits no frame.
opts.scope must be None: the handle already selects exactly one route.
§Cancel safety
After the handle is validated and its route removed, dropping this future abandons any drain wait but still settles pending requests and queues its GOODBYE in the background. The handle is uninstalled after queueing, or when the connection dies; a completed close never queues a second GOODBYE on drop.
Sourcepub fn current_epoch(&self) -> u64
pub fn current_epoch(&self) -> u64
Current transport epoch: 1 on initial connect, then +1 per successful reconnect.
Sourcepub fn on_connection_state(&self, cb: impl Fn(ConnectionState) + Send + 'static)
pub fn on_connection_state(&self, cb: impl Fn(ConnectionState) + Send + 'static)
Register a connection-state callback. Callbacks are best-effort observability hooks.