Skip to main content

Module database_handler

Module database_handler 

Source
Expand description

Unified database handler that owns a connection pool and implements all persistence traits from hypercall_db.

This is the standalone Diesel persistence layer. It has NO dependency on the root hypercall crate and owns its own DbPool directly. All SQL is inline or delegated to local modules (crate::ledger_ops, crate::settlement_ops, crate::order_status_materialization).

Trait implementations live in sibling modules:

  • crate::instruments – InstrumentReader / InstrumentWriter
  • crate::tiers – TierReader / TierWriter
  • crate::mmp – MmpConfigReader / MmpConfigWriter
  • crate::orders – OrderReader / OrderWriter + fill ledger helper
  • crate::transaction – Transactional (+ DieselTransaction)
  • crate::replay – JournalReplayReader
  • crate::rfq – RfqReader / RfqWriter
  • crate::settlements – SettlementReader / SettlementWriter

Structs§

DatabaseHandler
Synchronous persistence handler. Owns an r2d2 connection pool and implements all engine-path traits from hypercall_db (orders, instruments, tiers, settlements, journal replay, archiver, RFQ).
DynConnectionManager
Connection manager that resolves the database URL on every connect() call.
HypercallMigrations 🔒
Diesel runs each embedded migration file with one batch_execute call. PostgreSQL rejects CREATE/DROP INDEX CONCURRENTLY when it appears in a multi-statement batch, even outside an explicit transaction. This source replaces the one affected migration with a splitter that executes each statement separately while preserving Diesel’s migration ledger behavior.
NonTransactionalMigrationMetadata 🔒
PgTimeoutCustomizer 🔒
Sets statement_timeout and lock_timeout on every new Postgres connection.
SplitStatementMigration 🔒
StaticMigrationName 🔒

Constants§

MIGRATIONS
Embed migrations relative to hypercall-rs/db-diesel/Cargo.toml.
ORDER_INFOS_ACTIVE_SYMBOL_INDEX_MIGRATION 🔒

Functions§

build_db_pool
Build a raw r2d2 pool with the given auth config, for callers that manage the pool lifecycle themselves (e.g. integrated.rs).
current_option_token_deployment 🔒
Read the option token deployment parameters from environment variables. Used by save_market_and_instrument_sync to derive option token addresses.
redact_database_url 🔒
Redact credentials from a database URL for safe logging.
rsm_deposit_match_from_row 🔒
wallet_from_bytes 🔒

Type Aliases§

DbPool
Synchronous r2d2 connection pool for Postgres.
LegacyDbPool
Legacy pool type alias for backward compatibility with code that constructs pools directly with ConnectionManager.