mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-02 13:43:11 +00:00
Update to nim 2 x (#75)
* Add nimbledeps to be sure that dependencies are isolated * Update dependencies to specific commit hashes Signed-off-by: Arnaud <arnaud@status.im> * Add gcsafe pragma Signed-off-by: Arnaud <arnaud@status.im> * Apply method name changes Signed-off-by: Arnaud <arnaud@status.im> * Catch exceptions Signed-off-by: Arnaud <arnaud@status.im> * Cast to nil value because nil cannot be applied directly to distinct pointer Signed-off-by: Arnaud <arnaud@status.im> * Update nim-results to version 0.5.1 Signed-off-by: Arnaud <arnaud@status.im> * Add Nim 2.0.12 to matrix * Increment the version * Update the leveldb dependency * Add versions and commit to dependencies * Introduce nimble.lock Signed-off-by: Arnaud <arnaud@status.im> * Remove .lock and file and direct dependency to nim-results * Update to 2.0.14 * updates nim-leveldbstatic * sets leveldb to v0.2.0 * fix dep versions * remove except Exception, no longer needed * fix dep versions --------- Signed-off-by: Arnaud <arnaud@status.im> Co-authored-by: Ben <thatbenbierens@gmail.com> Co-authored-by: Eric <5089238+emizzle@users.noreply.github.com>
This commit is contained in:
parent
b3d4bd40fc
commit
39000fd4fc
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -23,7 +23,7 @@ jobs:
|
||||
os: windows,
|
||||
shell: msys2
|
||||
}
|
||||
nim: [1.6.18]
|
||||
nim: [2.0.14]
|
||||
name: ${{ matrix.platform.icon }} ${{ matrix.platform.label }} - Nim v${{ matrix.nim }}
|
||||
runs-on: ${{ matrix.platform.os }}-latest
|
||||
steps:
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,3 +11,4 @@ nimcache
|
||||
TODO
|
||||
nimble.develop
|
||||
nimble.paths
|
||||
nimbledeps
|
||||
|
||||
@ -14,3 +14,7 @@ when (NimMajor, NimMinor) > (1, 2):
|
||||
when withDir(thisDir(), system.fileExists("nimble.paths")):
|
||||
include "nimble.paths"
|
||||
# end Nimble config
|
||||
|
||||
when (NimMajor, NimMinor) >= (2, 0):
|
||||
--mm:refc
|
||||
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
mode = ScriptMode.Verbose
|
||||
|
||||
packageName = "datastore"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0"
|
||||
author = "Status Research & Development GmbH"
|
||||
description = "Simple, unified API for multiple data stores"
|
||||
license = "Apache License 2.0 or MIT"
|
||||
|
||||
requires "nim >= 1.2.0",
|
||||
requires "nim >= 2.0.14",
|
||||
"asynctest >= 0.5.2 & < 0.6.0",
|
||||
"chronos >= 4.0.3 & < 5.0.0",
|
||||
"chronos >= 4.0.4 & < 5.0.0",
|
||||
"questionable >= 0.10.15 & < 0.11.0",
|
||||
"sqlite3_abi",
|
||||
"leveldbstatic >= 0.1.6",
|
||||
"stew",
|
||||
"unittest2"
|
||||
"sqlite3_abi >= 3.47.0.0 & < 4.0.0.0",
|
||||
"leveldbstatic >= 0.2.0 & < 0.3.0",
|
||||
"stew >= 0.2.0 & < 0.3.0",
|
||||
"unittest2 >= 0.2.3 & < 0.3.0"
|
||||
|
||||
task coverage, "generates code coverage report":
|
||||
var (output, exitCode) = gorgeEx("which lcov")
|
||||
|
||||
@ -16,22 +16,22 @@ type
|
||||
Modify* = Function[?seq[byte], Future[?seq[byte]]]
|
||||
ModifyGet* = Function[?seq[byte], Future[(?seq[byte], seq[byte])]]
|
||||
|
||||
method has*(self: Datastore, key: Key): Future[?!bool] {.base, locks: "unknown".} =
|
||||
method has*(self: Datastore, key: Key): Future[?!bool] {.base, gcsafe, locks: "unknown".} =
|
||||
raiseAssert("Not implemented!")
|
||||
|
||||
method delete*(self: Datastore, key: Key): Future[?!void] {.base, locks: "unknown".} =
|
||||
method delete*(self: Datastore, key: Key): Future[?!void] {.base, gcsafe, locks: "unknown".} =
|
||||
raiseAssert("Not implemented!")
|
||||
|
||||
method delete*(self: Datastore, keys: seq[Key]): Future[?!void] {.base, locks: "unknown".} =
|
||||
method delete*(self: Datastore, keys: seq[Key]): Future[?!void] {.base, gcsafe, locks: "unknown".} =
|
||||
raiseAssert("Not implemented!")
|
||||
|
||||
method get*(self: Datastore, key: Key): Future[?!seq[byte]] {.base, locks: "unknown".} =
|
||||
method get*(self: Datastore, key: Key): Future[?!seq[byte]] {.base, gcsafe, locks: "unknown".} =
|
||||
raiseAssert("Not implemented!")
|
||||
|
||||
method put*(self: Datastore, key: Key, data: seq[byte]): Future[?!void] {.base, locks: "unknown".} =
|
||||
method put*(self: Datastore, key: Key, data: seq[byte]): Future[?!void] {.base, gcsafe, locks: "unknown".} =
|
||||
raiseAssert("Not implemented!")
|
||||
|
||||
method put*(self: Datastore, batch: seq[BatchEntry]): Future[?!void] {.base, locks: "unknown".} =
|
||||
method put*(self: Datastore, batch: seq[BatchEntry]): Future[?!void] {.base, gcsafe, locks: "unknown".} =
|
||||
raiseAssert("Not implemented!")
|
||||
|
||||
method close*(self: Datastore): Future[?!void] {.base, async, locks: "unknown".} =
|
||||
@ -46,7 +46,7 @@ method query*(
|
||||
proc contains*(self: Datastore, key: Key): Future[bool] {.async.} =
|
||||
return (await self.has(key)) |? false
|
||||
|
||||
method modify*(self: Datastore, key: Key, fn: Modify): Future[?!void] {.base, locks: "unknown".} =
|
||||
method modify*(self: Datastore, key: Key, fn: Modify): Future[?!void] {.base, gcsafe, locks: "unknown".} =
|
||||
## Concurrently safe way of modifying the value associated with the `key`.
|
||||
##
|
||||
## Same as `modifyGet`, but this takes `fn` that doesn't produce any auxillary value.
|
||||
@ -54,7 +54,7 @@ method modify*(self: Datastore, key: Key, fn: Modify): Future[?!void] {.base, lo
|
||||
|
||||
raiseAssert("Not implemented!")
|
||||
|
||||
method modifyGet*(self: Datastore, key: Key, fn: ModifyGet): Future[?!seq[byte]] {.base, locks: "unknown".} =
|
||||
method modifyGet*(self: Datastore, key: Key, fn: ModifyGet): Future[?!seq[byte]] {.base, gcsafe, locks: "unknown".} =
|
||||
## Concurrently safe way of updating value associated with the `key`. Returns auxillary value on
|
||||
## successful update.
|
||||
##
|
||||
|
||||
@ -79,7 +79,7 @@ proc getQueryString(query: Query): string =
|
||||
result = $(query.key)
|
||||
let toTrim = ["/*", "\\*"]
|
||||
for trim in toTrim:
|
||||
if result.endswith(trim):
|
||||
if result.endsWith(trim):
|
||||
result = result[0 ..< ^(trim.len)]
|
||||
|
||||
method query*(
|
||||
|
||||
@ -20,7 +20,7 @@ type
|
||||
MountedDatastore* = ref object of Datastore
|
||||
stores*: Table[Key, MountedStore]
|
||||
|
||||
method mount*(self: MountedDatastore, key: Key, store: Datastore): ?!void {.base.} =
|
||||
method mount*(self: MountedDatastore, key: Key, store: Datastore): ?!void {.base, gcsafe.} =
|
||||
## Mount a store on a namespace - namespaces are only `/`
|
||||
##
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ type
|
||||
AutoDisposed*[T: ptr|ref] = object
|
||||
val*: T
|
||||
|
||||
DataProc* = proc(s: RawStmtPtr) {.closure, gcsafe.}
|
||||
DataProc* = proc(s: RawStmtPtr) {.closure, gcsafe, raises: [].}
|
||||
|
||||
NoParams* = tuple # empty tuple
|
||||
|
||||
@ -128,7 +128,11 @@ template dispose*(db: SQLite) =
|
||||
|
||||
template dispose*(sqliteStmt: SQLiteStmt) =
|
||||
doAssert SQLITE_OK == sqlite3_finalize(RawStmtPtr(sqliteStmt))
|
||||
sqliteStmt = nil
|
||||
# nil literals can no longer be directly assigned to variables or fields of distinct pointer types.
|
||||
# They must be converted instead.
|
||||
# See https://nim-lang.org/blog/2022/12/21/version-20-rc.html#:~:text=nil%20literals%20can%20no%20longer%20be%20directly%20assigned%20to%20variables%20or%20fields%20of%20distinct%20pointer%20types.%20They%20must%20be%20converted%20instead.
|
||||
# SQLiteStmt(nil) is generating a SIGSEGV, so we need to cast it
|
||||
sqliteStmt = cast[typeof sqliteStmt](nil)
|
||||
|
||||
proc release*[T](x: var AutoDisposed[T]): T =
|
||||
result = x.val
|
||||
@ -256,11 +260,10 @@ proc query*(
|
||||
query: string,
|
||||
onData: DataProc): ?!bool =
|
||||
|
||||
var
|
||||
s = ? NoParamsStmt.prepare(env, query)
|
||||
res = s.query((), onData)
|
||||
var s = ? NoParamsStmt.prepare(env, query)
|
||||
|
||||
var res = s.query((), onData)
|
||||
# NB: dispose of the prepared query statement and free associated memory
|
||||
s.dispose
|
||||
return res
|
||||
|
||||
res
|
||||
|
||||
@ -25,7 +25,7 @@ suite "Test Basic LevelDbDatastore":
|
||||
otherBytes = "some other bytes".toBytes
|
||||
|
||||
setupAll:
|
||||
createdir(tempDir)
|
||||
createDir(tempDir)
|
||||
|
||||
teardownAll:
|
||||
(await ds.close()).tryGet()
|
||||
@ -40,7 +40,7 @@ suite "Test LevelDB Query":
|
||||
var ds: LevelDbDatastore
|
||||
|
||||
setup:
|
||||
createdir(tempDir)
|
||||
createDir(tempDir)
|
||||
ds = LevelDbDatastore.new(tempDir).tryGet()
|
||||
|
||||
teardown:
|
||||
@ -57,7 +57,7 @@ suite "Test LevelDB Typed Query":
|
||||
var ds: LevelDbDatastore
|
||||
|
||||
setup:
|
||||
createdir(tempDir)
|
||||
createDir(tempDir)
|
||||
ds = LevelDbDatastore.new(tempDir).tryGet()
|
||||
|
||||
teardown:
|
||||
@ -87,7 +87,7 @@ suite "LevelDB Query: keys should disregard trailing wildcards":
|
||||
val3 = "value for 3".toBytes
|
||||
|
||||
setup:
|
||||
createdir(tempDir)
|
||||
createDir(tempDir)
|
||||
ds = LevelDbDatastore.new(tempDir).tryGet()
|
||||
(await ds.put(key1, val1)).tryGet
|
||||
(await ds.put(key2, val2)).tryGet
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user