pub struct Rpc {
pub api: FinamApi,
pub limiter: Arc<BrokerLimiter>,
pub timeout: Duration,
}Expand description
Everything a connector needs to make calls: clients, quota, deadline.
Cheap to clone. FinamRaw wraps it for application code.
Fields§
§api: FinamApiService clients with the shared token manager.
limiter: Arc<BrokerLimiter>Rate limiter shared by all connectors of one Finam user.
timeout: DurationDeadline of one unary call.
Implementations§
Source§impl Rpc
impl Rpc
Sourcepub fn acquire(&self, method: &str) -> Result<(), Error>
pub fn acquire(&self, method: &str) -> Result<(), Error>
Takes the quota for the proto method method.
§Errors
[brokapi_core::Error::RateLimited] when a bucket on the route of method is empty. Nothing
is consumed in that case and the request must not be sent.
Sourcepub async fn read<T, F, Fut>(&self, method: &str, f: F) -> Result<T, Error>
pub async fn read<T, F, Fut>(&self, method: &str, f: F) -> Result<T, Error>
A read-only call: quota, deadline, one re-auth retry, public error mapping.
§Errors
[brokapi_core::Error::RateLimited] (local quota or RESOURCE_EXHAUSTED),
[brokapi_core::Error::Rejected] (the broker said no), [brokapi_core::Error::Transport]
(connection failure or timeout). See crate::error::map_protocol_err.
Sourcepub async fn send_command<T, F, Fut>(&self, f: F) -> Result<T, FinamError>
pub async fn send_command<T, F, Fut>(&self, f: F) -> Result<T, FinamError>
A trading command: quota, deadline, NO retry. The raw protocol error is returned so the caller can tell “definitely rejected” from “unknown outcome”.
Quota is taken by the caller beforehand (acquire) so that a refusal happens before the
command is registered as in flight.
§Errors
The raw [FinamError]. Map it with crate::error::map_command_err.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Rpc
impl !UnwindSafe for Rpc
impl Freeze for Rpc
impl Send for Rpc
impl Sync for Rpc
impl Unpin for Rpc
impl UnsafeUnpin for Rpc
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].