Code Monkey home page Code Monkey logo

irmin-server's Introduction

irmin-server

A server for irmin using a custom wire protocol, designed to have minimal overhead.

Command-line

Server

To run the server:

$ dune exec bin/server/server.exe -- --root ./data

Run the server with web-based dashboard on port 9999:

$ dune exec bin/server/server.exe -- --root ./data --dashboard 9999

For more information:

```shell
$ dune exec bin/server/server.exe -- --help

irmin-server accept WebSocket connection. To run the server:

$ dune exec -- ./examples/server.exe --uri=ws://localhost:9090/ws

irmin-server can also be executed using Docker:

$ docker run --env PORT=9999 $(docker build -q .)

Client

irmin-client is a command-line application that can be used to send commands to irmin-server

For a list of available commands:

$ dune exec bin/client/client.exe -- --help

For help with a specific command (for example, ping):

$ dune exec bin/client/client.exe -- ping --help

irmin-client can also send commands to irmin-server via WebSocket. To run an example thats ping the server:

$ dune exec ./examples/ping.exe ws://localhost:9090/ws

Browser

Server

irmin-server accept WebSocket connection which makes communication from a browser possible. To run the server:

$ dune exec -- ./examples/server.exe --uri=ws://localhost:9090/ws

Client

irmin-client-jsoo is a browser application that can be used to send commands to irmin-server via WebSocket
cd into examples/js

$ dune build

To run an example thats ping the server from the browser: Open the file _build/default/examples/js/index.html in the browser

OCaml client

An OCaml client library is provided to interact with the server. Some examples can be found in the examples/ directory.

Docs

See src/irmin-client/client_intf.ml

Protocol

A specification of the wire protocol can be found in PROTOCOL.md

irmin-server's People

Contributors

dinakajoy avatar dinosaure avatar patricoferris avatar zshipko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

irmin-server's Issues

Irmin-server browser support

Browser support for Irmin-server

Problem

There is need to support communication between the browser and irmin-server.
Currently irmin-server uses flows to communicate between the server and the client. Flows are byte-streams like a TCP connection and these are established using Conduit. In the browser, there is currently no mechanism we know of for having a bi-directional, stream-oriented communication channel

The closest thing is a websocket which solves bidirectional communication, but is inherently message-oriented and not stream-oriented. Websockets sound like a good solution but it could be implemented in a few different ways.

Solutions

A conduit-like flow using websockets

One solution is to impose a stream-like structure layered on top of the message-oriented websocket connection. This could look like the following for example:

let websocket_handler server client =
    let flow = Obj.magic () in (* BAD! *)
    let rec fill_ic channel client =
      let* frame = Websocket_lwt_unix.Connected_client.recv client in
      Lwt_io.write channel frame.content >>= fun () ->
      fill_ic channel client
    in
    let rec send_oc channel client =
      Lwt_io.read channel >>= fun content ->
      Websocket_lwt_unix.Connected_client.send client (Websocket.Frame.create ~content ()) >>= fun () ->
      send_oc channel client
    in
    let input_ic, input_oc = Lwt_io.pipe () in
    let output_ic, output_oc = Lwt_io.pipe () in
    Lwt.async (fun () -> fill_ic input_oc client);
    Lwt.async (fun () -> send_oc output_ic client);
    callback server flow input_ic output_oc

Although it is unclear if this will be sufficient but the basic idea is to have two pipes for reading and writing. When we receive a websocket message we add it to the reading channel and when we send a message we add it to the writing channel.

Reimplement protocol but with message-oriented

Going this route means that most features has to be reimplemented to support a message-oriented communication
1. The IO module - The IO module currently uses Conduit_lwt_unix, which communicates using flow.
2. The protocol - The protocol is currently structured around conn_intf which calls the IO module which uses flow.

Questions

  1. What would the API look like if we support a message-oriented and stream-oriented communication.

Fix memory issues when replaying tezos traces

When over 30,000 commits are replayed it looks like the server is being killed because it's running out of memory. A smarter way of managing trees on the server should fix this.

Release after next major irmin release (3.0)

It would be nice to release this after Irmin 3.0 is released.

TODO

  • Ensure compatibility with Irmin
  • Implement Irmin.S using Irmin_client (#34)
  • Fix irmin slow tests
  • Add more tests (Irmin_client.Store, replicate command, ...)

Get `irmin-test` running in the browser

I have this partially working and it reveals that websockets from the browser don't pass the tests, I'll try to fix the bugs and start upstreaming all of the various changes needed to put irmin-test in the browser.

Unify `Client` and `Store` APIs

Currently there are two different APIs that require two different sets of commands to implement. It seems like a good idea to focus on the Store client API with some additional functions (ping, reconnect, ...)

This would require:

  • Removing a lot of the existing commands not found in command_backend.ml
  • Moving some functionality from Irmin_client.Make to Irmin_client.Store.Make
  • Removing unused functionality from irmin-server-internal
  • Porting Batch API to Store client

Avoid base64 encoding for websockets

It should be possible to use Blob or Uint8Array on the Javascript side to support binary websockets, which would make it possible to remove the base64 encoding that websocket payloads go through.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.