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: DurationDeadline for election, endpoint publication, or a higher-ranked takeover.
handoff_grace: DurationHow 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
impl ServiceConfig
pub fn new( service: &str, role: &str, rank: u8, version: &str, allowlist: Allowlist, ) -> Self
Sourcepub fn private_secret(self, secret: PrivateSecret) -> Self
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.
Sourcepub fn with_methods(self, table: &MethodTable) -> Self
pub fn with_methods(self, table: &MethodTable) -> Self
Take the allowlist from a MethodTable, the single source
of method policy.