Raxol. Gateway. Adapter. Discord. GatewaySocket. Transport behaviour
(RaxolGateway v0.2.0)
Copy Markdown
View Source
The wire seam under Raxol.Gateway.Adapter.Discord.GatewaySocket.
A transport owns the WebSocket mechanics (TCP connect, HTTP upgrade,
frame encode/decode) and surfaces a small event vocabulary; the socket
owns every Discord semantic (heartbeats, identify/resume, sequence
tracking). MintTransport is the production implementation; tests
inject a message-driven fake, so the full socket lifecycle is testable
without a network or mocks.
connect/2 returns as soon as the upgrade request is in flight; the
:upgraded event arrives later through stream/2, which is fed every
process message the socket cannot interpret itself.
Summary
Types
@type conn() :: term()
@type event() :: :upgraded | {:text, String.t()} | {:close, term(), term()} | {:transport_error, term()}
What stream/2 can surface:
:upgraded- the HTTP 101 completed; the WebSocket is open{:text, payload}- one inbound text frame{:close, code, reason}- the server closed the WebSocket{:transport_error, reason}- the connection is unusable
@type url_parts() :: %{ scheme: :ws | :wss, host: String.t(), port: :inet.port_number(), path: String.t() }