An embedded, single-file key-value store for OCaml, inspired by BoltDB and LMDB.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: errors & alcotest scaffold

+117 -7
+10
.ocamlformat
··· 1 + profile = janestreet 2 + 3 + margin = 100 4 + doc-comments-padding = 100 5 + exp-grouping = preserve 6 + break-string-literals = never 7 + 8 + module-item-spacing = preserve 9 + exp-grouping = preserve 10 + sequence-blank-line = preserve
+9 -5
dune-project
··· 10 10 (documentation https://url/to/documentation) 11 11 (package 12 12 (name lithos) 13 - (synopsis "A short synopsis") 14 - (description "A longer description") 15 - (depends ocaml) 16 - (tags 17 - ("add topics" "to describe" your project))) 13 + (synopsis "Embedded key-value database inspired by BoltDB") 14 + (description "Lithos is an embedded, transactional key-value database written in OCaml. It provides MVCC with single-writer/multi-reader semantics and a functional API.") 15 + (depends 16 + (ocaml (>= 4.14)) 17 + dune 18 + (cmdliner (>= 1.2.0)) 19 + (alcotest :with-test) 20 + (odoc :with-doc)) 21 + (tags (database "key-value" embedded transactional MVCC))) 18 22 19 23 ; See https://dune.readthedocs.io/en/stable/reference/dune-project/index.html
+2 -1
lib/dune
··· 1 1 (library 2 - (name lithos)) 2 + (name lithos) 3 + (libraries unix))
+16
lib/error.ml
··· 1 + (** Error types for Lithos database operations *) 2 + 3 + type t = 4 + | IO_error of string 5 + | Invalid_database of string 6 + | Database_locked 7 + | Not_found 8 + 9 + let to_string = function 10 + | IO_error msg -> Printf.sprintf "I/O error: %s" msg 11 + | Invalid_database msg -> Printf.sprintf "Invalid database: %s" msg 12 + | Database_locked -> "Database is locked" 13 + | Not_found -> "Not found" 14 + ;; 15 + 16 + let of_unix_error err path = IO_error (Printf.sprintf "%s: %s" (Unix.error_message err) path)
+13
lib/error.mli
··· 1 + (** Error types for Lithos database operations *) 2 + 3 + type t = 4 + | IO_error of string 5 + | Invalid_database of string 6 + | Database_locked 7 + | Not_found 8 + 9 + (** Convert error to human-readable string *) 10 + val to_string : t -> string 11 + 12 + (** Create an I/O error from a Unix error *) 13 + val of_unix_error : Unix.error -> string -> t
+35
lithos.opam
··· 1 + # This file is generated by dune, edit dune-project instead 2 + opam-version: "2.0" 3 + synopsis: "Embedded key-value database inspired by BoltDB" 4 + description: 5 + "Lithos is an embedded, transactional key-value database written in OCaml. It provides MVCC with single-writer/multi-reader semantics and a functional API." 6 + maintainer: ["Owais J <desertthunder.dev@gmail.com>"] 7 + authors: ["Owais J <desertthunder.dev@gmail.com>"] 8 + license: "MIT" 9 + tags: ["database" "key-value" "embedded" "transactional" "MVCC"] 10 + homepage: "https://github.com/desertthunder/lithos" 11 + doc: "https://url/to/documentation" 12 + bug-reports: "https://github.com/desertthunder/lithos/issues" 13 + depends: [ 14 + "ocaml" {>= "4.14"} 15 + "dune" {>= "3.18"} 16 + "cmdliner" {>= "1.2.0"} 17 + "alcotest" {with-test} 18 + "odoc" {with-doc} 19 + ] 20 + build: [ 21 + ["dune" "subst"] {dev} 22 + [ 23 + "dune" 24 + "build" 25 + "-p" 26 + name 27 + "-j" 28 + jobs 29 + "@install" 30 + "@runtest" {with-test} 31 + "@doc" {with-doc} 32 + ] 33 + ] 34 + dev-repo: "git+https://github.com/desertthunder/lithos.git" 35 + x-maintenance-intent: ["(latest)"]
+2 -1
test/dune
··· 1 1 (test 2 - (name test_lithos)) 2 + (name test_lithos) 3 + (libraries lithos alcotest))
+27
test/test_error.ml
··· 1 + (** Tests for Error module *) 2 + 3 + let test_to_string () = 4 + let open Lithos.Error in 5 + Alcotest.(check string) 6 + "IO_error message" 7 + "I/O error: file not found" 8 + (to_string (IO_error "file not found")); 9 + Alcotest.(check string) 10 + "Invalid_database message" 11 + "Invalid database: bad header" 12 + (to_string (Invalid_database "bad header")); 13 + Alcotest.(check string) "Database_locked message" "Database is locked" (to_string Database_locked); 14 + Alcotest.(check string) "Not_found message" "Not found" (to_string Not_found) 15 + ;; 16 + 17 + let test_of_unix_error () = 18 + let open Lithos.Error in 19 + let err = of_unix_error Unix.ENOENT "/tmp/test.db" in 20 + let msg = to_string err in 21 + Alcotest.(check bool) 22 + "Unix error contains path" 23 + true 24 + (String.length msg > 0 && String.contains msg '/') 25 + ;; 26 + 27 + let suite = [ "to_string", `Quick, test_to_string; "of_unix_error", `Quick, test_of_unix_error ]
+3
test/test_lithos.ml
··· 1 + (** Main test suite for Lithos *) 2 + 3 + let () = Alcotest.run "Lithos" [ "Error", Test_error.suite ]