24 std::int64_t
reorgLookbackStart(std::int64_t next_from_block, std::size_t reorg_window_blocks);
33 std::vector<std::shared_ptr<IEmittedLogSource>>
sources;
60 asio::awaitable<void>
stop();
64 void addProjector(std::unique_ptr<IEventProjector> projector);
66 const asio::strand<asio::io_context::executor_type> &
writeStrand()
const {
return _write_strand; }
71 asio::awaitable<void> _sleepFor(
const std::uint64_t ms)
const;
73 asio::awaitable<std::optional<std::int64_t>> _storeLoadNextFromBlock(
int chain_id)
const;
74 asio::awaitable<std::optional<std::uint64_t>> _storeLoadNextLocalSeq(
int chain_id)
const;
75 asio::awaitable<bool> _storeSaveNextLocalSeq(
int chain_id, std::uint64_t next_seq, std::int64_t now_ms)
const;
76 asio::awaitable<std::vector<std::int64_t>> _storeLoadReorgWindowBlocks(
78 std::int64_t from_block,
79 std::int64_t to_block)
const;
80 asio::awaitable<bool> _storeIngestBatch(
82 std::vector<RawChainLog> raw_events,
83 std::vector<DecodedEvent> decoded_events,
84 std::vector<ChainBlockInfo> block_infos,
85 std::int64_t next_from_block,
87 std::optional<std::uint64_t> next_local_seq = std::nullopt)
const;
88 asio::awaitable<bool> _storeApplyFinality(
92 std::size_t reorg_window_blocks)
const;
94 asio::awaitable<void> _runSourceIngestionLoop(std::shared_ptr<IEmittedLogSource> source);
95 asio::awaitable<void> _runProjectorLoop();
96 asio::awaitable<void> _runPruneLoop();
97 asio::awaitable<void> _runMaintenanceLoop();
98 asio::awaitable<void> _waitForLoops();
101 asio::io_context & _io_context;
103 asio::strand<asio::io_context::executor_type> _write_strand;
105 std::shared_ptr<SQLiteHotStore> _store;
106 std::unique_ptr<IEventDecoder> _decoder;
108 std::vector<std::unique_ptr<IEventProjector>> _projectors;
110 std::atomic<bool> _stop_requested{
false};
111 std::atomic<bool> _running{
false};
113 std::atomic<std::size_t> _active_loop_count{0};
const asio::strand< asio::io_context::executor_type > & writeStrand() const
Definition events_runtime.hpp:66
EventRuntime(asio::io_context &io_context, EventRuntimeConfig config)
Definition events_runtime.cpp:29
EventRuntime(EventRuntime &&)=delete
asio::awaitable< storage::sqlite::WalCheckpointStats > checkpointWal(storage::sqlite::WalCheckpointMode mode) const override
Definition events_runtime.cpp:241
void requestStop()
Definition events_runtime.cpp:110
void start()
Definition events_runtime.cpp:51
bool running() const
Definition events_runtime.cpp:139
EventRuntime & operator=(const EventRuntime &)=delete
asio::awaitable< void > stop()
Definition events_runtime.cpp:120
void addProjector(std::unique_ptr< IEventProjector > projector)
Definition events_runtime.cpp:149
EventRuntime(const EventRuntime &)=delete
EventRuntime & operator=(EventRuntime &&)=delete
SQLiteHotStore & projectionStore()
Definition events_runtime.cpp:156
bool ingestionEnabled() const
Definition events_runtime.cpp:144
~EventRuntime()
Definition events_runtime.cpp:40
Definition sqlite_hot_store.hpp:19
Definition wal_store.hpp:10
Definition decoded_event.hpp:11
constexpr std::size_t DEFAULT_PROJECT_BATCH_SIZE
Definition events_runtime.hpp:22
std::int64_t reorgLookbackStart(std::int64_t next_from_block, std::size_t reorg_window_blocks)
Definition events_runtime.cpp:23
WalCheckpointMode
Definition wal.hpp:9
Definition events_runtime.hpp:28
unsigned int wal_checkpoint_interval_ms
Definition events_runtime.hpp:43
unsigned int confirmations
Definition events_runtime.hpp:36
bool ingestion_enabled
Definition events_runtime.hpp:32
std::filesystem::path hot_db_path
Definition events_runtime.hpp:29
unsigned int block_batch_size
Definition events_runtime.hpp:37
std::size_t reorg_window_blocks
Definition events_runtime.hpp:39
unsigned int projector_interval_ms
Definition events_runtime.hpp:41
unsigned int prune_interval_ms
Definition events_runtime.hpp:42
std::optional< std::int64_t > start_block
Definition events_runtime.hpp:34
unsigned int poll_interval_ms
Definition events_runtime.hpp:35
int chain_id
Definition events_runtime.hpp:31
std::vector< std::shared_ptr< IEmittedLogSource > > sources
Definition events_runtime.hpp:33
Definition events_ingest.hpp:12