Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
DEMO
Loading...
Searching...
No Matches
signet::forge::EventBus Class Reference

Multi-tier event bus for routing SharedColumnBatch events. More...

#include <event_bus.hpp>

Classes

struct  Stats
 Snapshot of cumulative event bus counters. More...
 

Public Types

using Options = EventBusOptions
 Alias for the options struct.
 
using Channel = MpmcRing< SharedColumnBatch >
 Tier-1 dedicated channel type (MpmcRing used as SPSC when single-writer).
 

Public Member Functions

 EventBus (Options opts={})
 Construct an EventBus with the given options.
 
 EventBus (EventBus &&)=delete
 Non-movable (contains mutex).
 
EventBusoperator= (EventBus &&)=delete
 Non-movable (contains mutex).
 
 EventBus (const EventBus &)=delete
 
EventBusoperator= (const EventBus &)=delete
 
 ~EventBus ()=default
 
std::shared_ptr< Channelmake_channel (const std::string &name, size_t capacity=0)
 Create (or return existing) named SPSC/MPSC channel.
 
std::shared_ptr< Channelchannel (const std::string &name) const
 Look up an existing channel by name.
 
bool publish (SharedColumnBatch batch)
 Publish a batch to the shared Tier-2 ring.
 
bool pop (SharedColumnBatch &out)
 Pop a batch from the shared Tier-2 ring (for worker threads).
 
void attach_sink (std::shared_ptr< StreamingSink > sink)
 Attach a StreamingSink for Tier-3 durable logging.
 
void detach_sink ()
 Detach the currently attached Tier-3 sink (no-op if none attached).
 
bool has_sink () const
 Check whether a Tier-3 StreamingSink is currently attached.
 
Stats stats () const noexcept
 Return a snapshot of the cumulative event bus statistics.
 
void reset_stats () noexcept
 Reset all counters to zero.
 
size_t tier2_size () const noexcept
 Approximate number of batches currently in the Tier-2 ring.
 
size_t tier2_capacity () const noexcept
 Capacity of the Tier-2 MPMC ring (power-of-two, set by EventBusOptions).
 
size_t num_channels () const
 Number of named Tier-1 channels that have been created.
 

Detailed Description

Multi-tier event bus for routing SharedColumnBatch events.

Routes batches through three tiers:

  • Tier 1 – SPSC dedicated channels (sub-us, one per producer-consumer pair).
  • Tier 2 – MPMC shared pool (us, N producers to M worker threads).
  • Tier 3 – WAL / StreamingSink (ms, async durable logging).

The bus is non-copyable and non-movable due to its internal mutex. Wrap in std::unique_ptr<EventBus> if heap allocation is needed.

See also
EventBusOptions, MpmcRing, StreamingSink

Definition at line 88 of file event_bus.hpp.

Member Typedef Documentation

◆ Channel

Tier-1 dedicated channel type (MpmcRing used as SPSC when single-writer).

Definition at line 98 of file event_bus.hpp.

◆ Options

Alias for the options struct.

Definition at line 91 of file event_bus.hpp.

Constructor & Destructor Documentation

◆ EventBus() [1/3]

signet::forge::EventBus::EventBus ( Options  opts = {})
inlineexplicit

Construct an EventBus with the given options.

Parameters
optsConfiguration controlling tier capacities and Tier-3 enablement.

Definition at line 106 of file event_bus.hpp.

◆ EventBus() [2/3]

signet::forge::EventBus::EventBus ( EventBus &&  )
delete

Non-movable (contains mutex).

◆ EventBus() [3/3]

signet::forge::EventBus::EventBus ( const EventBus )
delete

◆ ~EventBus()

signet::forge::EventBus::~EventBus ( )
default

Member Function Documentation

◆ attach_sink()

void signet::forge::EventBus::attach_sink ( std::shared_ptr< StreamingSink sink)
inline

Attach a StreamingSink for Tier-3 durable logging.

Parameters
sinkShared pointer to a StreamingSink (bus shares ownership).

Definition at line 191 of file event_bus.hpp.

◆ channel()

std::shared_ptr< Channel > signet::forge::EventBus::channel ( const std::string &  name) const
inline

Look up an existing channel by name.

Parameters
nameLogical channel identifier.
Returns
Shared pointer to the channel, or nullptr if not found.

Definition at line 141 of file event_bus.hpp.

◆ detach_sink()

void signet::forge::EventBus::detach_sink ( )
inline

Detach the currently attached Tier-3 sink (no-op if none attached).

Definition at line 197 of file event_bus.hpp.

◆ has_sink()

bool signet::forge::EventBus::has_sink ( ) const
inline

Check whether a Tier-3 StreamingSink is currently attached.

Returns
true if a sink is attached.

Definition at line 204 of file event_bus.hpp.

◆ make_channel()

std::shared_ptr< Channel > signet::forge::EventBus::make_channel ( const std::string &  name,
size_t  capacity = 0 
)
inline

Create (or return existing) named SPSC/MPSC channel.

Parameters
nameLogical channel identifier.
capacityRing capacity (0 → use opts_.tier1_capacity).

Definition at line 125 of file event_bus.hpp.

◆ num_channels()

size_t signet::forge::EventBus::num_channels ( ) const
inline

Number of named Tier-1 channels that have been created.

Definition at line 246 of file event_bus.hpp.

◆ operator=() [1/2]

EventBus & signet::forge::EventBus::operator= ( const EventBus )
delete

◆ operator=() [2/2]

EventBus & signet::forge::EventBus::operator= ( EventBus &&  )
delete

Non-movable (contains mutex).

◆ pop()

bool signet::forge::EventBus::pop ( SharedColumnBatch out)
inline

Pop a batch from the shared Tier-2 ring (for worker threads).

Parameters
outReceives the popped batch on success.
Returns
true if a batch was popped; false if the ring is empty (caller should back off / yield).

Definition at line 180 of file event_bus.hpp.

◆ publish()

bool signet::forge::EventBus::publish ( SharedColumnBatch  batch)
inline

Publish a batch to the shared Tier-2 ring.

Also forwards to Tier-3 sink (if attached and opts_.enable_tier3).

Parameters
batchThe column batch to publish (moved into the ring).
Returns
true on success; false if the Tier-2 ring is full (caller may retry or drop).

Definition at line 158 of file event_bus.hpp.

◆ reset_stats()

void signet::forge::EventBus::reset_stats ( )
inlinenoexcept

Reset all counters to zero.

Definition at line 231 of file event_bus.hpp.

◆ stats()

Stats signet::forge::EventBus::stats ( ) const
inlinenoexcept

Return a snapshot of the cumulative event bus statistics.

Returns
Stats struct with relaxed-order atomic reads.

Definition at line 222 of file event_bus.hpp.

◆ tier2_capacity()

size_t signet::forge::EventBus::tier2_capacity ( ) const
inlinenoexcept

Capacity of the Tier-2 MPMC ring (power-of-two, set by EventBusOptions).

Definition at line 244 of file event_bus.hpp.

◆ tier2_size()

size_t signet::forge::EventBus::tier2_size ( ) const
inlinenoexcept

Approximate number of batches currently in the Tier-2 ring.

Definition at line 242 of file event_bus.hpp.


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