pub struct SetMetricDetail {
pub client_id: String,
pub detail: Option<i32>,
pub ttl_seconds: Option<u32>,
pub clear: Option<bool>,
pub reason: Option<String>,
pub peer_pid: Option<i32>,
pub peer_session_ulid: Option<String>,
}Expand description
Apply, renew, or release a runtime cardinality lease on the metrics drain.
Leasing model: sozu top (and any future TUI client) leases a higher
MetricDetail for the duration of an interactive session. The worker’s
effective detail is max(configured, max(active leases)), where
configured is MetricsConfig.detail from the static configuration.
Multiple clients can lease independently; the worker keeps a client_id-
keyed table and uses the maximum across active entries.
Lifecycle:
- Apply: send
SetMetricDetail{ client_id, detail, ttl_seconds, reason }. The worker stores(client_id) -> (detail, expires_at = now + ttl). If a lease forclient_idalready exists, it is REPLACED (acts as a renewal). The renewer client is expected to re-send everyttl/2. - Expire: leases self-expire server-side at
expires_at. The worker’s janitor (5s polled tick at the top ofnotify) prunes expired leases and recomputes effective. Crash safety: a dead client is forgotten. - Clear: send
SetMetricDetail{ client_id, clear: true }for explicit revocation.client_idmust match the leased entry; mismatched IDs are silently ignored (other clients’ leases are not affected).
§Audit
Every operator-initiated effective-level transition emits an
EventKind::METRIC_DETAIL_CHANGED event on SubscribeEvents with the
previous and new effective levels and the requesting client_id plus
optional reason text. Renewal-no-op (same effective level) is NOT
emitted.
Emitter scope: operator-initiated transitions emit
METRIC_DETAIL_CHANGED via the master-side audit log. Worker-local
transitions — the polled janitor expiring a lease, or a worker-local
clear/apply after a master fan-out — are not yet surfaced; follow-up
tracked separately.
§Backwards compatibility
Workers that pre-date this verb cannot decode SetMetricDetail and return
WorkerResponse::error("unknown request type") which folds into the standard
fan-out error tally (extras.fanout.workers_err); operators see “succeeded
with errors” rather than a dedicated capability-skip list. Production
deployments keep master + workers in sync via the UpgradeMain hot-upgrade
flow, so this mixed-version state is transient. The master itself also
leases (mirroring the symmetric setup_metrics path) so the audit log has a
single canonical row when an operator flips detail across the fleet.
Fields§
§client_id: StringStable identifier for the leasing client (sozu top uses
top:<pid>:<random>). Required so multiple TUIs / scrapers / other
tooling can lease independently.
detail: Option<i32>Target detail for the lease. Required when clear is false/absent.
ttl_seconds: Option<u32>Time-to-live for the lease in seconds. The worker rejects (FAILURE) values larger than 300s to bound the worst-case effect of a stuck renewer. Defaults server-side to 60s when absent (the master treats 0 as “use default” and emits a warning).
clear: Option<bool>When true, releases the lease for client_id instead of applying.
detail and ttl_seconds are ignored when clear is true.
reason: Option<String>Optional human-readable provenance for the audit log
(e.g. "sozu top --detail backend", "prometheus-scraper:sozu-1").
peer_pid: Option<i32>Master-populated peer binding. These fields are NOT set by clients —
the master fills them in bin/src/command/requests.rs::worker_request
from the connecting ClientSession (actor_pid + session_ulid)
before forwarding to workers. The worker stores the binding
alongside the lease and rejects subsequent clear requests whose
binding does not match the apply-time binding. Prevents one same-UID
operator from accidentally (or deliberately) clearing another
operator’s lease by guessing the client_id format. A None value
means “binding not available” — the worker accepts any matching
client_id clear, preserving compat with pre-binding callers and
with platforms whose unix socket peer credentials are unavailable.
peer_session_ulid: Option<String>Implementations§
Source§impl SetMetricDetail
impl SetMetricDetail
Sourcepub fn detail(&self) -> MetricDetail
pub fn detail(&self) -> MetricDetail
Returns the enum value of detail, or the default if the field is unset or set to an invalid enum value.
Sourcepub fn set_detail(&mut self, value: MetricDetail)
pub fn set_detail(&mut self, value: MetricDetail)
Sets detail to the provided enum value.
Sourcepub fn ttl_seconds(&self) -> u32
pub fn ttl_seconds(&self) -> u32
Returns the value of ttl_seconds, or the default value if ttl_seconds is unset.
Sourcepub fn clear(&self) -> bool
pub fn clear(&self) -> bool
Returns the value of clear, or the default value if clear is unset.
Sourcepub fn reason(&self) -> &str
pub fn reason(&self) -> &str
Returns the value of reason, or the default value if reason is unset.
Sourcepub fn peer_pid(&self) -> i32
pub fn peer_pid(&self) -> i32
Returns the value of peer_pid, or the default value if peer_pid is unset.
Sourcepub fn peer_session_ulid(&self) -> &str
pub fn peer_session_ulid(&self) -> &str
Returns the value of peer_session_ulid, or the default value if peer_session_ulid is unset.
Trait Implementations§
Source§impl Clone for SetMetricDetail
impl Clone for SetMetricDetail
Source§fn clone(&self) -> SetMetricDetail
fn clone(&self) -> SetMetricDetail
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SetMetricDetail
impl Debug for SetMetricDetail
Source§impl Default for SetMetricDetail
impl Default for SetMetricDetail
Source§impl<'de> Deserialize<'de> for SetMetricDetail
impl<'de> Deserialize<'de> for SetMetricDetail
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for SetMetricDetail
impl Hash for SetMetricDetail
Source§impl Message for SetMetricDetail
impl Message for SetMetricDetail
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self.Source§impl Ord for SetMetricDetail
impl Ord for SetMetricDetail
Source§fn cmp(&self, other: &SetMetricDetail) -> Ordering
fn cmp(&self, other: &SetMetricDetail) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for SetMetricDetail
impl PartialEq for SetMetricDetail
Source§fn eq(&self, other: &SetMetricDetail) -> bool
fn eq(&self, other: &SetMetricDetail) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for SetMetricDetail
impl PartialOrd for SetMetricDetail
Source§impl Serialize for SetMetricDetail
impl Serialize for SetMetricDetail
impl Eq for SetMetricDetail
impl StructuralPartialEq for SetMetricDetail
Auto Trait Implementations§
impl Freeze for SetMetricDetail
impl RefUnwindSafe for SetMetricDetail
impl Send for SetMetricDetail
impl Sync for SetMetricDetail
impl Unpin for SetMetricDetail
impl UnsafeUnpin for SetMetricDetail
impl UnwindSafe for SetMetricDetail
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.