Skip to content

beryl/snapshot

A point-in-time snapshot of local runtime state.

Snapshots are point-in-time values as observed by the runtime process servicing the request. Counts may lag in-flight connect and disconnect notifications that have not yet reached that process, so they are eventually consistent rather than exact at the instant of the call. They are intended for operational polling, not as an event stream. Poll no more frequently than roughly once per second so observation does not add meaningful runtime load.

pub type Snapshot

A point-in-time snapshot of local runtime state.

pub type SnapshotError {
RuntimeUnavailable
RequestTimedOut
AdmissionRejected(overload.AdmissionError)
}

Errors from a runtime snapshot request.

RuntimeUnavailable

The local socket runtime is not running.

RequestTimedOut

The runtime did not process the request before the timeout.

AdmissionRejected(overload.AdmissionError)

The request did not enter the runtime queue.

pub fn active_topics(Snapshot) -> Int

Return the number of topics with at least one local joined socket.

pub fn connected_sockets(Snapshot) -> Int

Return the number of sockets connected to the local runtime.

pub fn get(beryl.Sockets) -> Result(Snapshot, SnapshotError)

Request a snapshot from the local runtime.

The request waits for about one second at most. During a runtime restart, this function returns RuntimeUnavailable or RequestTimedOut. An full runtime queue returns AdmissionRejected. Neither condition panics. This API reports only the node represented by sockets; aggregate multi-node statistics outside beryl.

Poll no more frequently than roughly once per second.

pub fn joined_socket_topic_pairs(Snapshot) -> Int

Return the number of joined socket/topic pairs.

One socket joined to two topics contributes two pairs.

pub fn queue(beryl.Sockets) -> Result(overload.Occupancy, overload.AdmissionError)

Read local router admission accounting without waiting for a router turn.