From c1f5d437750456c3a91a202ec8cc3239eb70b29e Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Tue, 26 Sep 2023 17:25:43 -0700 Subject: [PATCH] result types --- datastore/threads/threadproxyds.nim | 2 ++ tests/datastore/testthreadproxyds.nim | 36 +++++++++++++-------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/datastore/threads/threadproxyds.nim b/datastore/threads/threadproxyds.nim index 7d6541d..d5a53dc 100644 --- a/datastore/threads/threadproxyds.nim +++ b/datastore/threads/threadproxyds.nim @@ -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.} = diff --git a/tests/datastore/testthreadproxyds.nim b/tests/datastore/testthreadproxyds.nim index a9ae843..1a2c663 100644 --- a/tests/datastore/testthreadproxyds.nim +++ b/tests/datastore/testthreadproxyds.nim @@ -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":