pub struct Client { /* private fields */ }Expand description
One connected CLI session.
Owns the socket and nothing else: every verb drives it with
Client::request and, for a subscription, Client::next_frame.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn connect(endpoint: &Endpoint) -> Result<Self, CliError>
pub async fn connect(endpoint: &Endpoint) -> Result<Self, CliError>
Dials endpoint and greets it as Role::Cli.
§Errors
CliError::NoClusterif nothing is listening — the one failure a user hits constantly, reported as “start one withastrs up” rather than as a rawECONNREFUSED.CliError::Transportfor a refusal or a protocol failure.
Sourcepub async fn request(
&mut self,
label: &'static str,
request: &ControlRequest,
) -> Result<ControlReply, CliError>
pub async fn request( &mut self, label: &'static str, request: &ControlRequest, ) -> Result<ControlReply, CliError>
Sends one request and waits for its ControlReply.
label names the verb in any error, so a failure reads
“the coordinator refused list” rather than naming a wire variant
the user never typed.
§Errors
CliError::Transportif the socket fails or the reply does not arrive withinREQUEST_TIMEOUT.CliError::Refusedif the coordinator answeredControlReply::Error.
Sourcepub async fn request_ok(
&mut self,
label: &'static str,
request: &ControlRequest,
) -> Result<(), CliError>
pub async fn request_ok( &mut self, label: &'static str, request: &ControlRequest, ) -> Result<(), CliError>
Sends one request and requires a plain ControlReply::Ok.
§Errors
As Client::request, plus CliError::UnexpectedReply when the
answer is neither Ok nor an error.
Sourcepub async fn next_frame(&mut self) -> Result<Option<Frame>, CliError>
pub async fn next_frame(&mut self) -> Result<Option<Frame>, CliError>
Waits for the next frame the coordinator pushes — a Log for an
open LogSubscribe, a Data for a topic tap.
Returns Ok(None) when the coordinator closed the connection, which
is how a logs -f ends when the cluster goes down rather than an
error a user should see a backtrace-shaped message for.
§Errors
CliError::Transport if the socket fails.
Sourcepub async fn close(self) -> Result<(), CliError>
pub async fn close(self) -> Result<(), CliError>
Closes the connection politely.
§Errors
CliError::Transport if the shutdown fails — reported rather than
swallowed so a caller that cares (a script asserting a clean
teardown) can, while every ordinary caller ignores it.
Sourcepub async fn list_dataflows(
&mut self,
all: bool,
) -> Result<Vec<DataflowSummary>, CliError>
pub async fn list_dataflows( &mut self, all: bool, ) -> Result<Vec<DataflowSummary>, CliError>
Every dataflow the coordinator knows about.
§Errors
As Client::request, plus CliError::UnexpectedReply when the
answer is not a DataflowList.
Sourcepub async fn resolve(
&mut self,
reference: &DataflowRef,
) -> Result<DataflowId, CliError>
pub async fn resolve( &mut self, reference: &DataflowRef, ) -> Result<DataflowId, CliError>
Turns a user-typed reference into the id every request but
StopByName/RestartByName needs.
An id is taken as written — no round trip, so astrs logs <uuid>
works against a coordinator whose List is momentarily large. A name
costs one List { all: true }: names are not unique by construction
(nothing stops two runs sharing one), so an ambiguous name is refused
with the ids to choose between rather than resolved arbitrarily.
§Errors
- As
Client::request. CliError::UnknownDataflowwhen nothing matches, or when more than one dataflow answers to the same name.
Sourcepub async fn sole_dataflow(&mut self, all: bool) -> Result<DataflowId, CliError>
pub async fn sole_dataflow(&mut self, all: bool) -> Result<DataflowId, CliError>
The one dataflow a verb should act on when the user named none.
Convenience with a hard edge: exactly one candidate is resolved, and anything else is refused. Guessing between two running graphs is how a CLI stops a robot’s perception stack when the user meant to tail its planner.
§Errors
- As
Client::request. CliError::UnknownDataflowwhen zero, or more than one, dataflow is known.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
impl UnwindSafe for Client
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more