COROIO: NNet::NActors::TNode< TPoller > Class Template Reference
COROIO
 
Loading...
Searching...
No Matches
NNet::NActors::TNode< TPoller > Class Template Reference

Concrete INode implementation for a single remote actor-system endpoint. More...

#include <node.hpp>

Inheritance diagram for NNet::NActors::TNode< TPoller >:
NNet::NActors::INode NNet::NActors::IOutputStream

Public Types

using TSocket = typename TPoller::TSocket
 

Public Member Functions

 TNode (TPoller &poller, TMessagesFactory &factory, TResolver &resolver, const std::function< TSocket(const TAddress &)> &socketFactory, const THostPort &hostPort)
 Constructs a TNode but does not connect immediately.
 
void Send (TEnvelope &&envelope) override
 Serializes envelope and appends it to the outbound buffer.
 
std::span< char > Acquire (size_t size) override
 Reserves size contiguous bytes in the buffer and returns a span over them.
 
void Commit (size_t size) override
 Marks size previously acquired bytes as ready to send.
 
void StartConnect () override
 Initiates an async TCP connection if not already connected or connecting.
 
void Drain () override
 Calls StartConnect() then asynchronously writes all buffered bytes to the socket.
 
THostPort GetHostPort () const override
 Returns the remote host:port this node connects to.
 

Detailed Description

template<typename TPoller>
class NNet::NActors::TNode< TPoller >

Concrete INode implementation for a single remote actor-system endpoint.

Maintains a persistent TCP connection to hostPort, reconnecting with a 1 s back-off on failure. Outbound messages are accumulated in a vector buffer and flushed by Drain() once the connection is established.

Template Parameters
TPollerPoller type (e.g. TDefaultPoller); determines the socket type.

Constructor & Destructor Documentation

◆ TNode()

template<typename TPoller >
NNet::NActors::TNode< TPoller >::TNode ( TPoller &  poller,
TMessagesFactory factory,
TResolver resolver,
const std::function< TSocket(const TAddress &)> &  socketFactory,
const THostPort hostPort 
)
inline

Constructs a TNode but does not connect immediately.

Call StartConnect() or Drain() to initiate the connection.

Parameters
pollerPoller used for async I/O and sleep.
factoryFactory for serializing messages to their Far (wire) form.
resolverDNS resolver for translating hostPort.Host to an IP.
socketFactoryCallable that creates a connected socket given a resolved TAddress.
hostPortRemote host and port to connect to.

Member Function Documentation

◆ Acquire()

template<typename TPoller >
std::span< char > NNet::NActors::TNode< TPoller >::Acquire ( size_t  size)
inlineoverridevirtual

Reserves size contiguous bytes in the buffer and returns a span over them.

Implements NNet::NActors::IOutputStream.

◆ Commit()

template<typename TPoller >
void NNet::NActors::TNode< TPoller >::Commit ( size_t  size)
inlineoverridevirtual

Marks size previously acquired bytes as ready to send.

Implements NNet::NActors::IOutputStream.

◆ Drain()

template<typename TPoller >
void NNet::NActors::TNode< TPoller >::Drain ( )
inlineoverridevirtual

Calls StartConnect() then asynchronously writes all buffered bytes to the socket.

Implements NNet::NActors::INode.

◆ GetHostPort()

template<typename TPoller >
THostPort NNet::NActors::TNode< TPoller >::GetHostPort ( ) const
inlineoverridevirtual

Returns the remote host:port this node connects to.

Implements NNet::NActors::INode.

◆ Send()

template<typename TPoller >
void NNet::NActors::TNode< TPoller >::Send ( TEnvelope &&  envelope)
inlineoverridevirtual

Serializes envelope and appends it to the outbound buffer.

Implements NNet::NActors::INode.

◆ StartConnect()

template<typename TPoller >
void NNet::NActors::TNode< TPoller >::StartConnect ( )
inlineoverridevirtual

Initiates an async TCP connection if not already connected or connecting.

Implements NNet::NActors::INode.


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