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_projector.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <string_view>
6
7#include "native.h"
8#include <asio.hpp>
9
10#include "event_projector.hpp"
11#include "sqlite_hot_store.hpp"
12#include "feed.hpp"
13
14namespace dcn::feed
15{
40 {
41 public:
43 Feed & feed,
44 const asio::strand<asio::io_context::executor_type> & write_strand,
46
47 std::string_view id() const override;
48 std::int64_t cursor() const override { return _last_change_seq; }
49 asio::awaitable<std::size_t> projectBatch(std::size_t limit, std::int64_t now_ms) override;
50
51 private:
52 // Retries dead-lettered rows (throttled by _retry.sweep_interval_ms)
53 // and clears their bit on success. Returns the number of rows resolved.
54 asio::awaitable<std::size_t> _sweepDeadLetters(std::size_t limit, std::int64_t now_ms);
55
57 Feed & _feed;
58 asio::strand<asio::io_context::executor_type> _write_strand;
60 std::int64_t _last_change_seq{0};
61
62 // Consecutive-failure tracking for the row currently at the cursor head.
63 std::int64_t _failing_seq{0};
64 std::size_t _failure_count{0};
65
66 std::int64_t _last_sweep_ms{0};
67 };
68}
Definition event_projector.hpp:56
Definition sqlite_hot_store.hpp:19
std::string_view id() const override
Definition feed_projector.cpp:21
asio::awaitable< std::size_t > projectBatch(std::size_t limit, std::int64_t now_ms) override
Definition feed_projector.cpp:26
FeedProjector(events::SQLiteHotStore &store, Feed &feed, const asio::strand< asio::io_context::executor_type > &write_strand, events::ProjectorRetryConfig retry={})
Definition feed_projector.cpp:8
std::int64_t cursor() const override
Definition feed_projector.hpp:48
Definition feed.hpp:19
Definition feed.hpp:17
Definition event_projector.hpp:27