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.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <filesystem>
6#include <memory>
7#include <string>
8
9#include "async.hpp"
10#include "feed_types.hpp"
11#include "feed_store.hpp"
12#include "sqlite_feed_store.hpp"
13#include "event_projector.hpp"
14#include "sqlite/wal_store.hpp"
15
16namespace dcn::feed
17{
19 {
20 public:
21 Feed(asio::io_context & io_context,
22 std::filesystem::path feed_db_path,
23 std::filesystem::path archive_root,
24 std::int64_t outbox_retention_ms,
25 int default_chain_id,
26 std::string default_chain_namespace = "local");
27
28 Feed(const Feed&) = delete;
29 Feed& operator=(const Feed&) = delete;
30
31 // write side (serialize on _strand)
32 asio::awaitable<void> applyChange(events::ChangeRecord row, std::int64_t now_ms);
33 asio::awaitable<void> maintainOutbox(std::int64_t now_ms);
34 asio::awaitable<bool> runArchiveCycle(int chain_id, std::size_t hot_window_days, std::int64_t now_ms);
35
36 // query side (IFeedRepository; delegates to _store, callers own concurrency)
37 FeedPage getFeedPage(const FeedQuery & query) const override;
38 StreamPage getStreamPage(const StreamQuery & query) const override;
39 std::int64_t minAvailableStreamSeq() const override;
40
41 // cursor
42 // getFeedCursor is synchronous: read once at construction (pre-start, single-threaded)
43 std::int64_t getFeedCursor() const;
44 // setFeedCursor runs on the _strand so cursor writes serialize with all other store access
45 asio::awaitable<void> setFeedCursor(std::int64_t seq);
46
47 asio::awaitable<storage::sqlite::WalCheckpointStats> checkpointWal(
48 storage::sqlite::WalCheckpointMode mode) const override;
49
50 private:
51 asio::strand<asio::io_context::executor_type> _strand;
52 std::unique_ptr<IFeedStore> _store;
53 };
54}
asio::awaitable< void > maintainOutbox(std::int64_t now_ms)
Definition feed.cpp:35
Feed(const Feed &)=delete
asio::awaitable< storage::sqlite::WalCheckpointStats > checkpointWal(storage::sqlite::WalCheckpointMode mode) const override
Definition feed.cpp:73
asio::awaitable< void > setFeedCursor(std::int64_t seq)
Definition feed.cpp:67
StreamPage getStreamPage(const StreamQuery &query) const override
Definition feed.cpp:52
asio::awaitable< bool > runArchiveCycle(int chain_id, std::size_t hot_window_days, std::int64_t now_ms)
Definition feed.cpp:41
FeedPage getFeedPage(const FeedQuery &query) const override
Definition feed.cpp:47
Feed & operator=(const Feed &)=delete
asio::awaitable< void > applyChange(events::ChangeRecord row, std::int64_t now_ms)
Definition feed.cpp:29
std::int64_t getFeedCursor() const
Definition feed.cpp:62
std::int64_t minAvailableStreamSeq() const override
Definition feed.cpp:57
Feed(asio::io_context &io_context, std::filesystem::path feed_db_path, std::filesystem::path archive_root, std::int64_t outbox_retention_ms, int default_chain_id, std::string default_chain_namespace="local")
Definition feed.cpp:12
Definition feed_types.hpp:91
Definition wal_store.hpp:10
Definition feed.hpp:17
WalCheckpointMode
Definition wal.hpp:9
Definition event_projector.hpp:38
Definition feed_types.hpp:57
Definition feed_types.hpp:49
Definition feed_types.hpp:81
Definition feed_types.hpp:64