Skip to main content

Client

Struct Client 

Source
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

Source

pub async fn connect(endpoint: &Endpoint) -> Result<Self, CliError>

Dials endpoint and greets it as Role::Cli.

§Errors
  • CliError::NoCluster if nothing is listening — the one failure a user hits constantly, reported as “start one with astrs up” rather than as a raw ECONNREFUSED.
  • CliError::Transport for a refusal or a protocol failure.
Source

pub const fn session(&self) -> SessionId

The session the coordinator assigned this connection.

Source

pub fn display(&self) -> &str

How the endpoint was named, for a caller’s own messages.

Source

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
Source

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.

Source

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.

Source

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.

Source

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.

Source

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
Source

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

Trait Implementations§

Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeDebug for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more