···4141Pds.put repo ~collection:"app.bsky.feed.post" ~rkey:"abc123" record_bytes;
42424343(* Read records *)
4444-let data = Pds.get repo ~collection:"app.bsky.feed.post" ~rkey:"abc123" in
4444+let data = Pds.find repo ~collection:"app.bsky.feed.post" ~rkey:"abc123" in
45454646(* List collection *)
4747let records = Pds.list repo ~collection:"app.bsky.feed.post" in
···70707171### Records
72727373-- `Pds.get t ~collection ~rkey` - Read a record
7373+- `Pds.find t ~collection ~rkey` - Read a record
7474- `Pds.put t ~collection ~rkey data` - Write a record
7575- `Pds.delete t ~collection ~rkey` - Delete a record
7676- `Pds.list t ~collection` - List records in a collection
+1-1
lib/blob_store.ml
···4040 let size = Int64.of_int (String.length data) in
4141 { Atp.Blob_ref.cid; mime_type; size }
42424343-let get t cid =
4343+let find t cid =
4444 let path = blob_path t cid in
4545 try Some (Eio.Path.load path)
4646 with Eio.Io (Eio.Fs.E (Eio.Fs.Not_found _), _) -> None
+2-2
lib/blob_store.mli
···2323val put : t -> mime_type:string -> string -> Atp.Blob_ref.t
2424(** [put t ~mime_type data] stores [data] and returns a blob reference. *)
25252626-val get : t -> Atp.Cid.t -> string option
2727-(** [get t cid] retrieves blob data by CID. *)
2626+val find : t -> Atp.Cid.t -> string option
2727+(** [find t cid] retrieves blob data by CID. *)
28282929val delete : t -> Atp.Cid.t -> unit
3030(** [delete t cid] removes a blob. *)
+2-2
lib/pds.ml
···108108109109(* Records *)
110110111111-let get t ~collection ~rkey =
111111+let find t ~collection ~rkey =
112112 match checkout t with
113113 | None -> None
114114 | Some mst -> (
···159159(* Blobs *)
160160161161let put_blob t ~mime_type data = Blob_store.put t.blobs ~mime_type data
162162-let blob t cid = Blob_store.get t.blobs cid
162162+let blob t cid = Blob_store.find t.blobs cid
163163164164(* CAR Import/Export *)
165165
+2-2
lib/pds.mli
···5353 Records are stored in the MST with keys of the form [collection/rkey], e.g.,
5454 ["app.bsky.feed.post/abc123"]. *)
55555656-val get : t -> collection:string -> rkey:string -> string option
5757-(** [get t ~collection ~rkey] reads a record's DAG-CBOR bytes. *)
5656+val find : t -> collection:string -> rkey:string -> string option
5757+(** [find t ~collection ~rkey] reads a record's DAG-CBOR bytes. *)
58585959val put : t -> collection:string -> rkey:string -> string -> unit
6060(** [put t ~collection ~rkey data] writes a record (DAG-CBOR bytes). Creates a
+8-8
test/test_blob_store.ml
···3434 let store = Pds.Blob_store.v path in
3535 let data = "Hello, blob store!" in
3636 let blob_ref = Pds.Blob_store.put store ~mime_type:"text/plain" data in
3737- let result = Pds.Blob_store.get store blob_ref.cid in
3737+ let result = Pds.Blob_store.find store blob_ref.cid in
3838 Alcotest.(check (option string)) "roundtrip data" (Some data) result
39394040let test_put_returns_correct_size () =
···5959 with_temp_dir @@ fun path ->
6060 let store = Pds.Blob_store.v path in
6161 let fake_cid = Atp.Cid.v `Raw "nonexistent data" in
6262- let result = Pds.Blob_store.get store fake_cid in
6262+ let result = Pds.Blob_store.find store fake_cid in
6363 Alcotest.(check (option string)) "missing CID returns None" None result
64646565let test_mem_true_for_stored () =
···9393 Alcotest.(check bool)
9494 "gone after delete" false
9595 (Pds.Blob_store.mem store blob_ref.cid);
9696- let result = Pds.Blob_store.get store blob_ref.cid in
9696+ let result = Pds.Blob_store.find store blob_ref.cid in
9797 Alcotest.(check (option string)) "get after delete returns None" None result
98989999let test_binary_data () =
···103103 let blob_ref =
104104 Pds.Blob_store.put store ~mime_type:"application/octet-stream" data
105105 in
106106- let result = Pds.Blob_store.get store blob_ref.cid in
106106+ let result = Pds.Blob_store.find store blob_ref.cid in
107107 Alcotest.(check (option string)) "binary data preserved" (Some data) result
108108109109let test_multiple_mime_types () =
···128128 (fun (mime_type, data) blob_ref ->
129129 Alcotest.(check string)
130130 "mime type" mime_type blob_ref.Atp.Blob_ref.mime_type;
131131- let result = Pds.Blob_store.get store blob_ref.cid in
131131+ let result = Pds.Blob_store.find store blob_ref.cid in
132132 Alcotest.(check (option string))
133133 (Fmt.str "data for %s" mime_type)
134134 (Some data) result)
···141141 let blob_ref =
142142 Pds.Blob_store.put store ~mime_type:"application/octet-stream" data
143143 in
144144- let result = Pds.Blob_store.get store blob_ref.cid in
144144+ let result = Pds.Blob_store.find store blob_ref.cid in
145145 Alcotest.(check (option string)) "large blob roundtrip" (Some data) result;
146146 Alcotest.(check int64) "large blob size" (Int64.of_int 100_000) blob_ref.size
147147···152152 let blob_ref =
153153 Pds.Blob_store.put store ~mime_type:"application/octet-stream" data
154154 in
155155- let result = Pds.Blob_store.get store blob_ref.cid in
155155+ let result = Pds.Blob_store.find store blob_ref.cid in
156156 Alcotest.(check (option string)) "empty blob roundtrip" (Some data) result;
157157 Alcotest.(check int64) "empty blob size" 0L blob_ref.size
158158···167167 "same CID for same data"
168168 (Atp.Cid.to_string ref1.cid)
169169 (Atp.Cid.to_string ref2.cid);
170170- let result = Pds.Blob_store.get store ref1.cid in
170170+ let result = Pds.Blob_store.find store ref1.cid in
171171 Alcotest.(check (option string)) "still retrievable" (Some data) result
172172173173let test_delete_missing_is_noop () =
+3-3
test/test_pds.ml
···5858 Atp.Dagcbor.encode_string (`Map [ ("text", `String "Hello world") ])
5959 in
6060 Pds.put repo ~collection:"app.bsky.feed.post" ~rkey:"abc123" data;
6161- let result = Pds.get repo ~collection:"app.bsky.feed.post" ~rkey:"abc123" in
6161+ let result = Pds.find repo ~collection:"app.bsky.feed.post" ~rkey:"abc123" in
6262 Alcotest.(check (option string)) "record retrieved" (Some data) result
63636464let test_get_missing_record () =
6565 with_temp_repo @@ fun repo ->
6666 let result =
6767- Pds.get repo ~collection:"app.bsky.feed.post" ~rkey:"nonexistent"
6767+ Pds.find repo ~collection:"app.bsky.feed.post" ~rkey:"nonexistent"
6868 in
6969 Alcotest.(check (option string)) "missing record returns None" None result
7070···7373 let data = Atp.Dagcbor.encode_string (`String "test") in
7474 Pds.put repo ~collection:"test.collection" ~rkey:"key1" data;
7575 Pds.delete repo ~collection:"test.collection" ~rkey:"key1";
7676- let result = Pds.get repo ~collection:"test.collection" ~rkey:"key1" in
7676+ let result = Pds.find repo ~collection:"test.collection" ~rkey:"key1" in
7777 Alcotest.(check (option string)) "deleted record returns None" None result
78787979let test_list_collection () =