Struct NodeConfig
#[non_exhaustive]pub struct NodeConfig {
pub policy: Option<Arc<dyn DynPolicy<PublicKey>>>,
pub decide_timeout: Duration,
pub table: Option<Producer>,
pub layout: Option<Arc<dyn Layout<PublicKey>>>,
}Expand description
The configuration of a Node.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.policy: Option<Arc<dyn DynPolicy<PublicKey>>>Decides who may hold a session with the node, and with which rights.
The node asks it when it accepts a session, after the peer’s MoQ
SETUP, and before it dials a peer. A rejection closes an accepted
session with the rejection’s code, and fails a dial with
[Error::Rejected]. Each session is decided on its own, with the
request and token it opened with, so a peer’s second session asks
the policy again.
The node asks again about a live session when its authorization
expires and on Node::reauthorize, with
Event::Reauthorize. An expired
session may do nothing until the new decision applies.
None is [policy::Open] with Grant::subscribe_only: every peer
may subscribe to anything and publish nothing.
decide_timeout: DurationHow long the node waits for each decision of its policy.
A decision that takes longer is a rejection with
moq_net::Error::Timeout. The default is [DECIDE_TIMEOUT]. Raise it
when a person answers, as with a [policy::Queue].
When the node asks again about a live session, a timeout or a full
queue (moq_net::Error::TooManyRequests) is no rejection: the
session keeps its authorization, and the node asks again later.
table: Option<Producer>A route table to use instead of a new one, such as a media relay’s cluster origin.
The caller runs its driver. The node serves the table’s local view,
which hides routes from handles tagged Link::Peer
or Link::Upstream. None creates a table
under the hop derived from the endpoint id.
layout: Option<Arc<dyn Layout<PublicKey>>>The path layout that names the peer owning a path, for Node::claim_path.
None uses the generic rule: a path is a peer’s when exactly one of
its segments is the peer’s endpoint id.
Implementations§
§impl NodeConfig
impl NodeConfig
pub fn with_policy(self, policy: impl Policy<PublicKey>) -> NodeConfig
pub fn with_policy(self, policy: impl Policy<PublicKey>) -> NodeConfig
Returns this configuration with policy deciding who may hold a session.
pub fn with_decide_timeout(self, timeout: Duration) -> NodeConfig
pub fn with_decide_timeout(self, timeout: Duration) -> NodeConfig
Returns this configuration with timeout bounding each decision of the policy.
See decide_timeout.
pub fn with_table(self, table: Producer) -> NodeConfig
pub fn with_table(self, table: Producer) -> NodeConfig
Returns this configuration with table as the node’s route table.
See table.
pub fn with_layout(self, layout: impl Layout<PublicKey>) -> NodeConfig
pub fn with_layout(self, layout: impl Layout<PublicKey>) -> NodeConfig
Returns this configuration with layout naming the peer that owns a path.
See layout.
Trait Implementations§
§impl Clone for NodeConfig
impl Clone for NodeConfig
§fn clone(&self) -> NodeConfig
fn clone(&self) -> NodeConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more