Skip to content

Commit

Permalink
Merge branch 'main' into store-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
clecat authored Oct 4, 2023
2 parents d28e427 + 2e7a6a2 commit c4220c5
Show file tree
Hide file tree
Showing 41 changed files with 512 additions and 1,985 deletions.
11 changes: 9 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- **irmin-client**
- Added `irmin-client` package to connect to `irmin-server` instances (#2031,
@zshipko)
- **irmin**
- Add pretty printers for `Commit`, `Tree`, `Info`, `Status`, `Branch` when
using `utop` (@metanivek, #1839)

### Fixed

Expand All @@ -18,6 +21,10 @@
- **irmin-http**
- Removed `irmin-http` since it is not compatible with generic keys.
`irmin-grapqhl` or `irmin-server` should be used instead. (#1902, @zshipko)
- **irmin**
- Removed stream proofs. We now only have Merkle tree proofs. This simplifies
the maintenance of that part of the code, as ensuring the correct order of
cached IO operations was tricky for stream proofs (#2275, @samoht)

## 3.8.0 (2023-07-06)

Expand All @@ -27,7 +34,7 @@
- Change behavior of `Irmin.Conf.key` to disallow duplicate key names by
default. Add `allow_duplicate` optional argument to override. (#2252,
@metanivek)

- **irmin-pack**
- Add maximum memory as an alternative configuration option, `lru_max_memory`,
for setting LRU capacity. (@metanivek, #2254)
Expand All @@ -48,7 +55,7 @@
- **irmin-cli**
- Changed `--store irf` to `--store fs` to align the CLI with what is
published on the Irmin website (#2243, @wyn)

## 3.7.2 (2023-06-16)

### Fixed
Expand Down
47 changes: 0 additions & 47 deletions examples/client_batch.ml

This file was deleted.

11 changes: 2 additions & 9 deletions examples/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
push
custom_graphql
custom_storage
fold
client_batch
server)
fold)
(libraries
astring
cohttp
Expand All @@ -22,8 +20,6 @@
irmin-graphql.unix
irmin-pack.unix
irmin-watcher
irmin-server.unix
irmin-client.unix
websocket-lwt-unix
conduit-lwt-unix
lwt
Expand All @@ -44,10 +40,7 @@
custom_merge.exe
custom_graphql.exe
fold.exe
gc.exe
custom_storage.exe
client_batch.exe
server.exe))
custom_storage.exe))

