MantisBase v0.4.9
Loading...
Searching...
No Matches
mb::MbRealtimeDB Class Reference

#include <realtime.h>

Inheritance diagram for mb::MbRealtimeDB:
Collaboration diagram for mb::MbRealtimeDB:

Public Member Functions

 MbRealtimeDB (const MantisBase &app)
 ~MbRealtimeDB ()
bool init () const
void addDbHooks (const std::string &entity_name) const
void addDbHooks (const MbEntity &entity) const
void dropDbHooks (const std::string &entity_name) const
void runWorker (const RtCallback &callback)
void stopWorker () const
void notifyChange () const
Public Member Functions inherited from mb::MbAppMixin
 MbAppMixin (const MantisBase &app)
 Constrictor for instantiating this interface.
 MbAppMixin (MbAppMixin &&)=default
MbAppMixin & operator= (MbAppMixin &&)=delete
 MbAppMixin (const MbAppMixin &)=default
MbAppMixin & operator= (const MbAppMixin &)=delete
const MantisBase & mbApp () const
 Application that owns this service or request context.
const MbLogger & logger () const

Static Public Member Functions

static void addDbHooks (const MbEntity &entity, const std::shared_ptr< soci::session > &sess)
static void dropDbHooks (const std::string &entity_name, const std::shared_ptr< soci::session > &sess)

Detailed Description

Realtime database change detection and notification. Initializes DB-specific hooks (triggers for PostgreSQL, polling for SQLite) and runs a worker that invokes the registered callback with change events.

Constructor & Destructor Documentation

◆ MbRealtimeDB()

mb::MbRealtimeDB::MbRealtimeDB ( const MantisBase & app)
explicit
Parameters
appOwning application (used for db access/config). Stored by reference.

◆ ~MbRealtimeDB()

mb::MbRealtimeDB::~MbRealtimeDB ( )
default

Defined in the library. The implicit destructor would be emitted in every consumer and would need MbRtDbWorker, which is not exported.

Member Function Documentation

◆ addDbHooks() [1/3]

void mb::MbRealtimeDB::addDbHooks ( const MbEntity & entity) const

Register change hooks for an entity.

◆ addDbHooks() [2/3]

void mb::MbRealtimeDB::addDbHooks ( const MbEntity & entity,
const std::shared_ptr< soci::session > & sess )
static

Register change hooks for an entity on a given session (static, for schema creation).

◆ addDbHooks() [3/3]

void mb::MbRealtimeDB::addDbHooks ( const std::string & entity_name) const

Register change hooks for an entity by name.

◆ dropDbHooks() [1/2]

void mb::MbRealtimeDB::dropDbHooks ( const std::string & entity_name) const

Remove change hooks for an entity by name.

◆ dropDbHooks() [2/2]

void mb::MbRealtimeDB::dropDbHooks ( const std::string & entity_name,
const std::shared_ptr< soci::session > & sess )
static

Remove change hooks for an entity on a given session (static).

◆ init()

bool mb::MbRealtimeDB::init ( ) const
nodiscard

Initialize realtime for the current database backend. Must be called after DB is ready.

◆ notifyChange()

void mb::MbRealtimeDB::notifyChange ( ) const

Wake the worker to drain change events immediately (push, not poll). Called by the write path after a mutation commits. No-op if the worker is not running. Thread-safe.

◆ runWorker()

void mb::MbRealtimeDB::runWorker ( const RtCallback & callback)

Start the realtime worker; callback receives change events.

◆ stopWorker()

void mb::MbRealtimeDB::stopWorker ( ) const

Stop the realtime worker.


The documentation for this class was generated from the following files:
  • /home/runner/work/mantisbase/mantisbase/include/mantisbase/core/realtime.h
  • /home/runner/work/mantisbase/mantisbase/src/core/realtime.cpp