objective categorical abstract machine language personal data server
65
fork

Configure Feed

Select the types of activity you want to include in your feed.

Abstract out database stuff

futurGH 7528fd88 d50442e3

+31 -31
+6 -31
pegasus/lib/sqlite_blockstore.ml
··· 1 + open Util.Rapper 1 2 open Util.Syntax 2 - include Caqti_type.Std 3 - include Caqti_request.Infix 4 - include Lwt_result.Syntax 5 3 module Block_map = Mist.Storage.Block_map 6 - 7 - module Cid : Rapper.CUSTOM with type t = Cid.t = struct 8 - type t = Cid.t 9 - 10 - let t = 11 - let encode cid = 12 - try Ok (Cid.to_string cid) with e -> Error (Printexc.to_string e) 13 - in 14 - Caqti_type.(custom ~encode ~decode:Cid.of_string string) 15 - end 16 - 17 - module Blob : Rapper.CUSTOM with type t = bytes = struct 18 - type t = bytes 19 - 20 - let t = 21 - let encode blob = 22 - try Ok (Bytes.to_string blob) with e -> Error (Printexc.to_string e) 23 - in 24 - let decode blob = 25 - try Ok (Bytes.of_string blob) with e -> Error (Printexc.to_string e) 26 - in 27 - Caqti_type.(custom ~encode ~decode string) 28 - end 29 4 30 5 type t = {connection: Caqti_lwt.connection} 31 6 ··· 117 92 in 118 93 aux (Ok 0) queries 119 94 95 + let connect db_uri = 96 + let%lwt connection = Util.connect_sqlite db_uri in 97 + let$! () = Queries.create_table connection in 98 + Lwt.return {connection} 99 + 120 100 let get_bytes t cid = 121 101 let$! b_opt = Queries.get_block cid t.connection in 122 102 match b_opt with ··· 163 143 let delete_many t cids = 164 144 let$! deleted = Queries.delete_blocks cids t.connection in 165 145 Lwt.return_ok (List.length deleted) 166 - 167 - let connect db_uri = 168 - let%lwt connection = Util.connect_sqlite db_uri in 169 - let$! () = Queries.create_table connection in 170 - Lwt.return {connection}
+25
pegasus/lib/util.ml
··· 3 3 match%lwt m with Ok x -> f x | Error e -> raise (Caqti_error.Exn e) 4 4 end 5 5 6 + module Rapper = struct 7 + module Cid : Rapper.CUSTOM with type t = Cid.t = struct 8 + type t = Cid.t 9 + 10 + let t = 11 + let encode cid = 12 + try Ok (Cid.to_string cid) with e -> Error (Printexc.to_string e) 13 + in 14 + Caqti_type.(custom ~encode ~decode:Cid.of_string string) 15 + end 16 + 17 + module Blob : Rapper.CUSTOM with type t = bytes = struct 18 + type t = bytes 19 + 20 + let t = 21 + let encode blob = 22 + try Ok (Bytes.to_string blob) with e -> Error (Printexc.to_string e) 23 + in 24 + let decode blob = 25 + try Ok (Bytes.of_string blob) with e -> Error (Printexc.to_string e) 26 + in 27 + Caqti_type.(custom ~encode ~decode string) 28 + end 29 + end 30 + 6 31 let connect_sqlite db_uri = 7 32 let open Syntax in 8 33 match%lwt Caqti_lwt.connect (Uri.of_string db_uri) with