aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAdelyn Breelove <[email protected]>2019-02-04 14:43:17 -0700
committerAdelyn Breelove <[email protected]>2019-02-04 14:43:17 -0700
commitca3c00d8d16f36bc959f5e1ca628aeffc4326492 (patch)
tree628a30c88b84274ac28572f5e85ed78d428471a5 /lib
parentOof, put CI script change in wrong job (diff)
downloaddisml-ca3c00d8d16f36bc959f5e1ca628aeffc4326492.tar.xz
disml-ca3c00d8d16f36bc959f5e1ca628aeffc4326492.zip
Move large_threshold to shard storage, as it isn't needed elsewhere
Diffstat (limited to 'lib')
-rw-r--r--lib/client.ml3
-rw-r--r--lib/client_options.ml3
-rw-r--r--lib/client_options.mli3
-rw-r--r--lib/sharder.ml10
-rw-r--r--lib/sharder.mli3
5 files changed, 12 insertions, 10 deletions
diff --git a/lib/client.ml b/lib/client.ml
index a278d5a..97a736b 100644
--- a/lib/client.ml
+++ b/lib/client.ml
@@ -7,8 +7,7 @@ type t = {
let start ?count ?compress ?(large=250) token =
Client_options.token := token;
- Client_options.large_threshold := large;
- Sharder.start ?count ?compress ()
+ Sharder.start ?count ?compress ~large_threshold:large ()
>>| fun sharder ->
{ sharder; }
diff --git a/lib/client_options.ml b/lib/client_options.ml
index 0b52006..0571fea 100644
--- a/lib/client_options.ml
+++ b/lib/client_options.ml
@@ -1,2 +1 @@
-let token = ref ""
-let large_threshold = ref 250 \ No newline at end of file
+let token = ref "" \ No newline at end of file
diff --git a/lib/client_options.mli b/lib/client_options.mli
index 42d3eee..edf80e1 100644
--- a/lib/client_options.mli
+++ b/lib/client_options.mli
@@ -1,3 +1,2 @@
(** Token that is set when using {!Client.start} *)
-val token : string ref
-val large_threshold : int ref \ No newline at end of file
+val token : string ref \ No newline at end of file
diff --git a/lib/sharder.ml b/lib/sharder.ml
index c33504f..b613399 100644
--- a/lib/sharder.ml
+++ b/lib/sharder.ml
@@ -35,6 +35,7 @@ module Shard = struct
id: int * int;
hb_interval: Time.Span.t Ivar.t;
hb_stopper: unit Ivar.t;
+ large_threshold: int;
pipe: Frame.t Pipe.Reader.t * Frame.t Pipe.Writer.t;
ready: unit Ivar.t;
seq: int;
@@ -157,7 +158,7 @@ module Shard = struct
"$browser", `String "dis.ml";
];
"compress", `Bool shard.compress;
- "large_threshold", `Int !Client_options.large_threshold;
+ "large_threshold", `Int shard.large_threshold;
"shard", `List shards;
] in
push_frame ~payload ~ev:IDENTIFY shard
@@ -224,7 +225,7 @@ module Shard = struct
uri)
- let create ~url ~shards ?(compress=true) () =
+ let create ~url ~shards ?(compress=true) ?(large_threshold=100) () =
let open Core in
let uri = (url ^ "?v=6&encoding=json") |> Uri.of_string in
let extra_headers = Http.Base.process_request_headers () in
@@ -257,6 +258,7 @@ module Shard = struct
id = shards;
session = None;
url;
+ large_threshold;
compress;
_internal = (net_to_ws, ws_to_net);
}
@@ -294,7 +296,7 @@ type t = {
shards: (Shard.shard Shard.t) list;
}
-let start ?count ?compress () =
+let start ?count ?compress ?large_threshold () =
let module J = Yojson.Safe.Util in
Http.get_gateway_bot () >>= fun data ->
let data = match data with
@@ -329,7 +331,7 @@ let start ?count ?compress () =
match l with
| (id, total) when id >= total -> return a
| (id, total) ->
- Shard.create ~url ~shards:(id, total) ?compress ()
+ Shard.create ~url ~shards:(id, total) ?compress ?large_threshold ()
>>= fun shard ->
let t = Shard.{ state = shard; } in
let _ = Ivar.read t.state.hb_interval >>> fun hb ->
diff --git a/lib/sharder.mli b/lib/sharder.mli
index 53ab280..e00ad14 100644
--- a/lib/sharder.mli
+++ b/lib/sharder.mli
@@ -13,6 +13,7 @@ type t
val start :
?count:int ->
?compress:bool ->
+ ?large_threshold:int ->
unit ->
t Deferred.t
@@ -24,6 +25,7 @@ module Shard : sig
id: int * int; (** A tuple as expected by Discord. First element is the current shard index, second element is the total shard count. *)
hb_interval: Time.Span.t Ivar.t; (** Time span between heartbeats, wrapped in an Ivar. *)
hb_stopper: unit Ivar.t; (** Stops the heartbeat sequencer when filled. *)
+ large_threshold: int; (** Minimum number of members needed for a guild to be considered large. *)
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. *)
seq: int; (** Current sequence number *)
@@ -61,6 +63,7 @@ module Shard : sig
url:string ->
shards:int * int ->
?compress:bool ->
+ ?large_threshold:int ->
unit ->
shard Deferred.t