View Source Hyperliquid.Storage.Writer (hyperliquid v0.2.2)
Writes subscription events to configured storage backends.
Events are buffered and flushed periodically for efficiency. This GenServer provides both async (fire-and-forget) and sync (blocking) storage operations.
Usage
# Queue an event for async storage (recommended for high-throughput)
Writer.store_async(Hyperliquid.Api.Subscription.Trades, event_data)
# Store an event synchronously (for critical data)
{:ok, :stored} = Writer.store_sync(module, event_data)Configuration
The writer respects storage configuration defined in each subscription module
via the storage option in use Hyperliquid.Api.SubscriptionEndpoint.
Summary
Functions
Get current buffer size.
Returns a specification to start this module under a supervisor.
Force an immediate flush of the buffer.
Start the storage writer.
Queue an event for async storage.
Store an event synchronously.
Types
Functions
@spec buffer_size() :: non_neg_integer()
Get current buffer size.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec flush() :: :ok
Force an immediate flush of the buffer.
Start the storage writer.
Options
:flush_interval- Milliseconds between flushes (default: 5000):buffer_size- Max events before forcing flush (default: 100)
Queue an event for async storage.
This is non-blocking and batches writes for efficiency.
Store an event synchronously.
This blocks until the event is written to all configured backends.