Skip to main content

ServiceConfig

Struct ServiceConfig 

Source
pub struct ServiceConfig {
    pub service: String,
    pub role: String,
    pub rank: u8,
    pub version: String,
    pub allowlist: Allowlist,
    pub frame_limit: usize,
    pub takeover_timeout: Duration,
    pub handoff_grace: Duration,
    pub on_event: Option<Arc<dyn Fn(&ServiceEvent) + Send + Sync>>,
    pub known_roles: BTreeMap<String, u8>,
    pub endpoint: Option<String>,
    pub private_secret: Option<PrivateSecret>,
}

Fields§

§service: String§role: String§rank: u8§version: String§allowlist: Allowlist§frame_limit: usize§takeover_timeout: Duration

Deadline for election, endpoint publication, or a higher-ranked takeover.

§handoff_grace: Duration

How long the incumbent lets in-flight requests reach a boundary.

§on_event: Option<Arc<dyn Fn(&ServiceEvent) + Send + Sync>>§known_roles: BTreeMap<String, u8>

Role -> rank for peers that publish a role but no rank (HeardRight’s service.json and takeover.json). A peer whose rank cannot be resolved is never taken over from and never obliges a handoff.

§endpoint: Option<String>

Explicit endpoint (a compatibility convention such as HeardRight’s <service_dir>/speech.sock); default is crate::endpoint_for.

§private_secret: Option<PrivateSecret>

A per-run secret every frame must carry; see ServiceConfig::private_secret.

Implementations§

Source§

impl ServiceConfig

Source

pub fn new( service: &str, role: &str, rank: u8, version: &str, allowlist: Allowlist, ) -> Self

Source

pub fn private_secret(self, secret: PrivateSecret) -> Self

Require secret on the hello frame and on every request frame (a top-level secret field, checked in constant time before any handler runs). A frame without it, or with a wrong one, is answered unauthenticated and the connection is closed. This is the host half of the private per-run child service pattern; see the private module.

Source

pub fn with_methods(self, table: &MethodTable) -> Self

Take the allowlist from a MethodTable, the single source of method policy.

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.