Decentralised Art Server
High-performance C++ backend that exposes HTML interface and a secure REST API for managing Performative Transactions entities
Loading...
Searching...
No Matches
feed_runtime.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <atomic>
4#include <cstddef>
5#include <cstdint>
6#include <filesystem>
7#include <string>
8
9#include "native.h"
10#include <asio.hpp>
11
12#include "feed.hpp"
13
14namespace dcn::feed
15{
17 {
18 std::filesystem::path feed_db_path;
19 std::filesystem::path archive_root;
20 int chain_id = 1;
21 std::size_t hot_window_days = 90;
22 std::int64_t outbox_retention_ms = 7LL * 24 * 60 * 60 * 1000;
23 unsigned int archive_interval_ms = 30 * 1000;
24 unsigned int wal_checkpoint_interval_ms = 15 * 1000;
25 // Must match the namespace of the event source feeding the projector
26 // (IEmittedLogSource::chainNamespace); only the local EVM source exists today.
27 std::string chain_namespace = "local";
28 };
29
30 class FeedRuntime final
31 {
32 public:
33 FeedRuntime(asio::io_context & io_context, FeedRuntimeConfig config);
35
36 FeedRuntime(const FeedRuntime &) = delete;
37 FeedRuntime & operator=(const FeedRuntime &) = delete;
38
41
42 void start();
43 void requestStop();
44 asio::awaitable<void> stop();
45
46 Feed & feed();
47
48 private:
49 asio::awaitable<void> _runArchiveLoop();
50 asio::awaitable<void> _runWalCheckpointLoop();
51 asio::awaitable<void> _sleepFor(std::uint64_t ms) const;
52 asio::awaitable<void> _waitForLoops();
53
54 asio::io_context & _io_context;
55 FeedRuntimeConfig _config;
56 Feed _feed;
57
58 std::atomic<bool> _stop_requested{false};
59 std::atomic<bool> _running{false};
60 std::atomic<std::size_t> _active_loop_count{0};
61 };
62}
FeedRuntime & operator=(FeedRuntime &&)=delete
FeedRuntime(FeedRuntime &&)=delete
void start()
Definition feed_runtime.cpp:35
~FeedRuntime()
Definition feed_runtime.cpp:24
void requestStop()
Definition feed_runtime.cpp:68
FeedRuntime(asio::io_context &io_context, FeedRuntimeConfig config)
Definition feed_runtime.cpp:12
asio::awaitable< void > stop()
Definition feed_runtime.cpp:78
FeedRuntime(const FeedRuntime &)=delete
Feed & feed()
Definition feed_runtime.cpp:97
FeedRuntime & operator=(const FeedRuntime &)=delete
Definition feed.hpp:19
Definition config.hpp:8
Definition feed.hpp:17
Definition feed_runtime.hpp:17
int chain_id
Definition feed_runtime.hpp:20
std::filesystem::path feed_db_path
Definition feed_runtime.hpp:18
std::filesystem::path archive_root
Definition feed_runtime.hpp:19
std::size_t hot_window_days
Definition feed_runtime.hpp:21
unsigned int archive_interval_ms
Definition feed_runtime.hpp:23
unsigned int wal_checkpoint_interval_ms
Definition feed_runtime.hpp:24
std::int64_t outbox_retention_ms
Definition feed_runtime.hpp:22
std::string chain_namespace
Definition feed_runtime.hpp:27