aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAdelyn Breelove <[email protected]>2018-11-29 10:29:27 -0700
committerAdelyn Breelove <[email protected]>2018-11-29 10:29:27 -0700
commita1e0eed9739c2006c8012a8a9e0f8cde5f3c250d (patch)
tree8b7c75b0d9e1c8c38fb1761c2b53f28f0519e9a7 /lib
parentMissed a couple things (diff)
downloaddisml-a1e0eed9739c2006c8012a8a9e0f8cde5f3c250d.tar.xz
disml-a1e0eed9739c2006c8012a8a9e0f8cde5f3c250d.zip
Clean up a bit
Diffstat (limited to 'lib')
-rw-r--r--lib/sharder.ml37
1 files changed, 18 insertions, 19 deletions
diff --git a/lib/sharder.ml b/lib/sharder.ml
index 1deae72..7f66b4e 100644
--- a/lib/sharder.ml
+++ b/lib/sharder.ml
@@ -254,33 +254,32 @@ let start ?count token =
| None -> J.(member "shards" data |> to_int)
in
let shard_list = (0, count) in
+ let rec ev_loop t =
+ let (read, _) = t.shard.pipe in
+ Pipe.read read
+ >>| fun frame ->
+ let _ = match parse frame with
+ | Some f -> begin
+ handle_frame ~f t.shard
+ >>> fun shard ->
+ t.shard <- shard;
+ end
+ | None -> t.shard <- recreate t.shard;
+ in
+ t
+ >>= fun t ->
+ List.iter ~f:(fun f -> f t.shard) t.binds;
+ ev_loop t
+ in
let rec gen_shards l a =
match l with
| (id, total) when id >= total -> return a
| (id, total) ->
Shard.create ~url ~shards:(id, total) ~token ()
>>= fun shard ->
- let rec ev_loop t =
- let (read, _) = t.shard.pipe in
- Pipe.read read
- >>| fun frame ->
- let _ = match parse frame with
- | Some f -> begin
- handle_frame ~f t.shard
- >>> fun shard ->
- t.shard <- shard;
- end
- | None -> t.shard <- recreate t.shard;
- in
- t
- >>= fun t ->
- List.iter ~f:(fun f -> f t.shard) t.binds;
- ev_loop t
- in
let t = { shard; binds = []; } in
ev_loop t >>> ignore;
- let a = t :: a in
- gen_shards (id+1, total) a
+ gen_shards (id+1, total) (t :: a)
in
gen_shards shard_list []
>>| fun shards ->