(alias
(name runtest)
Expand Down
4 changes: 2 additions & 2 deletions examples/merkle_proofs.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ Here is the signature of `produce_proof`:
val produce_proof :
Store.repo ->
Store.Tree.kinded_key ->
(Store.tree -> (Store.tree * 'a) Lwt.t) ->
(Store.Tree.Proof.tree Store.Tree.Proof.t * 'a) Lwt.t = <fun>
(Store.tree -> (Store.tree * 'a) Lwt.t) -> (Store.Tree.Proof.t * 'a) Lwt.t =
<fun>
```

`produce_proof repo key_before f` is `(proof = { state; hash_before; hash_after }, f_res)`. `f` is invoked once per call to `produce_proof` and `f tree_before` is `(tree_after, f_res)`.
Expand Down
72 changes: 72 additions & 0 deletions examples/server/client.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
(*
* Copyright (c) 2023 Tarides <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)

open Lwt.Syntax

module Client =
Irmin_client_unix.Make_codec (Irmin_server.Conn.Codec.Bin) (Config.Store)

module Info = Irmin_client_unix.Info (Client.Info)

let info msg = Info.v ~author:"tester" msg

let main () =
let* client = Client.connect Config.uri in
let* main = Client.main client in
let* () =
Client.set_exn ~info:(info "set testing") main [ "testing" ] "testing"
in
let* () =
Client.set_exn ~info:(info "set remove") main [ "remove" ] "remove"
in
let* () = Client.remove_exn ~info:(info "remove remove") main [ "remove" ] in
let batch =
Client.Batch.(
v ()
|> add_value [ "a"; "b"; "c" ] "123"
|> add_value [ "foo" ] "bar"
|> remove [ "testing" ])
in
let* c = Client.Batch.apply ~info:(info "apply batch") ~path:[] main batch in
Logs.info (fun l ->
l "Applied batch -> commit %a" Irmin.Type.(pp Client.commit_key_t) c);

let* abc = Client.get main [ "a"; "b"; "c" ] in
assert (String.equal abc "123");

let* foo = Client.get main [ "foo" ] in
assert (foo = "bar");

let* testing = Client.find main [ "testing" ] in
assert (Option.is_none testing);

let* remove = Client.mem main [ "remove" ] in
assert (remove = false);

let* commit = Client.Commit.of_key client c in
let tree = Client.Commit.tree (Option.get commit) in
let* concrete = Client.Tree.to_concrete tree in

Logs.info (fun l -> l "%a" Irmin.Type.(pp Client.Tree.concrete_t) concrete);

Lwt.return_unit

let () =
Fmt_tty.setup_std_outputs ();
Logs.(set_level @@ Some Debug);
Irmin.Export_for_backends.Logging.reporter (module Mtime_clock)
|> Logs.set_reporter;
Lwt_main.run @@ main ()
19 changes: 19 additions & 0 deletions examples/server/config.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(*
* Copyright (c) 2023 Tarides <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)

module Store = Irmin_mem.KV.Make (Irmin.Contents.String)

let uri = Uri.of_string "tcp://localhost:4242"
12 changes: 12 additions & 0 deletions examples/server/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(executables
(names client server)
(libraries
irmin
irmin-client.unix
irmin-server.unix
irmin-git.unix
irmin-pack.unix
logs
unix
fmt.tty
hex))
25 changes: 10 additions & 15 deletions examples/server.ml → examples/server/server.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(*
* Copyright (c) 2018-2022 Tarides <[email protected]>
* Copyright (c) 2023 Tarides <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
Expand All @@ -15,26 +15,21 @@
*)

open Lwt.Syntax
module Store = Irmin_mem.KV.Make (Irmin.Contents.String)
module Server = Irmin_server_unix.Make (Store)

let info () = Irmin.Info.Default.empty

let init () =
let* repo = Store.Repo.v (Irmin_mem.config ()) in
let* main = Store.main repo in
let+ () = Store.set_exn ~info main [ "foo" ] "bar" in
()
module Server =
Irmin_server_unix.Make_ext (Irmin_server.Conn.Codec.Bin) (Config.Store)

let main () =
let uri = Uri.of_string Sys.argv.(1) in
let config = Irmin_mem.config () in
let dashboard = `TCP (`Port 1234) in
let uri = Config.uri in
let* server = Server.v ~uri ~dashboard config in
let () = Format.printf "Listening on %a@." Uri.pp uri in
Logs.debug (fun l -> l "Listening on %a@." Uri.pp uri);
Server.serve server

let () =
Lwt_main.run
@@ let* () = init () in
main ()
Fmt_tty.setup_std_outputs ();
Logs.(set_level @@ Some Debug);
Irmin.Export_for_backends.Logging.reporter (module Mtime_clock)
|> Logs.set_reporter;
Lwt_main.run @@ main ()
2 changes: 1 addition & 1 deletion irmin-cli.opam
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ depends: [
"conduit-lwt"
"conduit-lwt-unix"
"websocket-lwt-unix"
"ppx_blob"
"ppx_blob" {>= "0.7.2"}
"logs"
"uri"
"cmdliner"
Expand Down
3 changes: 3 additions & 0 deletions irmin-client.opam
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ depends: [
"lwt-dllist"
"js_of_ocaml-lwt"
"brr" {>= "0.0.4"}
"fmt" {>= "0.9.0"}
"logs" {>= "0.7.0"}
"lwt" {>= "5.7.0"}
]
build: [
["dune" "subst"] {pinned}
Expand Down
2 changes: 2 additions & 0 deletions irmin-pack-tools.opam
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ depends: [
"irmin-tezos" {= version}
"irmin-pack" {= version}
"irmin-pack" {= version}
"index" {>= "1.6.2"}
"cmdliner" {>= "1.1.0"}
"cmdliner" {>= "1.1.0"}
"notty" {>= "0.2.3"}
"prettree"
"ppx_repr" {>= "0.7.0"}
"ptime"
"hex"
"irmin-test" {with-test & = version}
Expand Down
5 changes: 4 additions & 1 deletion irmin-server.opam
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ depends: [
"conduit-lwt-unix"
"websocket-lwt-unix"
"cohttp-lwt-unix"
"ppx_blob"
"ppx_blob" {>= "0.7.2"}
"digestif" {>= "1.1.4"}
"alcotest-lwt" {>= "1.7.0" & with-test}
"irmin-watcher" {>= "0.5.0" & with-test}
]

build: [
Expand Down
2 changes: 2 additions & 0 deletions irmin-test.opam
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ depends: [
"metrics" {>= "0.2.0"}
"hex" {with-test & >= "1.4.0"}
"vector" {with-test & >= "1.0.0"}
"alcotest" {>= "1.7.0" & with-test}
"qcheck-alcotest" {>= "0.21.1" & with-test}
]

synopsis: "Irmin test suite"
Expand Down
Loading

0 comments on commit c4220c5

Please sign in to comment.