Struct FinamApiConfig
pub struct FinamApiConfig {
pub endpoint: ApiEndpoint,
pub secret: String,
pub source_app_id: String,
pub tokens: Option<Arc<TokenManager>>,
pub bearer: bool,
pub request_timeout: Duration,
}Expand description
Connection and credentials, shared in shape by both connector roles.
Holds the API secret, so it is not Display, and its Debug output hides the secret.
§Examples
Two accounts of one secret share one JWT. The token manager is started once and put into both configs. Here the broker is the in-process imitation:
use brokapi_finam::{FinamApiConfig, UserDataConfig};
// `cfg` is your config: secret plus endpoint.
let tokens = cfg.shared_tokens().await?;
let shared = cfg.with_tokens(tokens);
let first = UserDataConfig::new(shared.clone(), "ACC1", "finam-ud-ACC1");
let second = UserDataConfig::new(shared, "ACC2", "finam-ud-ACC2");
assert_ne!(first.account_id, second.account_id);Fields§
§endpoint: ApiEndpointAddress and timeouts of the channel. Default: the production endpoint.
secret: StringAPI secret. Ignored when tokens is set.
source_app_id: StringOptional application id sent with Auth.
tokens: Option<Arc<TokenManager>>Already running token manager to reuse (several accounts / roles on one secret).
bearer: boolSend authorization: Bearer <jwt> instead of the bare JWT (official SDKs send it bare).
request_timeout: DurationDeadline of a unary call. Default 10 seconds.
When it passes with no answer, a read fails with a transport error, and a command (place, cancel)
ends as Error::Unknown, because the broker may still have applied it.
Implementations§
§impl FinamApiConfig
impl FinamApiConfig
pub fn new(secret: impl Into<String>) -> FinamApiConfig
pub fn new(secret: impl Into<String>) -> FinamApiConfig
Config for secret with the production endpoint and default settings.
Nothing is checked or sent here. An empty or wrong secret shows up when a connector starts
(Error::Config for an empty one, Error::Rejected for one the broker refuses).
pub fn with_tokens(self, tokens: Arc<TokenManager>) -> FinamApiConfig
pub fn with_tokens(self, tokens: Arc<TokenManager>) -> FinamApiConfig
Reuse a token manager (see FinamApiConfig::shared_tokens).
When set, the connector does not log in itself and secret is not used.
pub fn with_endpoint(self, url: impl Into<String>) -> FinamApiConfig
pub fn with_endpoint(self, url: impl Into<String>) -> FinamApiConfig
Points the config at another gRPC server, with the default timeouts.
url is https://host:port (TLS) or http://host:port (plain, for a proxy or the test
imitation). It replaces the whole [ApiEndpoint], so set custom timeouts on
FinamApiConfig::endpoint after this call.
§Examples
use brokapi_finam::FinamApiConfig;
let cfg = FinamApiConfig::new("secret").with_endpoint("http://127.0.0.1:50051");
assert_eq!(cfg.endpoint.url, "http://127.0.0.1:50051");Authenticates once and returns the manager to put into several connector configs, so that all accounts of one secret share a single JWT.
The manager renews the token in the background until the last Arc is dropped.
§Errors
- [
Error::Config]: the secret is empty or the endpoint URL is invalid. - [
Error::Config] also: the broker refused the secret (a wrong token is a configuration problem at every broker). - [
Error::RateLimited]: the broker answeredRESOURCE_EXHAUSTED. - [
Error::Transport]: the broker could not be reached or the call timed out.
Trait Implementations§
§impl Clone for FinamApiConfig
impl Clone for FinamApiConfig
§fn clone(&self) -> FinamApiConfig
fn clone(&self) -> FinamApiConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for FinamApiConfig
impl !UnwindSafe for FinamApiConfig
impl Freeze for FinamApiConfig
impl Send for FinamApiConfig
impl Sync for FinamApiConfig
impl Unpin for FinamApiConfig
impl UnsafeUnpin for FinamApiConfig
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> 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].