Git Product home page Git Product logo

irmin-indexeddb's Introduction

Irmin-IndexedDB

Copyright Thomas Leonard, 2020

This is an Irmin backend that stores the data in the web-browser's IndexedDB store.

Instructions

You'll need to pin a fixed version of irmin-git first:

opam pin add -yn irmin-git.2.0.0 https://github.com/talex5/irmin.git#2.0.0-cuekeeper

Also, until mirage/encore#13 is fixed, you'll need to link with helpers.js to add a missing stub.

You can create stores using either the standard Git format, or using Irmin's own format. For Git format (you'll need to add irmin-git as a dependency), use:

(* A Git-format store. This data can be exported and used with the regular Git
   tools. It can also read data produced by older versions of irmin-indexeddb. *)
module I = Irmin_git.Generic(Irmin_indexeddb.Content_store)(Irmin_indexeddb.Branch_store)
    (Irmin.Contents.String)(Irmin.Path.String_list)(Irmin.Branch.String)

For Irmin format, use:

(* An Irmin-format store. This allows storing custom metadata or using
   different hash functions, but is not compatible with the Git tools or with
   databases created by older versions of irmin-indexeddb. *)
module I = Irmin.Make(Irmin_indexeddb.Content_store)(Irmin_indexeddb.Branch_store)
    (Irmin.Metadata.None)(Irmin.Contents.String)
    (Irmin.Path.String_list)(Irmin.Branch.String)(Irmin.Hash.SHA256)

To create a store, use e.g.

let () =
  let config = Irmin_IDB.config "MyProg" in
  I.v config make_task >>= fun store ->
  ...

The argument to Irmin_IDB.config is the name of the database to use (default "Irmin").

Note: In order to provide notifications (to instances running in other tabs), the backend will also write the current branch head hash into HTML local storage.

Bugs

Please any send questions or comments to the mirage mailing list:

http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel

Bugs can be reported on the mailing list or as GitHub issues:

https://github.com/talex5/irmin-indexeddb/issues

Conditions

See LICENSE.md.

irmin-indexeddb's People

Contributors

talex5 avatar kit-ty-kate avatar

Stargazers

 avatar Lin Oshitani avatar Patrick Ferris avatar David Sancho avatar  avatar savi2w avatar Sora Morimoto avatar ngoguey avatar Varun Kohli avatar zach avatar Chiantine P. Manigos avatar Bob Poekert avatar Joseph Price avatar Askar Yusupov avatar Jeff Carpenter avatar  avatar Arnau Siches avatar A ghost. avatar Marcello Seri avatar Paul Laforgue avatar Helder S Ribeiro avatar David.Gao avatar Andrejs Agejevs avatar Kamil Chmielewski avatar Gabriel Aires Guedes avatar Hannes Mehnert avatar KC Sivaramakrishnan avatar Stéphane Legrand avatar NP avatar Xavier Van de Woestyne avatar Vasilis Papavasileiou avatar Magnus Skjegstad avatar Rudi Grinberg avatar Thomas Gazagnaire avatar Anil Madhavapeddy avatar Seb Mondet avatar

Watchers

Anil Madhavapeddy avatar Thomas Gazagnaire avatar Hannes Mehnert avatar  avatar James Cloos avatar Varun Kohli avatar Kamil Chmielewski avatar ngoguey avatar Gabriel Aires Guedes avatar collecting MirageOS relevant repositories (feed: see URL) avatar  avatar

irmin-indexeddb's Issues

Irmin's binary format has changed in an incompatible way

Broken by #2. This is actually detected by the tests, but they're not run automatically as they require a browser:

Irmin-IndexedDB test
Deleting any previous test databases...
Created basic store. Checking it is empty...
Got [], as expected
Added test item. Reading it back...
Got value, as expected
Listing contents...
Got [/key], as expected
Head: fcfbcd4957fe4cfd2b6f43e1ec3dbe8981915f64
Parent: 233509c3580c21aa06502f05b3f9dff985878247
Dumping DB contents...
let ao = [
  "fcfbcd4957fe4cfd2b6f43e1ec3dbe8981915f64", "\020\2313,\190^\031\017\235\150\156\177N\139\001\155\209<\152\243^\000\253\160\208gX\000\004User\001\004test";
  "f32b67c7e26342af42efabc674d441dca0a281c5", "value";
  "e7332cbe5e1f11eb969cb14e8b019bd13c98f35e", "\001\003key\000\020\243+g\199\226cB\175B\239\171\198t\212A\220\160\162\129\197\000";
  "5ba93c9db0cff93f52b521d7420e43f6eda2784f", "\000";
  "47c6285c0e710635ab141fb75d4ee7d20b335e84", "\001\003key\000\020C\247\1709\015\026\002e\252-\231\001\0013\149\028\007\024\166~\000";
  "43f7aa390f1a0265fc2de7010133951c0718a67e", "value2";
  "233509c3580c21aa06502f05b3f9dff985878247", "\020G\198(\\\014q\0065\171\020\031\183]N\231\210\0113^\132\001\020\252\251\205IW\254L\253+oC\225\236=\190\137\129\145_d\253\160\208gX\000\004User\001\004test";
]
let rw = [
  "master", "\020#5\t\195X\012!\170\006P/\005\179\249\223\249\133\135\130G";
]
Testing ability to read v1 format db
ERROR: Ir_hash.Invalid(�)

The problem seems to be due to mirage/irmin#347, which added metadata to the entries. That shouldn't have mattered, since the default is Ir_hum.Unit but unfortunately bin_prot actually writes out data for (): https://github.com/janestreet/bin_prot/blob/b7bc5e0ba96d3df5d0108d0bdcfed67cfcbe63f4/src/size.ml#L89

let bin_size_unit () = 1

Upgrade to Irmin 1.0 API

Not exactly sure how to do this. It doesn't seem to be mentioned in the Irmin changelog, but it appears that Irmin 1.0 changed the binary format again (from bit_prot to JSON). Will take a bit more work to handle this...

/cc @samoht

Standalone IndexedDB binding

The IndexedDB binding (especially Iridb_lwt) looks nice. It will be great if you can make it usable in its own right. What I have in mind is a small package that doesn't have the Irmin dependencies.

I am experimenting with this in the context of Eliom. I currently rely on a messy patch to export the necessary modules, and put the Irmin-specific part under irmin_indexeddb.irmin.

For the above use case, it would be helpful if the API were a bit lower-level by using Js.string instead of string. We could then use Js_of_ocaml's Json module without unnecessary conversions.

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.