Mads
Multi-Agent Distributed System
Loading...
Searching...
No Matches
Mads::LinkState Struct Reference

#include <socket_monitor.hpp>

Public Attributes

LinkStatus status = LinkStatus::Unknown
 
LinkEvent last_event = LinkEvent::None
 The most recent event, whatever it was.
 
LinkEvent last_handshake = LinkEvent::None
 
std::string last_event_address
 The peer address libzmq reported with that event ("" if none yet).
 
uint64_t drops = 0
 
uint64_t recoveries = 0
 
std::optional< std::chrono::steady_clock::time_point > changed_at
 
int last_event_value = 0
 
uint64_t accept_failures = 0
 

Detailed Description

Everything SocketMonitor knows about one link, taken atomically so the status, the counters and the event that caused them can never disagree.

Examples
/home/runner/work/MADS/MADS/src/agent.hpp.

Definition at line 62 of file socket_monitor.hpp.

Member Data Documentation

◆ accept_failures

uint64_t Mads::LinkState::accept_failures = 0

Inbound connections this listener has failed to accept. Monotonic, so a caller can report only what is new since it last looked – which matters because a full descriptor table leaves the listening socket permanently readable, and libzmq re-fires the failure as fast as it can poll.

Definition at line 95 of file socket_monitor.hpp.

◆ changed_at

std::optional<std::chrono::steady_clock::time_point> Mads::LinkState::changed_at

When status last changed; empty while it is still Unknown. Callers report "down for 12s" from this.

Definition at line 85 of file socket_monitor.hpp.

◆ drops

uint64_t Mads::LinkState::drops = 0

Up -> Down transitions. Counts transitions, not events, so a broker that stays down through a hundred CONNECT_RETRIED reads as one drop.

Definition at line 79 of file socket_monitor.hpp.

◆ last_event

LinkEvent Mads::LinkState::last_event = LinkEvent::None

The most recent event, whatever it was.

Definition at line 65 of file socket_monitor.hpp.

◆ last_event_address

std::string Mads::LinkState::last_event_address

The peer address libzmq reported with that event ("" if none yet).

Definition at line 76 of file socket_monitor.hpp.

◆ last_event_value

int Mads::LinkState::last_event_value = 0

The integer libzmq attached to the most recent event. Its meaning is per-event and it is 0 for the ones that carry nothing useful; the case this exists for is AcceptFailed, where it is the errno accept(2) failed with.

Definition at line 90 of file socket_monitor.hpp.

◆ last_handshake

LinkEvent Mads::LinkState::last_handshake = LinkEvent::None

How the most recent ZMTP handshake ended: HandshakeSucceeded, one of the three HandshakeFailed* events, or None if none has completed yet.

This – not last_event – is what carries the reason a link is down. libzmq follows a rejected handshake with ZMQ_EVENT_DISCONNECTED and then a stream of ZMQ_EVENT_CONNECT_RETRIED, so by the time anything asks, last_event has almost always moved on and "the broker rejected our key" would have been lost. Only the next handshake replaces it.

Definition at line 74 of file socket_monitor.hpp.

◆ recoveries

uint64_t Mads::LinkState::recoveries = 0

Down -> Up transitions. A first connection is not a recovery, so this stays 0 until a drop has actually been repaired.

Definition at line 82 of file socket_monitor.hpp.

◆ status

LinkStatus Mads::LinkState::status = LinkStatus::Unknown

Definition at line 63 of file socket_monitor.hpp.


The documentation for this struct was generated from the following file: