cleanup results import and some warnings (#64)

* cleanup results import and some warnings

* add some more push raises
This commit is contained in:
Dmitriy Ryajov 2024-05-15 11:37:01 -06:00 committed by GitHub
parent 0ee88a2a9b
commit 962c08c101
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 43 additions and 68 deletions

2
.gitignore vendored
View File

@ -9,3 +9,5 @@ coverage
datastore.nims
nimcache
TODO
nimble.develop
nimble.paths

View File

@ -10,3 +10,7 @@ when (NimMajor, NimMinor) == (1, 2):
when (NimMajor, NimMinor) > (1, 2):
switch("hint", "XCannotRaiseY:off")
# begin Nimble config (version 2)
when withDir(thisDir(), system.fileExists("nimble.paths")):
include "nimble.paths"
# end Nimble config

View File

@ -13,8 +13,7 @@ requires "nim >= 1.2.0",
"sqlite3_abi",
"leveldbstatic >= 0.1.2",
"stew",
"unittest2",
"upraises >= 0.1.0 & < 0.2.0"
"unittest2"
task coverage, "generates code coverage report":
var (output, exitCode) = gorgeEx("which lcov")

View File

@ -1,7 +1,8 @@
{.push raises: [].}
import pkg/chronos
import pkg/questionable
import pkg/questionable/results
import pkg/upraises
import ./key
import ./query
@ -9,8 +10,6 @@ import ./types
export key, query, types
push: {.upraises: [].}
type
BatchEntry* = tuple[key: Key, data: seq[byte]]
Function*[T, U] = proc(value: T): U {.raises: [CatchableError], gcsafe, closure.}
@ -76,4 +75,4 @@ method modifyGet*(self: Datastore, key: Key, fn: ModifyGet): Future[?!seq[byte]]
## only the last auxillary value is returned.
##
raiseAssert("Not implemented!")
raiseAssert("Not implemented!")

View File

@ -1,3 +1,5 @@
{.push raises: [].}
import pkg/chronos
import pkg/questionable
import pkg/questionable/results

View File

@ -1,3 +1,5 @@
{.push raises: [].}
import std/os
import std/options
import std/tables
@ -6,16 +8,12 @@ import std/strutils
import pkg/chronos
import pkg/questionable
import pkg/questionable/results
from pkg/stew/results as stewResults import get, isErr
import pkg/upraises
import ./defaultimpl
import ./datastore
export datastore
push: {.upraises: [].}
type
FSDatastore* = ref object of Datastore
root*: string

View File

@ -1,3 +1,5 @@
{.push raises: [].}
import std/algorithm
import std/hashes
import std/oids
@ -7,15 +9,11 @@ import std/strformat
import pkg/questionable
import pkg/questionable/results
from pkg/stew/results as stewResults import get, isErr
import pkg/upraises
import ./namespace
export hashes, namespace
push: {.upraises: [].}
type
Key* = object
namespaces*: seq[Namespace]

View File

@ -1,11 +1,9 @@
{.push raises: [].}
import std/hashes
import pkg/questionable
import pkg/questionable/results
import pkg/upraises
push: {.upraises: [].}
const
Delimiter* = ":"

View File

@ -1,3 +1,5 @@
{.push raises: [].}
import std/options
import std/tables
import std/os
@ -8,14 +10,10 @@ import pkg/chronos
import pkg/questionable
import pkg/questionable/results
import pkg/stew/byteutils
from pkg/stew/results as stewResults import isErr
import pkg/upraises
import ../datastore
import ../defaultimpl
push: {.upraises: [].}
type
LevelDbDatastore* = ref object of Datastore
db: LevelDb

View File

@ -1,9 +1,10 @@
{.push raises: [].}
import std/tables
import pkg/chronos
import pkg/questionable
import pkg/questionable/results
import pkg/upraises
import ./key
import ./query
@ -11,8 +12,6 @@ import ./datastore
export key, query
push: {.upraises: [].}
type
MountedStore* = object
store*: Datastore
@ -28,7 +27,7 @@ method mount*(self: MountedDatastore, key: Key, store: Datastore): ?!void {.base
if key in self.stores:
return failure("Key already has store mounted!")
self.stores.add(key, MountedStore(store: store, key: key))
self.stores[key] = MountedStore(store: store, key: key)
return success()

View File

@ -1,4 +1,6 @@
import pkg/upraises
{.push raises: [].}
import pkg/chronos
import pkg/questionable
import pkg/questionable/results
@ -21,8 +23,8 @@ type
QueryResponse* = tuple[key: ?Key, data: seq[byte]]
QueryEndedError* = object of DatastoreError
GetNext* = proc(): Future[?!QueryResponse] {.upraises: [], gcsafe, closure.}
IterDispose* = proc(): Future[?!void] {.upraises: [], gcsafe.}
GetNext* = proc(): Future[?!QueryResponse] {.raises: [], gcsafe, closure.}
IterDispose* = proc(): Future[?!void] {.raises: [], gcsafe.}
QueryIter* = ref object
finished*: bool
next*: GetNext
@ -32,7 +34,7 @@ iterator items*(q: QueryIter): Future[?!QueryResponse] =
while not q.finished:
yield q.next()
proc defaultDispose(): Future[?!void] {.upraises: [], gcsafe, async.} =
proc defaultDispose(): Future[?!void] {.gcsafe, async.} =
return success()
proc new*(T: type QueryIter, dispose = defaultDispose): T =

View File

@ -1,3 +1,5 @@
{.push raises: [].}
import std/times
import std/options
@ -5,8 +7,6 @@ import pkg/chronos
import pkg/questionable
import pkg/questionable/results
import pkg/sqlite3_abi
from pkg/stew/results as stewResults import isErr
import pkg/upraises
import ../datastore
import ./sqlitedsdb
@ -14,8 +14,6 @@ import ./sqliteutils
export datastore, sqlitedsdb
push: {.upraises: [].}
type
SQLiteDatastore* = ref object of Datastore
readOnly: bool

View File

@ -1,17 +1,18 @@
{.push raises: [].}
import std/os
import std/strformat
import pkg/questionable
import pkg/questionable/results
import pkg/upraises
import ./sqliteutils
type
BoundIdCol* = proc (): string {.closure, gcsafe, upraises: [].}
BoundVersionCol* = proc (): int64 {.closure, gcsafe, upraises: [].}
BoundDataCol* = proc (): seq[byte] {.closure, gcsafe, upraises: [].}
BoundTimestampCol* = proc (): int64 {.closure, gcsafe, upraises: [].}
BoundIdCol* = proc (): string {.closure, gcsafe, raises: [].}
BoundVersionCol* = proc (): int64 {.closure, gcsafe, raises: [].}
BoundDataCol* = proc (): seq[byte] {.closure, gcsafe, raises: [].}
BoundTimestampCol* = proc (): int64 {.closure, gcsafe, raises: [].}
# feels odd to use `void` for prepared statements corresponding to SELECT
# queries but it fits with the rest of the SQLite wrapper adapted from

View File

@ -1,7 +1,8 @@
{.push raises: [].}
import pkg/questionable
import pkg/questionable/results
import pkg/sqlite3_abi
import pkg/upraises
export sqlite3_abi
@ -14,8 +15,6 @@ export sqlite3_abi
# e.g. `nimble test --forceBuild:on`
{.passc: "-DSQLITE_ENABLE_COLUMN_METADATA".}
push: {.upraises: [].}
type
AutoDisposed*[T: ptr|ref] = object
val*: T
@ -34,7 +33,7 @@ type
# see https://github.com/arnetheduck/nim-sqlite3-abi/issues/4
sqlite3_destructor_type_gcsafe =
proc (a1: pointer) {.cdecl, gcsafe, upraises: [].}
proc (a1: pointer) {.cdecl, gcsafe, raises: [].}
const
SQLITE_TRANSIENT_GCSAFE* = cast[sqlite3_destructor_type_gcsafe](-1)

View File

@ -1,17 +1,15 @@
{.push raises: [].}
import std/sequtils
import pkg/chronos
import pkg/questionable
import pkg/questionable/results
from pkg/stew/results as stewResults import get, isErr
import pkg/upraises
import ./datastore
export datastore
push: {.upraises: [].}
type
TieredDatastore* = ref object of Datastore
stores: seq[Datastore]

View File

@ -1,3 +1,5 @@
{.push raises: [].}
import std/options
import std/macros

View File

@ -1,8 +1,5 @@
import std/options
import pkg/asynctest
import pkg/chronos
import pkg/stew/results
import pkg/datastore

View File

@ -5,7 +5,6 @@ from std/algorithm import sort, reversed
import pkg/asynctest
import pkg/chronos
import pkg/stew/results
import pkg/stew/byteutils
import pkg/datastore

View File

@ -2,7 +2,6 @@ import std/options
import std/sugar
import std/random
import std/sequtils
import std/strutils
import pkg/asynctest
import pkg/chronos

View File

@ -1,12 +1,3 @@
import std/options
import std/sequtils
from std/algorithm import sort, reversed
import pkg/asynctest
import pkg/chronos
import pkg/stew/results
import pkg/stew/byteutils
import pkg/datastore
template queryTests*(ds: Datastore, testLimitsAndOffsets = true, testSortOrder = true) {.dirty.} =

View File

@ -5,7 +5,6 @@ from std/algorithm import sort, reversed
import pkg/asynctest
import pkg/chronos
import pkg/stew/results
import pkg/stew/byteutils
import pkg/datastore/sql/sqliteds

View File

@ -2,7 +2,6 @@ import std/options
import pkg/asynctest/unittest2
import pkg/chronos
import pkg/stew/results
import pkg/datastore

View File

@ -5,7 +5,6 @@ from std/algorithm import sort, reversed
import pkg/asynctest
import pkg/chronos
import pkg/stew/results
import pkg/stew/byteutils
import pkg/datastore/fsds

View File

@ -226,9 +226,6 @@ suite "Key":
key.reverse.field == "a"
test "key root":
let
key = Key.init("/a:b/c/d:e").tryGet()
check:
Key.init(":b").tryGet().root
not Key.init(":b/c").tryGet().root

View File

@ -4,7 +4,6 @@ import std/tables
import pkg/asynctest
import pkg/chronos
import pkg/stew/results
import pkg/stew/byteutils
import pkg/datastore/mountedds

View File

@ -3,7 +3,6 @@ import std/os
import pkg/asynctest
import pkg/chronos
import pkg/stew/results
import pkg/stew/byteutils
import pkg/datastore/fsds