client: resilient oracle subscriptions#14
Conversation
Add SubscribeToPriceOracle() and SubscribeToFeeRateOracle() APIs for real-time asset price and fee rate updates. Test client now accepts configurable OracleTickers list, with async subscription including exponential backoff retry (100ms-5s), deduplication, and automatic event streaming to frontend. Comprehensive tests cover success, error, and redundant subscription cases. Config supports comma-separated tickers: oracle=BTC,DCR
b7b82a4 to
a3c3eff
Compare
martonp
left a comment
There was a problem hiding this comment.
For the test client, we don't need separate oracle clients. Regular clients are the same as oracle clients. I guess we could add a special UI to subscribe to oracles, but I don't think we need that right now.
|
There isn't an oracle test client currently. It's the same test client with a command option to setup oracle updates for the tickers provided. I thought that would simplify testing with it instead of using the UI to setup the subscriptions. |
- Replace one-shot WaitForConnection with pub-sub ConnectionStateFeed API - Add subscriber registry (subscribe/unsubscribe) to meshConnectionManager - Implement state change broadcasting to all subscribers via buffered channels - ConnectionStateFeed returns channel delivering true/false state updates - Context cancellation unsubscribes and closes subscriber channels - Updated mesh_connection_manager_test with TestConnectionStateFeed covering all cases - Updated testing/client to use ConnectionStateFeed for oracle subscriptions - Non-blocking sends with drop-on-slow-reader semantics ensure consistency - Multiple concurrent subscribers now supported
…ment - Subscribe now registers in topic registry before attempting wire call - Unsubscribe now unregisters from topic registry before attempting wire call - Both return nil silently when no connection is available (not an error) - Connection sync happens automatically via openPushStream on reconnect - Topic registry is source of truth; subscriptions persist across reconnects - Broadcast unchanged: still requires active connection (has no local state) - Added tests verifying Subscribe/Unsubscribe succeed without connection - Simplified testing/client.subscribeToOracles: removed connection-wait loop - Errors from wire calls still propagate; only missing connection is silent
Revert testclient and harness.sh to pre-oracle configuration state. Simplifies test infrastructure while keeping oracle subscription APIs in client.
Reverted the test client and harness changes. |
martonp
left a comment
There was a problem hiding this comment.
- setPrimaryConnection is called both in
runandattemptConnect, causing double notifications each time. The call inattemptConnectcan be removed.
- Remove unmarshalOracleData wrapper from oracle.go; use proto.Unmarshal directly - Remove TestUnmarshalOracleData test from oracle_test.go - Rename meshConnectionManager.subscribe/unsubscribe to subscribeToConnectionState/unsubscribeFromConnectionState - Remove connMtx and connChanged from meshConnectionManager; simplify synchronization - Improve slow subscriber handling: drain full buffer and send latest state - Update ConnectionStateFeed to return (chan bool, error) for consistency - Fix Subscribe to not unregister topic on wire failure; retain for reconnect retry - Fix Unsubscribe to unregister at correct point in flow - Remove OracleTickers from test client Config; remove subscribeToOracles from testing/client
0b3f585 to
1add712
Compare
Co-authored-by: Marton <marci93@gmail.com>
Add oracle subscription APIs (SubscribeToPriceOracle/SubscribeToFeeRateOracle) with
automatic reconnection handling. Introduce pub-sub ConnectionStateFeed pattern for
efficient multi-subscriber connection tracking. Decouple subscription registration from
wire connectivity—subscriptions persist in registry and sync automatically on reconnect.