Documentation
¶
Overview ¶
Package behavior holds the runtime constants every Grvt SDK shares, and the write and retry decisions made with them.
Index ¶
Constants ¶
const CallTimeout = 30000 * time.Millisecond
CallTimeout: Default bound on one whole call, including preparation and retries.
const ClientOrderIDCounterBits = 31
ClientOrderIDCounterBits: Width of the per-process counter in the low bits of a generated client order ID.
const ClientOrderIDCounterMask = 0x7FFFFFFF
ClientOrderIDCounterMask: (1 << CLIENT_ORDER_ID_COUNTER_BITS) - 1.
const ClientOrderIDSecondsBits = 32
ClientOrderIDSecondsBits: Generated client order IDs are 1<<63 | seconds<<counter_bits | counter; seconds is the Unix time masked to this many bits.
const ClientOrderIDSecondsMask = 0xFFFFFFFF
ClientOrderIDSecondsMask: (1 << CLIENT_ORDER_ID_SECONDS_BITS) - 1.
const CountdownMaxSeconds = 300
CountdownMaxSeconds: Largest countdown the cancel-on-disconnect helper accepts.
const CountdownMinSeconds = 1
CountdownMinSeconds: Smallest countdown the cancel-on-disconnect helper accepts.
const HTTPAttemptTimeout = 10000 * time.Millisecond
HTTPAttemptTimeout: Default bound on one HTTP attempt, including login.
const QueueSize = 4096
QueueSize: Default bound on each subscription's queue.
const RateLimitCode = 1006
RateLimitCode: The rate-limit error code. A read always retries on it.
const ReadAttempts = 3
ReadAttempts: Tries in total for a read that keeps failing with a retryable error. Writes are sent once.
const ReadBackoffBase = 100 * time.Millisecond
ReadBackoffBase: Full-jitter backoff between read retries: wait uniform(0, min(cap, base * 2^attempt)).
const ReadBackoffCap = 2000 * time.Millisecond
ReadBackoffCap: Largest wait between read retries.
const ReconnectBackoffBase = 250 * time.Millisecond
ReconnectBackoffBase: Full-jitter backoff between WebSocket reconnects, same formula as reads.
const ReconnectBackoffCap = 30000 * time.Millisecond
ReconnectBackoffCap: Largest wait between WebSocket reconnects.
const ResyncTimeout = 5000 * time.Millisecond
ResyncTimeout: Default wait for a fresh snapshot after a gap re-subscribe before reconnecting.
const SessionDefaultLifetime = 3600000 * time.Millisecond
SessionDefaultLifetime: Session lifetime assumed when the cookie carries no expiry.
const SessionRenewAt = 0.8
SessionRenewAt: Log in again once this share of the session cookie's lifetime has passed.
const SessionRetryDelay = 5000 * time.Millisecond
SessionRetryDelay: Wait before trying a failed session renewal again.
const WSRequestTimeout = 5000 * time.Millisecond
WSRequestTimeout: Default wait for the reply to one WebSocket request.
const WriteRejectedStatusMax = 499
WriteRejectedStatusMax: Upper end of WRITE_REJECTED_STATUS_MIN's range.
const WriteRejectedStatusMin = 400
WriteRejectedStatusMin: Inclusive range. A write error is a definite rejection only if its HTTP status (when there is one) and its code's contract status are in it and the code is in the contract; otherwise the outcome is unknown.
Variables ¶
This section is empty.
Functions ¶
func ReadRetryStatuses ¶
func ReadRetryStatuses() []int
ReadRetryStatuses: HTTP statuses a read retries on, whatever the error code. Codes the contract marks retryable retry too.
func ReadRetryable ¶
ReadRetryable reports whether a read that failed with this error may be tried again. status is 0 when there is none; codeRetryable: the contract says so.
func RetryRead ¶
RetryRead reports whether to try a read again after its attempt-th try (from 1) failed; retryable as for the error.
func WriteOutcomeUnknown ¶
WriteOutcomeUnknown reports whether a failed write whose request may have left this process may have reached the exchange. status is the reply's HTTP status and codeStatus the contract's HTTP status for the reply's error code; 0 when there is none (no reply, a reply that did not decode, a code the contract does not list).
Types ¶
This section is empty.