seqeron 0.18.0
Loading...
Searching...
No Matches
org::limitless::seqeron::hosted::Gateway< Listener > Class Template Reference

The client stub of a hosted Gateway (doc/seqeron-protocol-spec.md §17): the surface of app::Gateway, with the façade itself, the pair and the election running in a host process that this talks to over schema 218. More...

#include <org/limitless/seqeron/hosted/Gateway.hpp>

Inheritance diagram for org::limitless::seqeron::hosted::Gateway< Listener >:

Classes

struct  Config
 

Public Member Functions

 Gateway (Config config, Listener &listener)
 
bool canAccept () const noexcept
 Whether a connection may be taken right now: the host's last Gate, or this stub's own Activated(true).
 
bool isServing () const noexcept
 Whether the edge is open: onActivated returned true and no Gate or Role has closed it since.
 
std::int32_t sourceId () const noexcept
 
std::int32_t openConnection (const char *connectionData, const std::size_t length)
 Takes one connection into the cluster's view of this gateway, under the next id from the last Role (H-4).
 
std::int32_t openConnection ()
 Takes one connection whose only identity is its id; see openConnection(const char*, std::size_t).
 
void closeConnection (const std::int32_t connectionId)
 That connection has gone.
 
void gateClosed ()
 The edge closed without being asked to: the host opens it again through onActivated, if this instance is still the one designated.
 
protocol::Publish publish (const std::int32_t connectionId, const std::uint16_t payloadId, const std::uint8_t *payload, const std::uint16_t payloadLength)
 Offers one payload on a connection to this gateway's own group (H-4).
 
protocol::Publish publish (const std::int32_t connectionId, const std::uint16_t groupMask, const std::uint16_t payloadId, const std::uint8_t *payload, const std::uint16_t payloadLength)
 The same to the groups groupMask names as well as its own.
 

Static Public Attributes

static constexpr std::int32_t NO_CONNECTION = -1
 

Detailed Description

template<typename Listener>
class org::limitless::seqeron::hosted::Gateway< Listener >

The client stub of a hosted Gateway (doc/seqeron-protocol-spec.md §17): the surface of app::Gateway, with the façade itself, the pair and the election running in a host process that this talks to over schema 218.

Its listener is the direct Gateway's, and onActivated returns what the host waits for (§17.5).

What differs: connection ids are allocated here, from the host's last Role (H-4); a Published command can be lost at a gate edge (H-3, H-4), and one on a connection whose ConnectionOpened is not yet placed is Published, not Declined; the queries mirror the host's last Gate (H-16). The host waits in onActivated for the answer and drops a stub whose heartbeat is silent for its clientTimeoutMs, so a listener that dials for longer calls keepAlive() while it does (H-14).

Single-threaded: every method belongs to the caller's one duty-cycle thread.

Constructor & Destructor Documentation

◆ Gateway()

template<typename Listener >
org::limitless::seqeron::hosted::Gateway< Listener >::Gateway ( Config  config,
Listener &  listener 
)
inline

Member Function Documentation

◆ canAccept()

template<typename Listener >
bool org::limitless::seqeron::hosted::Gateway< Listener >::canAccept ( ) const
inlinenoexcept

Whether a connection may be taken right now: the host's last Gate, or this stub's own Activated(true).

◆ closeConnection()

template<typename Listener >
void org::limitless::seqeron::hosted::Gateway< Listener >::closeConnection ( const std::int32_t  connectionId)
inline

That connection has gone.

Returns nothing: the offer is retried within the call, as it cannot be declined (H-5).

Parameters
connectionIdthe id openConnection returned

◆ gateClosed()

template<typename Listener >
void org::limitless::seqeron::hosted::Gateway< Listener >::gateClosed ( )
inline

The edge closed without being asked to: the host opens it again through onActivated, if this instance is still the one designated.

Retried within the call.

◆ isServing()

template<typename Listener >
bool org::limitless::seqeron::hosted::Gateway< Listener >::isServing ( ) const
inlinenoexcept

Whether the edge is open: onActivated returned true and no Gate or Role has closed it since.

◆ openConnection() [1/2]

template<typename Listener >
std::int32_t org::limitless::seqeron::hosted::Gateway< Listener >::openConnection ( )
inline

Takes one connection whose only identity is its id; see openConnection(const char*, std::size_t).

◆ openConnection() [2/2]

template<typename Listener >
std::int32_t org::limitless::seqeron::hosted::Gateway< Listener >::openConnection ( const char *  connectionData,
const std::size_t  length 
)
inline

Takes one connection into the cluster's view of this gateway, under the next id from the last Role (H-4).

Parameters
connectionDatawhat onConnectionOpened will carry, or null
lengthits length
Returns
the connection's id, or NO_CONNECTION while not serving, with the window full, or with stream 304 back-pressured: retry it while canAccept()

◆ publish() [1/2]

template<typename Listener >
protocol::Publish org::limitless::seqeron::hosted::Gateway< Listener >::publish ( const std::int32_t  connectionId,
const std::uint16_t  groupMask,
const std::uint16_t  payloadId,
const std::uint8_t *  payload,
const std::uint16_t  payloadLength 
)
inline

The same to the groups groupMask names as well as its own.

Parameters
connectionIdthe connection it belongs to, or NO_CONNECTION for the gateway itself
groupMaskbits from the GroupDirectory; one the table lacks is Refused
payloadIdthe payload's protocol
payloadthe payload's first byte, its own messageHeader included if it has one
payloadLengththe payload's length
Returns
as publish(connectionId, payloadId, payload, payloadLength)

◆ publish() [2/2]

template<typename Listener >
protocol::Publish org::limitless::seqeron::hosted::Gateway< Listener >::publish ( const std::int32_t  connectionId,
const std::uint16_t  payloadId,
const std::uint8_t *  payload,
const std::uint16_t  payloadLength 
)
inline

Offers one payload on a connection to this gateway's own group (H-4).

The result is an offer's, not the cluster's: Published means the host may place it, and a gate edge in flight drops it without notice (H-3).

Parameters
connectionIdthe connection it belongs to, or NO_CONNECTION for the gateway itself
payloadIdthe payload's protocol
payloadthe payload's first byte, its own messageHeader included if it has one
payloadLengththe payload's length
Returns
Published; Declined while the gate is shut, the window is full or stream 304 is back-pressured, to retry; Refused, permanently

◆ sourceId()

template<typename Listener >
std::int32_t org::limitless::seqeron::hosted::Gateway< Listener >::sourceId ( ) const
inlinenoexcept

Member Data Documentation

◆ NO_CONNECTION

template<typename Listener >
constexpr std::int32_t org::limitless::seqeron::hosted::Gateway< Listener >::NO_CONNECTION = -1
staticconstexpr

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