-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
512 additions
and
1,985 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.