Skip to main content

GrpcConfig

Struct GrpcConfig 

Source
#[non_exhaustive]
pub struct GrpcConfig {
Show 20 fields pub enabled: bool, pub listener: Listener, pub bind: String, pub health: bool, pub reflection: Toggle, pub metrics: bool, pub max_metric_series: usize, pub shutdown_grace_ms: u64, pub timeout_ms: u64, pub max_connections: usize, pub concurrency_limit_per_connection: usize, pub max_concurrent_streams: u32, pub http2_max_local_error_reset_streams: usize, pub tcp_nodelay: bool, pub tcp_keepalive_ms: u64, pub http2_keepalive_interval_ms: u64, pub http2_keepalive_timeout_ms: u64, pub max_connection_age_ms: u64, pub tls: TlsConfig, pub clients: BTreeMap<String, ClientConfig>,
}
Expand description

Settings for one gRPC server.

The defaults limit resource use. For a setting that says “0: off”, the value 0 removes that limit or feature.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§enabled: bool

Start the server. Default: true.

§listener: Listener

dedicated: a listener of its own, on bind. shared: Autumn’s HTTP port (needs the multiplex feature). Default: dedicated.

§bind: String

Listen address, IP:port. Port 0 picks a free port. Empty: the profile decides. dev and test use 127.0.0.1:50051. Other profiles use 0.0.0.0:50051. Default: empty.

§health: bool

Serve grpc.health.v1.Health. Default: true.

§reflection: Toggle

Serve server reflection. auto is on in dev and test only.

§metrics: bool

Record grpc_server_* metrics. Default: true.

§max_metric_series: usize

Maximum label sets per metric. The plugin counts new label sets over this limit as other. Default: 1000.

§shutdown_grace_ms: u64

Time for in-flight calls to finish at shutdown. Must be more than 0. Default: 10000.

§timeout_ms: u64

Per-call timeout for unary calls. 0: off. Default: 0.

§max_connections: usize

Open connections. The listener waits when it reaches the limit. 0: off. Default: 1000.

§concurrency_limit_per_connection: usize

Concurrent calls per connection. A streaming call counts until its response starts. 0: off. Default: 0.

§max_concurrent_streams: u32

HTTP/2 SETTINGS_MAX_CONCURRENT_STREAMS. Must be more than 0. Default: 200.

§http2_max_local_error_reset_streams: usize

Server-side stream resets per connection before the server closes it (a protection against reset floods). Must be more than 0. Default: 1024.

§tcp_nodelay: bool

Set TCP_NODELAY. Default: true.

§tcp_keepalive_ms: u64

TCP keepalive idle time. 0: off. Default: 0.

§http2_keepalive_interval_ms: u64

HTTP/2 PING interval. 0: off. Default: 60000.

§http2_keepalive_timeout_ms: u64

Time to wait for a PING reply. 0: tonic default (20 s). Default: 20000.

§max_connection_age_ms: u64

Close connections after this age. 0: off. Default: 0.

§tls: TlsConfig

TLS settings. Empty paths mean plain text.

§clients: BTreeMap<String, ClientConfig>

Downstream services to call, by name ([grpc.clients.<name>]). Needs the client feature. The server does not use them.

Implementations§

Source§

impl GrpcConfig

Source

pub fn bind_addr(&self, development: bool) -> Result<SocketAddr, ConfigError>

The listen address. An empty bind gives 127.0.0.1:50051 in development and 0.0.0.0:50051 in other profiles.

§Errors

Returns ConfigError when bind is not IP:port.

Source

pub const fn timeout(&self) -> Option<Duration>

Per-call timeout.

Source

pub const fn shutdown_grace(&self) -> Duration

Shutdown grace period.

Source

pub const fn tcp_keepalive(&self) -> Option<Duration>

TCP keepalive idle time.

Source

pub const fn http2_keepalive_interval(&self) -> Option<Duration>

HTTP/2 PING interval.

Source

pub const fn http2_keepalive_timeout(&self) -> Option<Duration>

HTTP/2 PING ack timeout.

Source

pub const fn max_connection_age(&self) -> Option<Duration>

Maximum connection age.

Source

pub fn from_toml_str(text: &str, section: &str) -> Result<Self, ConfigError>

Parse [section] from a whole autumn.toml text. No profiles and no environment.

§Errors

Returns ConfigError for bad TOML, unknown keys, wrong types or values that validate rejects.

Source

pub fn resolve(section: &str) -> Result<Resolved, ConfigError>

Resolve [section] from the app’s files and the process environment.

§Errors

Returns ConfigError when a file cannot be read or parsed, or when the merged section is not valid.

Source

pub fn resolve_with_env( section: &str, env: &dyn Env, ) -> Result<Resolved, ConfigError>

Like resolve, but reads only env.

§Errors

See resolve.

Source

pub fn resolve_with_env_and_clients( section: &str, env: &dyn Env, clients: &[&str], ) -> Result<Resolved, ConfigError>

Like resolve_with_env. Env overrides apply to each client in the files and to each name in clients (the plugin passes the names from client).

§Errors

See resolve.

Source

pub fn validate(&self) -> Result<(), ConfigError>

Reject values that fail at runtime.

§Errors

Returns ConfigError that names the bad key.

Trait Implementations§

Source§

impl Clone for GrpcConfig

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 GrpcConfig

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for GrpcConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for GrpcConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for GrpcConfig

Source§

impl PartialEq for GrpcConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for GrpcConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for GrpcConfig

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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> 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> JsonSink for T
where T: Serialize + ?Sized,

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

Source§

type Output = T

Should always be Self
Source§

impl<T> Scoped for T
where T: Send + Sync + 'static,

Source§

fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>

Open a deferred ScopeQuery for this type. Resolves the registered scope at .load() time, not here.
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