seqeron 0.18.0
Loading...
Searching...
No Matches
org::limitless::seqeron::protocol::SnapshotHeader Struct Reference

The header a façade writes ahead of the application's body: what it derives from frames before the round's cut. More...

#include <org/limitless/seqeron/protocol/Snapshot.hpp>

Public Member Functions

bool operator== (const SnapshotHeader &) const =default
 
std::size_t encodedLength () const
 
std::size_t encode (std::uint8_t *out) const
 Writes the header.
 

Static Public Member Functions

static std::int32_t version (const std::uint8_t *in, const std::size_t length)
 Reads the headerVersion a snapshot starts with.
 
static std::optional< SnapshotHeader > decode (const std::uint8_t *in, const std::size_t length)
 Reads a header written by encode.
 

Public Attributes

std::int64_t leadershipTermId
 
std::int32_t leaderMemberId
 
std::vector< SnapshotGroup > groups
 the active groups before the cut, in ascending groupId
 
std::optional< SnapshotGatewayState > gateway
 empty for an application's header
 

Static Public Attributes

static constexpr std::uint16_t VERSION = 2
 
static constexpr std::int32_t NO_GATEWAY = -1
 
static constexpr std::size_t FIXED_LENGTH = 19
 
static constexpr std::size_t NAME_LENGTH = 32
 
static constexpr std::size_t GROUP_LENGTH = 1 + NAME_LENGTH
 
static constexpr std::size_t GATEWAY_FIXED_LENGTH = 14
 
static constexpr std::size_t GATEWAY_ROW_LENGTH = 5 + NAME_LENGTH
 

Detailed Description

The header a façade writes ahead of the application's body: what it derives from frames before the round's cut.

Little-endian and packed; the layout is in the Java twin, SnapshotHeader. Every instance of a source writes the same header (A-6).

Member Function Documentation

◆ decode()

static std::optional< SnapshotHeader > org::limitless::seqeron::protocol::SnapshotHeader::decode ( const std::uint8_t *  in,
const std::size_t  length 
)
inlinestatic

Reads a header written by encode.

Parameters
inthe snapshot's first byte
lengththe snapshot's bytes
Returns
the header, or empty if it is not a VERSION header or does not fit length

◆ encode()

std::size_t org::limitless::seqeron::protocol::SnapshotHeader::encode ( std::uint8_t *  out) const
inline

Writes the header.

Parameters
outwhere to write; at least encodedLength() bytes
Returns
the bytes written

◆ encodedLength()

std::size_t org::limitless::seqeron::protocol::SnapshotHeader::encodedLength ( ) const
inline

◆ operator==()

bool org::limitless::seqeron::protocol::SnapshotHeader::operator== ( const SnapshotHeader &  ) const
default

◆ version()

static std::int32_t org::limitless::seqeron::protocol::SnapshotHeader::version ( const std::uint8_t *  in,
const std::size_t  length 
)
inlinestatic

Reads the headerVersion a snapshot starts with.

Parameters
inthe snapshot's first byte
lengththe snapshot's bytes
Returns
the version, or -1 if length cannot hold one

Member Data Documentation

◆ FIXED_LENGTH

constexpr std::size_t org::limitless::seqeron::protocol::SnapshotHeader::FIXED_LENGTH = 19
staticconstexpr

◆ gateway

std::optional<SnapshotGatewayState> org::limitless::seqeron::protocol::SnapshotHeader::gateway

empty for an application's header

◆ GATEWAY_FIXED_LENGTH

constexpr std::size_t org::limitless::seqeron::protocol::SnapshotHeader::GATEWAY_FIXED_LENGTH = 14
staticconstexpr

◆ GATEWAY_ROW_LENGTH

constexpr std::size_t org::limitless::seqeron::protocol::SnapshotHeader::GATEWAY_ROW_LENGTH = 5 + NAME_LENGTH
staticconstexpr

◆ GROUP_LENGTH

constexpr std::size_t org::limitless::seqeron::protocol::SnapshotHeader::GROUP_LENGTH = 1 + NAME_LENGTH
staticconstexpr

◆ groups

std::vector<SnapshotGroup> org::limitless::seqeron::protocol::SnapshotHeader::groups

the active groups before the cut, in ascending groupId

◆ leaderMemberId

std::int32_t org::limitless::seqeron::protocol::SnapshotHeader::leaderMemberId

◆ leadershipTermId

std::int64_t org::limitless::seqeron::protocol::SnapshotHeader::leadershipTermId

◆ NAME_LENGTH

constexpr std::size_t org::limitless::seqeron::protocol::SnapshotHeader::NAME_LENGTH = 32
staticconstexpr

◆ NO_GATEWAY

constexpr std::int32_t org::limitless::seqeron::protocol::SnapshotHeader::NO_GATEWAY = -1
staticconstexpr

◆ VERSION

constexpr std::uint16_t org::limitless::seqeron::protocol::SnapshotHeader::VERSION = 2
staticconstexpr

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