pub struct Config { /* private fields */ }Expand description
Configuration for an SDK gRPC client (shared by canton-ledger and
canton-admin).
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(endpoint: impl Into<String>) -> Config
pub fn new(endpoint: impl Into<String>) -> Config
Create a configuration targeting endpoint, with no authentication and
no retrying.
Sourcepub fn with_token(self, token: impl Into<String>) -> Config
pub fn with_token(self, token: impl Into<String>) -> Config
Authenticate with a fixed bearer token.
Sourcepub fn with_oidc<T>(self, provider: T) -> Configwhere
T: TokenSource + 'static,
pub fn with_oidc<T>(self, provider: T) -> Configwhere
T: TokenSource + 'static,
Authenticate with a dynamic token source (e.g. an OIDC provider with client-credentials and auto-refresh).
Sourcepub fn with_retry(self, retry: RetryConfig) -> Config
pub fn with_retry(self, retry: RetryConfig) -> Config
Enable retrying of unary calls on retriable errors, per retry.
Sourcepub fn with_tls(self, tls: TlsConfig) -> Config
pub fn with_tls(self, tls: TlsConfig) -> Config
Use TLS for the gRPC channel (server-side and, if configured, mutual).
Sourcepub fn with_timeout(self, timeout: Duration) -> Config
pub fn with_timeout(self, timeout: Duration) -> Config
Set the per-request timeout on the gRPC channel (default 30s). Long
submitAndWait calls under load may need a higher bound.
Sourcepub fn with_max_decoding_message_size(self, bytes: usize) -> Config
pub fn with_max_decoding_message_size(self, bytes: usize) -> Config
The largest gRPC response to decode, in bytes
(default DEFAULT_MAX_DECODING_MESSAGE_SIZE, 128 MiB).
Raise it for a participant that returns very large ACS pages or transactions; lower it to bound the memory a single response can claim.
Sourcepub fn max_decoding_message_size(&self) -> usize
pub fn max_decoding_message_size(&self) -> usize
The largest gRPC response this configuration will decode, in bytes.
Sourcepub fn endpoint(&self) -> &str
pub fn endpoint(&self) -> &str
The gRPC endpoint of the target service, e.g. http://localhost:3901.
Sourcepub fn retry(&self) -> Option<&RetryConfig>
pub fn retry(&self) -> Option<&RetryConfig>
The configured retry policy, if any.
Sourcepub fn connect_channel(&self) -> Result<Channel, Error>
pub fn connect_channel(&self) -> Result<Channel, Error>
Build a lazily-connected gRPC Channel for this configuration.
Returns immediately; the TCP/TLS handshake happens on the first RPC. TLS
is applied when Config::with_tls was set or the endpoint is https;
a with_tls endpoint given as http:// is normalised to https:// so
TLS is never silently downgraded (see the private resolve_endpoint).
§Errors
Returns Error::InvalidRequest if the endpoint URI or the TLS
configuration is invalid.
Source§impl Config
impl Config
Sourcepub fn from_env() -> Result<Config, Error>
pub fn from_env() -> Result<Config, Error>
Build a configuration from a LocalNet exported into the environment — the app-provider participant, with its token.
See the module documentation for the variables read and the two things worth knowing about the URLs.
§Errors
Returns Error::InvalidRequest when no endpoint variable is set,
naming the variable and the command that exports it. A missing token is
not an error: an unauthenticated LocalNet is a normal thing to point
this at.
Sourcepub fn from_env_for(role: &str) -> Result<Config, Error>
pub fn from_env_for(role: &str) -> Result<Config, Error>
The same, for a participant other than the default: "app-user",
"sv", or any role the exporter knows.
§Errors
As Config::from_env, naming that role’s variable.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Config
impl !UnwindSafe for Config
impl Freeze for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
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,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request