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
registry_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 "registry.hpp"
13
14namespace dcn::registry
15{
44 {
45 public:
49 const asio::strand<asio::io_context::executor_type> & write_strand,
51
52 std::string_view id() const override;
53
54 std::int64_t cursor() const override { return _cursor; }
55
56 asio::awaitable<std::size_t> projectBatch(std::size_t limit, std::int64_t now_ms) override;
57
58 private:
59 // Returns true → row materialized (or already present); advance past it.
60 // Returns false → materialization failed; projectBatch retries the row on
61 // later passes and dead-letters it after
62 // _retry.max_attempts consecutive failures.
63 asio::awaitable<bool> _materializeOne(const events::ChangeRecord & row);
64
65 // Retries dead-lettered rows (throttled by _retry.sweep_interval_ms)
66 // and clears their bit on success. Returns the number of rows resolved.
67 asio::awaitable<std::size_t> _sweepDeadLetters(std::size_t limit, std::int64_t now_ms);
68
70 Registry & _registry;
71 asio::strand<asio::io_context::executor_type> _write_strand;
73 std::int64_t _cursor{0};
74
75 // Consecutive-failure tracking for the row currently at the cursor head.
76 std::int64_t _failing_seq{0};
77 std::size_t _failure_count{0};
78
79 std::int64_t _last_sweep_ms{0};
80 };
81}
Definition event_projector.hpp:56
Definition sqlite_hot_store.hpp:19
std::int64_t cursor() const override
Definition registry_projector.hpp:54
asio::awaitable< std::size_t > projectBatch(std::size_t limit, std::int64_t now_ms) override
Definition registry_projector.cpp:38
std::string_view id() const override
Definition registry_projector.cpp:33
RegistryProjector(events::SQLiteHotStore &store, Registry &registry, const asio::strand< asio::io_context::executor_type > &write_strand, events::ProjectorRetryConfig retry={})
Definition registry_projector.cpp:19
Definition registry.hpp:42
Definition registry.hpp:23
Definition event_projector.hpp:38
Definition event_projector.hpp:27