simulator-client
Async WebSocket client for the Termina Solana simulator backtest API.
[]
= "0.16"
Quickstart
Use ManagedBacktestSession. It owns the control and subscription WebSockets,
keepalives, and reconnect-and-reattach, and surfaces a single event stream.
use ;
async
For a run split across several sessions, managed::ManagedParallelSession
multiplexes the batch over one control connection.
Reconnects are not optional
A backtest session runs on its own host and outlives the WebSocket you talk to it through — but only if something comes back for it.
The management service in front of your session is redeployed routinely. When
it shuts down it pauses each live session, records it as handed off, and closes
the control WebSocket with code 1012 (management handoff). The session then
waits to be claimed:
- Reconnect and send
AttachBacktestSession(with the last sequence number you received) followed byResumeAttachedSession, and the session resumes with everything you missed replayed. - Do nothing, and the server reclaims it once
disconnect_timeout_secselapses. The run is gone.
Not every disconnect is graceful — a load balancer draining a target can reset the socket with no close frame at all. Treat any transport error as "reconnect and reattach", never as a failed run.
ManagedBacktestSession implements all of this. Its control task reconnects
with backoff and re-handshakes with attach + resume, and it defaults
disconnect_timeout_secs to a window wider than its own reconnect budget so the
server does not reclaim a session while the client is still retrying. If you
drive the protocol yourself, budget for the same.
Low-level API
BacktestClient / BacktestSession are a single raw WebSocket with no
reconnect and no reattach: the connection dropping ends the run. Use them only
when you need direct BacktestRequest / BacktestResponse access, and then
implement the reattach loop above yourself via BacktestClient::attach_session
and BacktestSession::resume_attached_session.
Docs
Full API documentation: https://docs.rs/simulator-client.