Skip to main content

digdigdig3_station/
lib.rs

1//! `digdigdig3-station` — Layer 2 of the digdigdig3 workspace.
2//!
3//! High-level consumer-facing builder over [`digdigdig3::connector_manager::ExchangeHub`].
4//! See `docs/plans/station-architecture.md` for design, `docs/plans/station-phase-1-plan.md`
5//! for the phase-by-phase implementation roadmap.
6//!
7//! Phase 1 scope (current): skeleton only. Modules below are stubs.
8
9pub mod backfill;
10pub use backfill::{fetch_history, SeedOutcome, SeedSource, TruncationReason};
11pub mod bar_align;
12pub use bar_align::{bar_align_points, load_bar_aligned, load_for_key, BarAlignedSeries, FillPolicy, ScalarBar};
13pub mod normalize;
14pub use normalize::{active_only, canonical_status, is_active, SymbolStatus};
15pub mod ws_health;
16pub use ws_health::WsHealth;
17pub mod builder;
18pub mod settings;
19pub mod cache;
20pub mod data;
21pub(crate) mod derived;
22pub mod error;
23pub mod persistence;
24pub mod quota;
25pub mod series;
26pub mod station;
27pub mod subscription;
28
29// Modules moved from dig3-core (persistence/cache/cure/OB concerns belong in station)
30pub mod orderbook;
31pub mod rest_cache;
32
33#[cfg(feature = "reconnect")]
34pub mod reconnect;
35
36// OPFS helpers — wasm32 only, shared by store_wasm + manager_wasm.
37#[cfg(target_arch = "wasm32")]
38pub(crate) mod opfs_helpers;
39
40// storage: native uses std::fs; wasm32 uses OPFS-backed manager.
41// On wasm32 only StorageManager / StorageConfig / StreamKey are available;
42// the sub-modules that use std::fs (event_log, rotation, retention, snapshot,
43// index) remain native-only inside storage/mod.rs.
44pub mod storage;
45
46// cure: pure logic over StorageManager — compiles on both targets.
47pub mod cure;
48
49// replay: backed by StorageManager; ws.rs has cfg-split for tokio::spawn /
50// wasm_bindgen_futures::spawn_local and tokio::time::sleep / gloo_timers.
51pub mod replay;
52
53// polling + gap_heal: REST-based; work on wasm via rest_override (Workstream A).
54// spawn_poller uses cfg-split tokio::spawn / wasm_bindgen_futures::spawn_local.
55pub(crate) mod polling;
56
57pub mod gap_heal;
58
59pub use builder::StationBuilder;
60pub use cache::{ticker_cache, CacheConfig, TickerKey};
61pub use error::{Result, StationError};
62pub use persistence::{PersistDepth, PersistenceConfig};
63pub use series::{DataPoint, Kind, Series, SeriesKey, SharedSeries, SharedSeriesMap, TpoSource};
64pub use quota::{ConsumerHandle, ConsumerQuota, ConsumerWhitelist, QuotaError};
65pub use station::{RewarmOutcome, RewarmedPoints, Station};
66pub use subscription::{
67    Event, FailedStream, Stream, SubscribeReport, SubscriptionHandle, SubscriptionSet,
68    WarmupReport,
69};
70
71// DiskStore is available on both targets (native: std::fs; wasm32: OPFS).
72pub use series::DiskStore;
73
74// PollSpec, PollSource, GapHealConfig: available on both targets.
75// polling is now un-gated; gap_heal is un-gated.
76pub use series::PollSpec;
77pub use polling::PollSource;
78pub use gap_heal::GapHealConfig;
79
80// StorageManager and friends — available on both targets now.
81pub use storage::{StorageConfig, StorageManager, StreamKey};
82
83// EventLog is native-only (std::fs backed).
84#[cfg(not(target_arch = "wasm32"))]
85pub use storage::{EventLog, EventLogIter, EventRecord};
86
87pub use replay::{ReplayHub, ReplayConfig, ReplayRate};
88
89pub use orderbook::{OrderBookTracker, OrderBookError};
90pub use rest_cache::RestCache;
91
92// Settings store — native (file) and wasm32 (OPFS) at API parity.
93pub use settings::{SettingsError, SettingsStore};
94
95pub use cure::{
96    IntegrityChecker, IntegrityReport,
97    Deduper,
98    GapDetector, GapInfo,
99    RepairPipeline, RepairReport,
100};
101
102// Re-export common core types so consumers can build a SubscriptionSet without
103// pulling `digdigdig3` directly.
104pub use digdigdig3::core::types::{AccountType, ExchangeId};
105pub use digdigdig3::SymbolInfo;
106// Re-export Credentials so callers can use add_authenticated without a direct
107// digdigdig3 dependency.
108pub use digdigdig3::core::traits::Credentials;
109// Re-export private DataPoint types for consumers that inspect private events.
110pub use data::{BalanceUpdatePoint, OrderUpdatePoint, PositionUpdatePoint};