Skip to main content

Config

Struct Config 

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

Configuration for an SDK gRPC client (shared by canton-ledger and canton-admin).

Implementations§

Source§

impl Config

Source

pub fn new(endpoint: impl Into<String>) -> Self

Create a configuration targeting endpoint, with no authentication and no retrying.

Source

pub fn with_token(self, token: impl Into<String>) -> Self

Authenticate with a fixed bearer token.

Source

pub fn with_oidc<T: TokenSource + 'static>(self, provider: T) -> Self

Authenticate with a dynamic token source (e.g. an OIDC provider with client-credentials and auto-refresh).

Source

pub fn with_retry(self, retry: RetryConfig) -> Self

Enable retrying of unary calls on retriable errors, per retry.

Source

pub fn with_tls(self, tls: TlsConfig) -> Self

Use TLS for the gRPC channel (server-side and, if configured, mutual).

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Set the per-request timeout on the gRPC channel (default 30s). Long submitAndWait calls under load may need a higher bound.

Source

pub fn with_max_decoding_message_size(self, bytes: usize) -> Self

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.

Source

pub fn max_decoding_message_size(&self) -> usize

The largest gRPC response this configuration will decode, in bytes.

Source

pub fn endpoint(&self) -> &str

The gRPC endpoint of the target service, e.g. http://localhost:3901.

Source

pub fn auth(&self) -> &Auth

The configured authentication mode.

Source

pub fn retry(&self) -> Option<&RetryConfig>

The configured retry policy, if any.

Source

pub fn connect_channel(&self) -> Result<Channel>

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 or grpcs; 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, or TLS is configured and the endpoint’s scheme is one other than http, https or grpcs.

Source§

impl Config

Source

pub fn from_env() -> Result<Self>

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.

Source

pub fn from_env_for(role: &str) -> Result<Self>

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§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Hand-written so the endpoint’s userinfo is redacted. auth and tls redact themselves; the endpoint was the remaining way a credential reached a log through a Config, and a Config is exactly the thing an application attaches to a tracing span while debugging a connection.

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Config

§

impl !UnwindSafe for Config

§

impl Forget for Config

§

impl Freeze for Config
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const ArcInner<dyn TokenSource> is !null: Freeze, PhantomData<ArcInner<dyn TokenSource>>: Freeze,

§

impl Move for Config

§

impl Send for Config
where RawVecInner: Send, Arc<dyn TokenSource>: Send,

§

impl Sync for Config
where RawVecInner: Sync, Arc<dyn TokenSource>: Sync,

§

impl Unpin for Config
where *const u8 is !null: Unpin, Arc<dyn TokenSource>: Unpin,

§

impl UnsafeUnpin for Config
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<dyn TokenSource> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn TokenSource>>: UnsafeUnpin,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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<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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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