pub struct FleetFeed {
epoch: String,
hostname: String,
channel: String,
version: String,
os: String,
install_id: Option<String>,
tx: Sender<FleetSnapshot>,
viewer_port: Arc<AtomicU16>,
streams: Arc<AtomicUsize>,
heartbeat: Duration,
}Fields§
§epoch: String16 lowercase hex chars, new on every srv launch: a client that sees a
different epoch knows the instance restarted and takes the snapshot
as-is rather than comparing revs.
hostname: String§channel: String§version: String§os: String§install_id: Option<String>This install’s WAN instance id; None without a WAN identity store.
tx: Sender<FleetSnapshot>§viewer_port: Arc<AtomicU16>Where the viewer port is read from on each look; 0 = not up.
streams: Arc<AtomicUsize>§heartbeat: DurationImplementations§
Source§impl FleetFeed
impl FleetFeed
pub fn new(hostname: String, channel: String, version: String) -> Self
Sourcepub fn with_viewer_port(self, port: Arc<AtomicU16>) -> Self
pub fn with_viewer_port(self, port: Arc<AtomicU16>) -> Self
Read the viewer port from port (ViewerService::advertised_port_handle).
Sourcepub fn with_install_id(self, install_id: Option<String>) -> Self
pub fn with_install_id(self, install_id: Option<String>) -> Self
Set the install id the body reports (fleet_source::install_id).
pub fn hostname(&self) -> &str
pub fn channel(&self) -> &str
pub fn version(&self) -> &str
pub fn os(&self) -> &str
pub fn snapshot(&self) -> FleetSnapshot
Sourcepub fn subscribe(&self) -> Receiver<FleetSnapshot>
pub fn subscribe(&self) -> Receiver<FleetSnapshot>
A receiver that wakes on every change, for the presence publisher.
Sourcepub fn event_id(&self, snapshot: &FleetSnapshot) -> String
pub fn event_id(&self, snapshot: &FleetSnapshot) -> String
<epoch>:<rev>: the SSE id, and (quoted) the snapshot’s ETag.
Sourcepub fn body_json(&self, snapshot: &FleetSnapshot) -> String
pub fn body_json(&self, snapshot: &FleetSnapshot) -> String
The /agentmux/fleet body, on one line, with now_ms read as it is
served, so a peer can tell how long a state has held without trusting
its own clock against this one. now_ms is not part of the snapshot:
it never bumps rev or changes the ETag.
fn body_json_at(&self, snapshot: &FleetSnapshot, now_ms: u64) -> String
Sourcepub fn observe_fleet(&self, observation: FleetObservation) -> bool
pub fn observe_fleet(&self, observation: FleetObservation) -> bool
Record the current fleet; bumps rev and wakes every stream only if
it differs from the last one (names, kinds, channel count, any
agent’s state or line, or the viewer port). Returns whether it did.
Sourcepub fn spawn_change_detection<F>(
self: Arc<Self>,
observe: F,
token: CancellationToken,
)
pub fn spawn_change_detection<F>( self: Arc<Self>, observe: F, token: CancellationToken, )
Start the change-detection task: observe is read now, then every
CHANGE_POLL_INTERVAL on a blocking thread (it reads the store and
the shared registry) until token is cancelled (srv shutdown), the
same stop signal the WAL checkpoint loop watches.
Sourcepub fn open_stream(
self: &Arc<Self>,
last_event_id: Option<&str>,
) -> Option<impl Stream<Item = Result<Bytes, Infallible>> + Send + 'static>
pub fn open_stream( self: &Arc<Self>, last_event_id: Option<&str>, ) -> Option<impl Stream<Item = Result<Bytes, Infallible>> + Send + 'static>
Open one event stream, or None when MAX_STREAMS are already open.
The slot is held by a guard moved into the stream, so it is released whenever the stream is dropped: when hyper drops the response body after the client goes away (noticed at the latest on the next heartbeat write), or if the response is never sent at all.
With last_event_id equal to the current <epoch>:<rev> the client is
already up to date and gets no initial event, only later ones.
Sourcefn event_bytes(&self, snapshot: &FleetSnapshot) -> Bytes
fn event_bytes(&self, snapshot: &FleetSnapshot) -> Bytes
One fleet event. body_json is serde output, so it holds no raw
newline that could break the data: line.
Auto Trait Implementations§
impl !RefUnwindSafe for FleetFeed
impl !UnwindSafe for FleetFeed
impl Freeze for FleetFeed
impl Send for FleetFeed
impl Sync for FleetFeed
impl Unpin for FleetFeed
impl UnsafeUnpin for FleetFeed
Blanket Implementations§
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more