atproto libraries implementation in ocaml
1(** AT Protocol Sync Support.
2
3 This package provides event stream (firehose) subscription and repository
4 synchronization for AT Protocol.
5
6 {2 Firehose Subscription}
7
8 The firehose provides real-time updates from the network:
9
10 {[
11 let config =
12 Firehose.config
13 ~uri:
14 (Uri.of_string
15 "wss://bsky.network/xrpc/com.atproto.sync.subscribeRepos")
16 ()
17 in
18
19 Firehose.subscribe config ~handler:(fun event ->
20 match event with
21 | Firehose.Commit commit ->
22 Printf.printf "Commit from %s\n" commit.repo;
23 true (* continue *)
24 | _ -> true)
25 ]}
26
27 {2 Effect Handler}
28
29 The firehose uses OCaml 5 effects for WebSocket operations. You must provide
30 handlers for the WebSocket effects:
31
32 {[
33 let run_with_ws f =
34 Effect.Deep.match_with f () {
35 retc = (fun x -> x);
36 exnc = raise;
37 effc = fun (type a) (eff : a Effect.t) ->
38 match eff with
39 | Firehose.Ws_connect uri -> Some (fun k -> ...)
40 | Firehose.Ws_recv ws -> Some (fun k -> ...)
41 | Firehose.Ws_close ws -> Some (fun k -> ...)
42 | _ -> None
43 }
44 ]} *)
45
46module Firehose = Firehose
47module Repo_sync = Repo_sync