Files
aevolution/include/evo/server/postgres_action_ledger.hpp
T
dingo 08519b66af
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 40s
Foundation / checks (ecs) (push) Successful in 1m50s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 26s
Foundation / checks (network) (push) Canceled after 1m49s
Foundation / checks (client) (push) Canceled after 2m29s
Add cellular durable action record lookup
2026-10-10 23:05:10 -04:00

40 lines
1.9 KiB
C++

#pragma once
#include "evo/network/intent_admission.hpp"
#include "evo/persistence/region_lease_store.hpp"
#include "evo/server/pg_slot.hpp"
#include <chrono>
#include <functional>
#include <optional>
#include <utility>
// M10.4b durable action records over the region's PostgreSQL lease (ADR-0092, schema v11).
// Linux only. Owned by the region host's thread, on its own connection slot. `lease`
// returns the host's current region lease, or nothing while it holds none; every lookup
// then reports `unavailable`, as does any store failure.
namespace evo::server {
class PostgresActionLedger final : public network::ActionLedger {
public:
using LeaseSource = std::function<std::optional<persistence::LeaseGrant>()>;
PostgresActionLedger(PgSlot& db, persistence::RegionKey key, LeaseSource lease,
std::chrono::milliseconds timeout = std::chrono::milliseconds{2000})
: db_{&db}, key_{key}, lease_{std::move(lease)}, timeout_{timeout} {}
[[nodiscard]] std::expected<std::optional<network::ActionOutcome>, network::ActionLedgerError>
find(const network::AccountId& account, std::uint64_t action_id) override;
[[nodiscard]] std::expected<std::optional<network::DurableActionRecord>,
network::ActionLedgerError>
find_record(const network::AccountId& account, std::uint64_t action_id) override;
[[nodiscard]] std::expected<std::vector<std::optional<network::DurableActionRecord>>,
network::ActionLedgerError>
find_all_records(std::span<const network::ActionKey> keys) override;
[[nodiscard]] std::expected<std::vector<std::optional<network::ActionOutcome>>,
network::ActionLedgerError>
find_all(std::span<const network::ActionKey> keys) override; // One statement.
private:
PgSlot* db_;
persistence::RegionKey key_;
LeaseSource lease_;
std::chrono::milliseconds timeout_;
};
} // namespace evo::server