aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAdelyn Breedlove <[email protected]>2019-01-21 20:17:21 -0700
committerAdelyn Breedlove <[email protected]>2019-01-21 20:17:21 -0700
commitee77e43ac06098f6877bf7b3db736b95a56c1be1 (patch)
tree623d784dfc38704e723e256fd0fe3e2e87606a24 /lib
parentimprove the status example (diff)
downloaddisml-ee77e43ac06098f6877bf7b3db736b95a56c1be1.tar.xz
disml-ee77e43ac06098f6877bf7b3db736b95a56c1be1.zip
Docs!
Diffstat (limited to 'lib')
-rw-r--r--lib/sharder.mli25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/sharder.mli b/lib/sharder.mli
index 554ed73..aa040f9 100644
--- a/lib/sharder.mli
+++ b/lib/sharder.mli
@@ -1,30 +1,49 @@
+(** Internal sharding manager. Most of this is accessed through {!Client}. *)
+
+open Core
open Async
+open Websocket_async
exception Invalid_Payload
exception Failure_to_Establish_Heartbeat
type t
+(** Start the Sharder. This is called by {!Client.start}. *)
val start :
?count:int ->
unit ->
t Deferred.t
+(** Module representing a single shard. *)
module Shard : sig
- type shard
+ (** Representation of the state of a shard. *)
+ type shard = {
+ hb_interval: Time.Span.t Ivar.t; (** Time span between heartbeats, wrapped in an Ivar. *)
+ seq: int; (** Current sequence number *)
+ session: string option; (** Session id, if one exists. *)
+ pipe: Frame.t Pipe.Reader.t * Frame.t Pipe.Writer.t; (** Raw frame IO pipe used for websocket communications. *)
+ ready: unit Ivar.t; (** A simple Ivar indicating if the shard has received READY. *)
+ url: string; (** The websocket URL in use. *)
+ id: int * int; (** A tuple as expected by Discord. First element is the current shard index, second element is the total shard count. *)
+ }
+ (** Wrapper around an internal state, used to wrap {!shard}. *)
type 'a t = {
mutable state: 'a;
}
+ (** Send a heartbeat to Discord. This is handled automatically. *)
val heartbeat :
shard ->
shard Deferred.t
+ (** Set the status of the shard. *)
val set_status :
status:Yojson.Safe.json ->
shard ->
shard Deferred.t
+ (** Request guild members for the shard's guild. Causes dispatch of multiple {{!Dispatch.members_chunk}member chunk} events. *)
val request_guild_members :
?query:string ->
?limit:int ->
@@ -32,6 +51,7 @@ module Shard : sig
shard ->
shard Deferred.t
+ (** Create a new shard *)
val create :
url:string ->
shards:int * int ->
@@ -39,16 +59,19 @@ module Shard : sig
shard Deferred.t
end
+(** Calls {!Shard.set_status} for each shard registered with the sharder. *)
val set_status :
status:Yojson.Safe.json ->
t ->
Shard.shard list Deferred.t
+(** Like {!set_status} but takes a function with a {{!Shard.shard}shard} as its parameter and {{!Yojson.Safe.json}json} for its return. *)
val set_status_with :
f:(Shard.shard -> Yojson.Safe.json) ->
t ->
Shard.shard list Deferred.t
+(** Calls {!Shard.request_guild_members} for each shard registered with the sharder. *)
val request_guild_members :
?query:string ->
?limit:int ->