Skip to main content

ClientRegistry

Struct ClientRegistry 

Source
pub struct ClientRegistry { /* private fields */ }
Expand description

Per-worker registry of configured upstream clients, keyed by [grpc.clients.<name>] name. Built once per worker run(); each entry lazily opens its channel on first call. Clients whose descriptor pool fails to build are logged and omitted (a call to them returns UNIMPLEMENTED), rather than crashing the worker.

Implementations§

Source§

impl ClientRegistry

Source

pub fn build(configs: &HashMap<String, ClientConfig>) -> Self

Build the registry from [grpc.clients.*]. Never fails as a whole: a client with no usable descriptors is skipped with a warning.

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

pub async fn call(&self, env: ClientCallEnvelope) -> Value

Execute one grpc.client.call. Returns a JSON value: { "message": <DTO> } on success, or { "__grpc_status", "__grpc_message" } for any gRPC/transport failure (business status passed through; transport → UNAVAILABLE(14); client deadline → DEADLINE_EXCEEDED(4)). Never returns Err for a call outcome — only truly internal encode failures surface as a status too.

Source

pub async fn open_stream(&self, env: ClientStreamEnvelope) -> StreamConn

Open a server-streaming call (phase 88b). Returns a StreamConn whose inbound stream yields one JSON frame per upstream message: { "message": … } for a decoded DTO, or { "__grpc_status", "__grpc_message" } for a decode failure or a non-OK trailing status — the same convention the unary call uses, so the PHP side maps a status frame to GrpcException. Never fails at the handler level: setup errors (unknown client/method, bad request, connect) surface as a single status frame, so PHP’s foreach always sees the outcome.

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<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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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<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