aboutsummaryrefslogtreecommitdiffstats
path: root/lib/management/physical.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/management/physical.ml')
-rw-r--r--lib/management/physical.ml28
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/management/physical.ml b/lib/management/physical.ml
index 3fc2cf7..0f26bca 100644
--- a/lib/management/physical.ml
+++ b/lib/management/physical.ml
@@ -9,10 +9,12 @@
(** Backend module signature that any storage driver must implement *)
module type BACKEND = sig
+ include Configuration.CONFIGURABLE
+
type connection
type error
- val connect : unit -> (connection, error) result
+ val connect : configuration -> (connection, error) result
(** Connect to the storage backend *)
val disconnect : connection -> unit
@@ -47,10 +49,12 @@ end
(** Storage operations built on top of a backend *)
module type S = sig
+ include Configuration.CONFIGURABLE
+
type t
type error
- val create : unit -> (t, error) result
+ val create : configuration -> (t, error) result
(** Create a storage instance from a backend connection *)
val close : t -> unit
@@ -80,11 +84,14 @@ module type S = sig
end
(** Functor to create storage operations from a backend *)
-module Make (B : BACKEND) : S with type error = B.error = struct
+module Make (B : BACKEND) :
+ S with type error = B.error and type configuration = B.configuration = struct
+ type configuration = B.configuration
type t = B.connection
type error = B.error
- let create () = B.connect ()
+ let parse = B.parse
+ let create config = B.connect config
let close = B.disconnect
let store_attribute conn value =
@@ -115,7 +122,10 @@ module Make (B : BACKEND) : S with type error = B.error = struct
end
(** In-memory backend for testing and development *)
-module MemoryBackend : BACKEND with type error = string = struct
+module MemoryBackend :
+ BACKEND with type error = string and type configuration = unit = struct
+ type configuration = unit
+
type connection = {
data : (string, bytes) Hashtbl.t;
mutable in_transaction : bool;
@@ -124,6 +134,14 @@ module MemoryBackend : BACKEND with type error = string = struct
type error = string
+ let parse sexp =
+ match sexp with
+ | Sexplib.Sexp.List [] -> Ok ()
+ | _ ->
+ Error
+ (Printf.sprintf "memory backend takes no configuration, got: %s"
+ (Sexplib.Sexp.to_string sexp))
+
let connect () =
Ok
{