libduvet/gateway/manager
Types
A manager’s setup: its API client, where the gateway is, how long an attempt may take, and whether sessions resume.
pub type Config {
Config(
api: client.RestClient,
router: api_router.ApiRouter,
connect_timeout: Int,
resume: Bool,
platform: option.Option(client_platform.ClientPlatform),
log: fn(Int, String) -> Nil,
feed: feed.Feed,
)
}
Constructors
-
Config( api: client.RestClient, router: api_router.ApiRouter, connect_timeout: Int, resume: Bool, platform: option.Option(client_platform.ClientPlatform), log: fn(Int, String) -> Nil, feed: feed.Feed, )
pub opaque type GatewayManager
What a manager can fail with.
pub type ManagerError {
Destroyed
}
Constructors
-
DestroyedThe manager was destroyed before its shards were online.
Values
pub fn config(api: client.RestClient) -> Config
pub fn connect_all(
manager: GatewayManager,
shard_count: Int,
) -> Result(Nil, ManagerError)
Spawns [shard_count] shards and connects each one: it returns once each has a socket open, trying again while one can’t open, and fails with [Destroyed] if the manager is destroyed first.
pub fn connection(manager: GatewayManager) -> option.Option(Int)
Shard 0’s connection number, or None while it has no socket.
pub fn destroy(manager: GatewayManager) -> Nil
Permanently shuts down all shards and closes the feed.
pub fn feed(manager: GatewayManager) -> feed.Feed
The manager’s feed: every shard’s events, states, resumes, closes and failures, in the order the shard published them.
pub fn retry_now(manager: GatewayManager) -> Bool
Ends each shard’s wait before its next attempt, and answers whether one was waiting.
pub fn send_message(
manager: GatewayManager,
type_: String,
data: json.Json,
) -> Result(Bool, Nil)
Sends an event message through shard 0, when one is connected.
pub fn silence_before_ready(
manager: GatewayManager,
) -> duration.Duration
Shard 0’s silence before its last READY.
pub fn start(config: Config) -> GatewayManager
pub fn want_fresh_session(manager: GatewayManager) -> Nil
Makes each shard’s next identify start a new session, with READY, rather than resume its own.
pub fn with_platform(
config: Config,
platform: client_platform.ClientPlatform,
) -> Config
pub fn with_router(
config: Config,
router: api_router.ApiRouter,
) -> Config