Skip to content

Commit

Permalink
no lwt, no type value (#19)
Browse files Browse the repository at this point in the history
* no lwt, no type value

* adjust docs

* .
  • Loading branch information
hannesm authored Oct 22, 2019
1 parent 4541a10 commit c003a5b
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 105 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.t
script: bash -ex .travis-opam.sh
env:
global:
- PINS="mirage-kv.dev:. mirage-kv-lwt.dev:."
- PACKAGE="mirage-kv"
matrix:
- OCAML_VERSION=4.05 PACKAGE="mirage-kv-lwt"
- OCAML_VERSION=4.06 PACKAGE="mirage-kv-lwt"
- OCAML_VERSION=4.07 PACKAGE="mirage-kv-lwt"
- OCAML_VERSION=4.06
- OCAML_VERSION=4.07
- OCAML_VERSION=4.08
- OCAML_VERSION=4.09
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### v3.0.0 (2019-10-22)

* remove mirage-kv-lwt (#19 @hannesm)
* specialise mirage-kv on Lwt.t and value being string (#19 @hannesm)
* raise lower OCaml bound to 4.06.0 (#19 @hannesm)

### v2.0.0 (2019-02-24)

* Major revision of the `RO` signature:
Expand Down
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
## mirage-kv — MirageOS signatures for key/value devices

mirage-kv provides the [Mirage_kv.RO][ro] and [Mirage_kv.RW][rw]
signatures the MirageOS key/value devices should implement. In addition,
[Mirage_kv_lwt.RO][ro-lwt] and [Mirage_kv_lwt.RW][rw-lwt] are provided where
`io` is constrained to `Lwt.t` and `value` to `string`.
signatures the MirageOS key/value devices should implement.

mirage-kv is distributed under the ISC license.

[ro]: https://mirage.github.io/mirage-kv/mirage-kv/Mirage_kv/module-type-RO/index.html
[rw]: https://mirage.github.io/mirage-kv/mirage-kv/Mirage_kv/module-type-RW/index.html
[ro-lwt]: https://mirage.github.io/mirage-kv/mirage-kv-lwt/Mirage_kv_lwt/index.html#module-type-RO
[rw-lwt]: https://mirage.github.io/mirage-kv/mirage-kv-lwt/Mirage_kv_lwt/index.html#module-type-RW

[![Build Status](https://travis-ci.org/mirage/mirage-kv.svg?branch=master)](https://travis-ci.org/mirage/mirage-kv)

Expand All @@ -26,9 +22,8 @@ instructions.
## Documentation

The documentation and API reference is generated from the source
interfaces. API docs for both [mirage-kv][doc-mirage-kv] and
[mirage-kv-lwt][doc-mirage-kv-lwt] can be consulted online or via `odig
interfaces. API docs for both [mirage-kv][doc-mirage-kv]
can be consulted online or via `odig
doc mirage-kv`.

[doc-mirage-kv]: http://docs.mirage.io/mirage-kv/
[doc-mirage-kv-lwt]: http://docs.mirage.io/mirage-kv-lwt/
4 changes: 0 additions & 4 deletions lwt/dune

This file was deleted.

29 changes: 0 additions & 29 deletions lwt/mirage_kv_lwt.ml

This file was deleted.

29 changes: 0 additions & 29 deletions mirage-kv-lwt.opam

This file was deleted.

5 changes: 3 additions & 2 deletions mirage-kv.opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ build: [
["dune" "runtest" "-p" name] {with-test}
]
depends: [
"ocaml" {>= "4.05.0"}
"ocaml" {>= "4.06.0"}
"dune"
"mirage-device" {>= "1.0.0"}
"mirage-device" {>= "2.0.0"}
"fmt"
"lwt" {>= "4.4.0"}
"alcotest" {with-test}
]
synopsis: "MirageOS signatures for key/value devices"
Expand Down
17 changes: 8 additions & 9 deletions src/mirage_kv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ module type RO = sig
val pp_error: error Fmt.t
include Mirage_device.S
type key = Key.t
type value
val exists: t -> key -> ([`Value | `Dictionary] option, error) result io
val get: t -> key -> (value, error) result io
val list: t -> key -> ((string * [`Value | `Dictionary]) list, error) result io
val last_modified: t -> key -> (int * int64, error) result io
val digest: t -> key -> (string, error) result io
val exists: t -> key -> ([`Value | `Dictionary] option, error) result Lwt.t
val get: t -> key -> (string, error) result Lwt.t
val list: t -> key -> ((string * [`Value | `Dictionary]) list, error) result Lwt.t
val last_modified: t -> key -> (int * int64, error) result Lwt.t
val digest: t -> key -> (string, error) result Lwt.t
end

type write_error = [ error | `No_space | `Too_many_retries of int ]
Expand All @@ -83,7 +82,7 @@ module type RW = sig
include RO
type nonrec write_error = private [> write_error]
val pp_write_error: write_error Fmt.t
val set: t -> key -> value -> (unit, write_error) result io
val remove: t -> key -> (unit, write_error) result io
val batch: t -> ?retries:int -> (t -> 'a io) -> 'a io
val set: t -> key -> string -> (unit, write_error) result Lwt.t
val remove: t -> key -> (unit, write_error) result Lwt.t
val batch: t -> ?retries:int -> (t -> 'a Lwt.t) -> 'a Lwt.t
end
37 changes: 17 additions & 20 deletions src/mirage_kv.mli
Original file line number Diff line number Diff line change
Expand Up @@ -113,33 +113,30 @@ module type RO = sig
type key = Key.t
(** The type for keys. *)

type value
(** The type for values. *)
val exists: t -> key -> ([`Value | `Dictionary] option, error) result Lwt.t
(** [exists t k] is [Some `Value] if [k] is bound to a value in [t],
[Some `Dictionary] if [k] is a prefix of a valid key in [t] and
[None] if no key with that prefix exists in [t].
val exists: t -> key -> ([`Value | `Dictionary] option, error) result io
(** [exists t k] is [Some `Value] if [k] is bound to a value in [t],
[Some `Dictionary] if [k] is a prefix of a valid key in [t] and
[None] if no key with that prefix exists in [t].
{!exists} answers two questions: does the key exist and is it
referring to a value or a dictionary.
{!exists} answers two questions: does the key exist and is it
referring to a value or a dictionary.
An error occurs when the underlying storage layer fails. *)

An error occurs when the underlying storage layer fails. *)
val get: t -> key -> (string, error) result Lwt.t
(** [get t k] is the value bound to [k] in [t].
val get: t -> key -> (value, error) result io
(** [get t k] is the value bound to [k] in [t].
The result is [Error (`Value_expected k)] if [k] refers to a
dictionary in [t]. *)

The result is [Error (`Value_expected k)] if [k] refers to a
dictionary in [t]. *)

val list: t -> key -> ((string * [`Value | `Dictionary]) list, error) result io
val list: t -> key -> ((string * [`Value | `Dictionary]) list, error) result Lwt.t
(** [list t k] is the list of entries and their types in the
dictionary referenced by [k] in [t].
The result is [Error (`Dictionary_expected k)] if [k] refers to a
value in [t]. *)

val last_modified: t -> key -> (int * int64, error) result io
val last_modified: t -> key -> (int * int64, error) result Lwt.t
(** [last_modified t k] is the last time the value bound to [k] in
[t] has been modified.
Expand All @@ -152,7 +149,7 @@ module type RO = sig
time is the latest modification of all entries in that
dictionary. This behaviour is only one level deep and not recursive. *)

val digest: t -> key -> (string, error) result io
val digest: t -> key -> (string, error) result Lwt.t
(** [digest t k] is the unique digest of the value bound to [k] in
[t].
Expand Down Expand Up @@ -190,22 +187,22 @@ module type RW = sig
val pp_write_error: write_error Fmt.t
(** The pretty-printer for [pp_write_error]. *)

val set: t -> key -> value -> (unit, write_error) result io
val set: t -> key -> string -> (unit, write_error) result Lwt.t
(** [set t k v] replaces the binding [k -> v] in [t].
Durability is guaranteed unless [set] is run inside an enclosing
{!batch} operation, where durability will be guaranteed at the
end of the batch. *)

val remove: t -> key -> (unit, write_error) result io
val remove: t -> key -> (unit, write_error) result Lwt.t
(** [remove t k] removes any binding of [k] in [t]. If [k] was bound
to a dictionary, the full dictionary will be removed.
Durability is guaranteed unless [remove] is run inside an
enclosing {!batch} operation, where durability will be guaranteed
at the end of the batch. *)

val batch: t -> ?retries:int -> (t -> 'a io) -> 'a io
val batch: t -> ?retries:int -> (t -> 'a Lwt.t) -> 'a Lwt.t
(** [batch t f] run [f] in batch. Ensure the durability of
operations.
Expand Down

0 comments on commit c003a5b

Please sign in to comment.