#pragma once #include "evo/network/handoff_ticket.hpp" #include "evo/persistence/probe_store.hpp" #include "evo/server/pg_slot.hpp" #include #include #include #include // M10.8b destination side of a ticket login over PostgreSQL (ADR-0096, schema v12). Linux // only; owned by the region host's thread, on its own connection slot. For a verified ticket: // stage its transfer under the host's current lease (again after a restart), commit it (the // authority switch), then take the account's durable control for the session. Every step is // idempotent, so a retried ticket login after an undecided outcome converges. A transfer that // is unknown, aborted, for another account or another region is refused. namespace evo::server { class PostgresHandoffLedger final : public network::HandoffLedger { public: using LeaseSource = std::function()>; PostgresHandoffLedger(PgSlot& db, persistence::RegionKey key, LeaseSource lease, std::chrono::milliseconds duration = std::chrono::milliseconds{20000}, std::chrono::milliseconds timeout = std::chrono::milliseconds{2000}) : db_{&db}, key_{key}, lease_{std::move(lease)}, duration_{duration}, timeout_{timeout} {} [[nodiscard]] std::expected admit(const network::TicketClaims& ticket, std::uint64_t session) override; private: PgSlot* db_; persistence::RegionKey key_; LeaseSource lease_; std::chrono::milliseconds duration_, timeout_; }; } // namespace evo::server