Skip to content

Commit c11a3df

Browse files
committed
Cache db pools, run pragma statements in separate queries
1 parent 4ea081a commit c11a3df

File tree

16 files changed

+315
-244
lines changed

16 files changed

+315
-244
lines changed

pegasus/lib/api/admin_/users.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ let post_handler =
183183
~perm:0o644
184184
in
185185
let%lwt repo =
186-
Repository.load ~write:true ~create:true
186+
Repository.load ~create:true
187187
~ds:ctx.db new_did
188188
in
189189
let%lwt _ =

pegasus/lib/api/repo/describeRepo.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let handler =
2525
"at://%s"
2626
(fun h -> h)
2727
in
28-
let%lwt repo = Repository.load ~write:false did in
28+
let%lwt repo = Repository.load did in
2929
let%lwt collections = Repository.list_collections repo in
3030
Dream.json @@ Yojson.Safe.to_string
3131
@@ response_to_yojson

pegasus/lib/api/repo/importRepo.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ let handler =
1313
let did = Auth.get_authed_did_exn ctx.auth in
1414
let bytes_stream = Dream.body_stream ctx.req in
1515
let car_stream = stream_to_seq bytes_stream in
16-
let%lwt repo =
17-
Repository.load did ~ds:ctx.db ~ensure_active:true ~write:true
18-
in
16+
let%lwt repo = Repository.load did ~ds:ctx.db ~ensure_active:true in
1917
let%lwt result = Repository.import_car repo car_stream in
2018
match result with
2119
| Ok _ ->

pegasus/lib/api/server/checkAccountStatus.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let handler =
1818
Errors.internal_error ~msg:"actor not found" ()
1919
| Some actor -> (
2020
let%lwt {db= us; commit; _} =
21-
Repository.load ~write:false ~ds:db did
21+
Repository.load ~ds:db did
2222
in
2323
let%lwt cid, commit =
2424
match commit with

pegasus/lib/api/server/createAccount.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ let create_account ~email ~handle ~password ?invite_code ?did ?recovery_key db =
120120
~perm:0o644
121121
in
122122
let%lwt repo =
123-
Repository.load ~write:true ~create:true ~ds:db did
123+
Repository.load ~create:true ~ds:db did
124124
in
125125
let%lwt _ = Repository.put_initial_commit repo in
126126
let%lwt _ = Sequencer.sequence_identity db ~did ~handle () in

pegasus/lib/api/sync/getBlob.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let handler =
55
let {did; cid} = Xrpc.parse_query ctx.req query_of_yojson in
66
let cid_parsed = Cid.as_cid cid in
77
let%lwt {db; _} =
8-
Repository.load did ~ensure_active:true ~write:false ~ds:ctx.db
8+
Repository.load did ~ensure_active:true ~ds:ctx.db
99
in
1010
let%lwt blob_meta = User_store.get_blob_metadata db cid_parsed in
1111
match blob_meta with

pegasus/lib/api/sync/getBlocks.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let handler =
55
Xrpc.handler (fun ctx ->
66
let {did; cids} : query = Xrpc.parse_query ctx.req query_of_yojson in
77
let%lwt {db; commit; _} =
8-
Repository.load did ~ensure_active:true ~write:false ~ds:ctx.db
8+
Repository.load did ~ensure_active:true ~ds:ctx.db
99
in
1010
let commit_cid, commit_signed = Option.get commit in
1111
let commit_block =

pegasus/lib/api/sync/getLatestCommit.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let handler =
66
Xrpc.handler (fun ctx ->
77
let {did} : query = Xrpc.parse_query ctx.req query_of_yojson in
88
match%lwt
9-
Repository.load did ~ensure_active:true ~write:false ~ds:ctx.db
9+
Repository.load did ~ensure_active:true ~ds:ctx.db
1010
with
1111
| {commit= Some (cid, {rev; _}); _} ->
1212
let cid = Cid.to_string cid in

pegasus/lib/api/sync/getRecord.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let handler =
1010
in
1111
let path = collection ^ "/" ^ rkey in
1212
let%lwt repo =
13-
Repository.load did ~ensure_active:true ~write:false ~ds:ctx.db
13+
Repository.load did ~ensure_active:true ~ds:ctx.db
1414
in
1515
match%lwt Repository.get_record repo path with
1616
| None ->

pegasus/lib/api/sync/getRepo.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ type query = {did: string} [@@deriving yojson {strict= false}]
33
let handler =
44
Xrpc.handler (fun ctx ->
55
let {did} : query = Xrpc.parse_query ctx.req query_of_yojson in
6-
let%lwt repo = Repository.load did ~ensure_active:true ~write:false in
6+
let%lwt repo = Repository.load did ~ensure_active:true in
77
let%lwt car_stream = Repository.export_car repo in
88
Dream.stream
99
~headers:[("Content-Type", "application/vnd.ipld.car")]

0 commit comments

Comments
 (0)