-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate irmin-server #2031
Merged
Merged
Integrate irmin-server #2031
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
9a1244a
Add irmin-server and irmin-client
zshipko a22a140
Add executables and test
zshipko 62e42d4
Add examples for client/server
samoht fe03261
irmin-server example: expose the dashboard on port 1234
samoht 48cb953
Add server command to irmin cli
samoht 77a060c
Fix irmin-client.opam
zshipko 8c5a0c1
Add irmin-server/irmin-client to changelog
samoht 001d081
Make unix/jsoo packages optional
zshipko 3bcea9d
Add more dependencies
zshipko 7770c37
Formatting
zshipko 7e18c09
Add depopts
zshipko c73a44f
Add copyright header
zshipko 1ca919a
Add basic web dashboard
zshipko ff36968
Improvements to dashboard
zshipko 6b20442
Fix irmin-cli tests
zshipko 51f1af7
formatting
zshipko 494d85c
Remove high-level get function to fix atomic tests
zshipko c0f3c8b
fix loading contents on dashboard
zshipko cb78799
Remove optional dependencies
samoht aa11dd8
Use latest Brr
samoht eb45063
Minor changes to the dashboard
samoht aec5e8f
irmin-client: add minimal documentation for the Batch module
samoht 4a34601
start documenting S.Batch
zshipko d593ff2
Update irmin-server/client to use `clear` arg
metanivek 866bdff
irmin-server: do not flush request header write
metanivek bd71dae
irmin-server: remove un-needed clients hash table
metanivek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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,47 @@ | ||
(* | ||
* Copyright (c) 2018-2022 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 | ||
open Lwt.Infix | ||
module Store = Irmin_mem.KV.Make (Irmin.Contents.String) | ||
module Client = Irmin_client_unix.Make (Store) | ||
module Error = Irmin_client.Error | ||
|
||
let main = | ||
let info () = Client.Info.empty in | ||
let uri = Uri.of_string Sys.argv.(1) in | ||
let* client = Client.connect uri in | ||
|
||
let* main = Client.main client in | ||
let* () = Client.set_exn ~info main [ "testing" ] "testing" in | ||
let* head = Client.Branch.get client Client.Branch.main in | ||
let* tree = | ||
Client.Batch.Tree.of_commit client (Client.Commit.hash head) >|= Option.get | ||
in | ||
let* tree = Client.Batch.Tree.add client tree [ "b"; "c" ] "123" in | ||
let* tree = Client.Batch.Tree.add_tree client tree [ "a" ] tree in | ||
let* tree = Client.Batch.Tree.remove client tree [ "testing" ] in | ||
let* commit = Client.Batch.commit ~parents:[ head ] ~info client tree in | ||
let* () = Client.Branch.set client Client.Branch.main commit in | ||
let* foo = Client.get main [ "foo" ] in | ||
let* abc = Client.get main [ "a"; "b"; "c" ] in | ||
let* testing = Client.find main [ "testing" ] in | ||
assert (foo = "bar"); | ||
assert (abc = "123"); | ||
assert (Option.is_none testing); | ||
Lwt_io.printlf "foo => %s\na/b/c => %s" foo abc | ||
|
||
let () = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
(* | ||
* Copyright (c) 2018-2022 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 Irmin_cli | ||
|
||
(* Adding a new content type *) | ||
|
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,40 @@ | ||
(* | ||
* Copyright (c) 2018-2022 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 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 | ||
() | ||
|
||
let main () = | ||
let uri = Uri.of_string Sys.argv.(1) in | ||
let config = Irmin_mem.config () in | ||
let dashboard = `TCP (`Port 1234) in | ||
let* server = Server.v ~uri ~dashboard config in | ||
let () = Format.printf "Listening on %a@." Uri.pp uri in | ||
Server.serve server | ||
|
||
let () = | ||
Lwt_main.run | ||
@@ let* () = init () in | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
opam-version: "2.0" | ||
synopsis: "A client for irmin-server" | ||
maintainer: "Zach Shipko <[email protected]>" | ||
authors: "Zach Shipko <[email protected]>" | ||
license: "ISC" | ||
homepage: "https://github.com/mirage/irmin" | ||
doc: "https://irmin.org" | ||
bug-reports: "https://github.com/mirage/irmin/issues" | ||
depends: [ | ||
"ocaml" {>= "4.08.0"} | ||
"dune" {>= "2.0.0"} | ||
"irmin-server" {= version} | ||
"ipaddr" | ||
"websocket-lwt-unix" | ||
"conduit-lwt-unix" | ||
"lwt-dllist" | ||
"js_of_ocaml-lwt" | ||
"brr" {>= "0.0.4"} | ||
] | ||
build: [ | ||
["dune" "subst"] {pinned} | ||
["dune" "build" "-p" name "-j" jobs] | ||
["dune" "runtest" "-p" name] {with-test} | ||
] | ||
dev-repo: "git+ssh://github.com/mirage/irmin" |
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,30 @@ | ||
opam-version: "2.0" | ||
synopsis: "A high-performance server for Irmin" | ||
maintainer: "Zach Shipko <[email protected]>" | ||
authors: "Zach Shipko <[email protected]>" | ||
license: "ISC" | ||
homepage: "https://github.com/mirage/irmin" | ||
doc: "https://irmin.org" | ||
bug-reports: "https://github.com/mirage/irmin/issues" | ||
depends: [ | ||
"ocaml" {>= "4.08.0"} | ||
"dune" {>= "2.0.0"} | ||
"optint" {>= "0.1.0"} | ||
"irmin" {= version} | ||
"ppx_irmin" {= version} | ||
"uri" | ||
"fmt" | ||
"cmdliner" {>= "1.0.4"} | ||
"logs" {>= "0.7.0"} | ||
"lwt" {>= "5.4.0"} | ||
"conduit-lwt-unix" | ||
"websocket-lwt-unix" | ||
"cohttp-lwt-unix" | ||
"ppx_blob" | ||
] | ||
|
||
build: [ | ||
["dune" "subst"] {pinned} | ||
["dune" "build" "-p" name "-j" jobs] | ||
["dune" "runtest" "-p" name] {with-test} | ||
] |
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 |
---|---|---|
@@ -1,3 +1,19 @@ | ||
(* | ||
* Copyright (c) 2018-2022 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. | ||
*) | ||
|
||
include module type of Cli | ||
(** @inline *) | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zshipko could you describe the rational of
Batch
here? Does it mean thatClient.Tree
always connect to the server whileClient.Batch.Tree
is maintaining a local tree?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, the
Batch
API allows you to manipulate a local tree and send it all at once since the IrminStore
API doesn't give much control over when data will be transferred over the network.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind adding a bit of documentation about this somewhere? Maybe in the corresponding mli?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am in the process of adding some more comments, I will push something up this week