|
FastMM C++ API 0.14.0
Public headers, tier 1 and tier 2
|
RestChannel: reactor-driven keep-alive HTTP(S) for the venue requests that run on the net thread (depth snapshots, openOrders, execution replays, listenKey keepalive, and the order traffic that goes over REST: orders falling back from the WebSocket, cancel-all, dead man's switch refreshes). More...
#include "fastmm/net/dns.hpp"#include "fastmm/net/endpoint_selector.hpp"#include "fastmm/net/http_client.hpp"#include "fastmm/net/reactor.hpp"#include "fastmm/net/source_address.hpp"#include "fastmm/net/tls_stream.hpp"#include "fastmm/net/url.hpp"#include <array>#include <cstddef>#include <cstdint>#include <cstring>#include <deque>#include <memory>#include <optional>#include <stdexcept>#include <string>#include <string_view>#include <utility>#include <vector>Go to the source code of this file.
Classes | |
| struct | fastmm::venues::RestChannelConfig |
| class | fastmm::venues::RestChannel |
Namespaces | |
| namespace | fastmm |
| namespace | fastmm::venues |
Enumerations | |
| enum class | fastmm::venues::RestLane : std::uint8_t { fastmm::venues::Control = 0 , fastmm::venues::Orders = 1 } |
Functions | |
| constexpr std::size_t | fastmm::venues::rest_queue_for (std::size_t symbols) noexcept |
Queue room for a connector's REST channel with symbols subscribed: every connector fans some requests out per symbol (cancel-all, the USDⓈ-M countdown, execution and funding replays), and those can overlap, on top of a fixed set (reconciliation, clock, listen key, the dead man's switch, orders falling back to REST). | |
| template<class Cfg > | |
| RestChannelConfig | fastmm::venues::rest_channel_config (const Cfg &cfg, std::size_t symbols) |
| The RestChannelConfig every connector config spells the same way. | |
RestChannel: reactor-driven keep-alive HTTP(S) for the venue requests that run on the net thread (depth snapshots, openOrders, execution replays, listenKey keepalive, and the order traffic that goes over REST: orders falling back from the WebSocket, cancel-all, dead man's switch refreshes).
HTTP/1.1 answers one request at a time per connection, so a channel with one connection makes a cancel wait for every snapshot and replay page queued ahead of it. The channel therefore has two lanes, each with its own connection and queue:
RestLane::Control everything else: reference data, snapshots, reconciliation, replays RestLane::Orders orders, cancels and the requests that keep orders safe (cancel-all, the dead man's switch): they wait for nothing but each other
A lane hands its client one request at a time and keeps the rest. When a connection that was up fails, only the request on it fails; the ones behind it go out on the next connection. When a connection cannot be made (refused, TLS failure, connect timeout, no address), every request of the lane fails with that error and the host is resolved again for the next attempt, so a venue that moved its addresses is found again. Lookups run off the net thread (net::AsyncResolver): the first starts when the channel is made.
With endpoint selection (net/endpoint_selector.hpp, select_endpoint) the lookups also probe the host's addresses and each connection goes to the fastest; an address a connection could not be made to is passed over by the next. A lane keeps its connection while it lasts: it moves to a faster address when it next connects.
Requests are std::function/std::string based: control path only.