result types

This commit is contained in:
Jaremy Creechley 2023-09-26 17:25:43 -07:00
parent e75081f832
commit c1f5d43775
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 20 additions and 18 deletions

View File

@ -159,6 +159,7 @@ method has*(self: ThreadDatastore,
let key = KeyId.new key.id()
dispatchTask[bool](self, signal):
self.tp.spawn hasTask(ctx, ds, key)
return ctx[].res.toRes(v => v)
proc deleteTask[T, DB](ctx: TaskCtx[T], ds: DB;
key: KeyId) {.gcsafe.} =
@ -175,6 +176,7 @@ method delete*(self: ThreadDatastore,
let key = KeyId.new key.id()
dispatchTask[void](self, signal):
self.tp.spawn deleteTask(ctx, ds, key)
return ctx[].res.toRes()
method delete*(self: ThreadDatastore,
keys: seq[Key]): Future[?!void] {.async.} =

View File

@ -58,29 +58,29 @@ suite "Test Basic ThreadProxyDatastore":
val &= char(c)
echo "get res2: ", $val
# suite "Test Basic ThreadDatastore with SQLite":
suite "Test Basic ThreadDatastore with SQLite":
# var
# sqlStore: SQLiteBackend[KeyId,DataBuffer]
# ds: ThreadDatastore
# taskPool: Taskpool
# key = Key.init("/a/b").tryGet()
# bytes = "some bytes".toBytes
# otherBytes = "some other bytes".toBytes
var
sqlStore: SQLiteBackend[KeyId,DataBuffer]
ds: ThreadDatastore
taskPool: Taskpool
key = Key.init("/a/b").tryGet()
bytes = "some bytes".toBytes
otherBytes = "some other bytes".toBytes
# setupAll:
# sqlStore = newSQLiteBackend[KeyId, DataBuffer](Memory).tryGet()
# taskPool = Taskpool.new(NumThreads)
# ds = ThreadDatastore.new(sqlStore, tp = taskPool).tryGet()
setupAll:
sqlStore = newSQLiteBackend[KeyId, DataBuffer](Memory).tryGet()
taskPool = Taskpool.new(NumThreads)
ds = ThreadDatastore.new(sqlStore, tp = taskPool).tryGet()
# teardown:
# GC_fullCollect()
teardown:
GC_fullCollect()
# teardownAll:
# (await ds.close()).tryGet()
# taskPool.shutdown()
teardownAll:
(await ds.close()).tryGet()
taskPool.shutdown()
# basicStoreTests(ds, key, bytes, otherBytes)
basicStoreTests(ds, key, bytes, otherBytes)
# suite "Test Query ThreadDatastore with SQLite":