mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-04 06:33:11 +00:00
Define raises for async pragma
This commit is contained in:
parent
ea917be824
commit
13c0a0cdb1
@ -16,22 +16,22 @@ type
|
|||||||
Modify* = Function[?seq[byte], Future[?seq[byte]]]
|
Modify* = Function[?seq[byte], Future[?seq[byte]]]
|
||||||
ModifyGet* = Function[?seq[byte], Future[(?seq[byte], seq[byte])]]
|
ModifyGet* = Function[?seq[byte], Future[(?seq[byte], seq[byte])]]
|
||||||
|
|
||||||
method has*(self: Datastore, key: Key): Future[?!bool] {.base, gcsafe, locks: "unknown".} =
|
method has*(self: Datastore, key: Key): Future[?!bool] {.base, gcsafe, async: (raises: [CancelledError]), locks: "unknown".} =
|
||||||
raiseAssert("Not implemented!")
|
raiseAssert("Not implemented!")
|
||||||
|
|
||||||
method delete*(self: Datastore, key: Key): Future[?!void] {.base, gcsafe, locks: "unknown".} =
|
method delete*(self: Datastore, key: Key): Future[?!void] {.base, gcsafe, async: (raises: [CancelledError]), locks: "unknown".} =
|
||||||
raiseAssert("Not implemented!")
|
raiseAssert("Not implemented!")
|
||||||
|
|
||||||
method delete*(self: Datastore, keys: seq[Key]): Future[?!void] {.base, gcsafe, locks: "unknown".} =
|
method delete*(self: Datastore, keys: seq[Key]): Future[?!void] {.base, gcsafe, async: (raises: [CancelledError]), locks: "unknown".} =
|
||||||
raiseAssert("Not implemented!")
|
raiseAssert("Not implemented!")
|
||||||
|
|
||||||
method get*(self: Datastore, key: Key): Future[?!seq[byte]] {.base, gcsafe, locks: "unknown".} =
|
method get*(self: Datastore, key: Key): Future[?!seq[byte]] {.base, gcsafe, async: (raises: [CancelledError]), locks: "unknown".} =
|
||||||
raiseAssert("Not implemented!")
|
raiseAssert("Not implemented!")
|
||||||
|
|
||||||
method put*(self: Datastore, key: Key, data: seq[byte]): Future[?!void] {.base, gcsafe, locks: "unknown".} =
|
method put*(self: Datastore, key: Key, data: seq[byte]): Future[?!void] {.base, gcsafe, async: (raises: [CancelledError]), locks: "unknown".} =
|
||||||
raiseAssert("Not implemented!")
|
raiseAssert("Not implemented!")
|
||||||
|
|
||||||
method put*(self: Datastore, batch: seq[BatchEntry]): Future[?!void] {.base, gcsafe, locks: "unknown".} =
|
method put*(self: Datastore, batch: seq[BatchEntry]): Future[?!void] {.base, gcsafe, async: (raises: [CancelledError]), locks: "unknown".} =
|
||||||
raiseAssert("Not implemented!")
|
raiseAssert("Not implemented!")
|
||||||
|
|
||||||
method close*(self: Datastore): Future[?!void] {.base, async, locks: "unknown".} =
|
method close*(self: Datastore): Future[?!void] {.base, async, locks: "unknown".} =
|
||||||
@ -43,7 +43,7 @@ method query*(
|
|||||||
|
|
||||||
raiseAssert("Not implemented!")
|
raiseAssert("Not implemented!")
|
||||||
|
|
||||||
proc contains*(self: Datastore, key: Key): Future[bool] {.async.} =
|
proc contains*(self: Datastore, key: Key): Future[bool] {.async: (raises: [CancelledError]).} =
|
||||||
return (await self.has(key)) |? false
|
return (await self.has(key)) |? false
|
||||||
|
|
||||||
method modify*(self: Datastore, key: Key, fn: Modify): Future[?!void] {.base, gcsafe, locks: "unknown".} =
|
method modify*(self: Datastore, key: Key, fn: Modify): Future[?!void] {.base, gcsafe, locks: "unknown".} =
|
||||||
|
|||||||
@ -65,10 +65,10 @@ proc path*(self: FSDatastore, key: Key): ?!string =
|
|||||||
|
|
||||||
return success fullname
|
return success fullname
|
||||||
|
|
||||||
method has*(self: FSDatastore, key: Key): Future[?!bool] {.async.} =
|
method has*(self: FSDatastore, key: Key): Future[?!bool] {.async: (raises: [CancelledError]).} =
|
||||||
return self.path(key).?fileExists()
|
return self.path(key).?fileExists()
|
||||||
|
|
||||||
method delete*(self: FSDatastore, key: Key): Future[?!void] {.async.} =
|
method delete*(self: FSDatastore, key: Key): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
without path =? self.path(key), error:
|
without path =? self.path(key), error:
|
||||||
return failure error
|
return failure error
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ method delete*(self: FSDatastore, key: Key): Future[?!void] {.async.} =
|
|||||||
|
|
||||||
return success()
|
return success()
|
||||||
|
|
||||||
method delete*(self: FSDatastore, keys: seq[Key]): Future[?!void] {.async.} =
|
method delete*(self: FSDatastore, keys: seq[Key]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if err =? (await self.delete(key)).errorOption:
|
if err =? (await self.delete(key)).errorOption:
|
||||||
return failure err
|
return failure err
|
||||||
@ -119,7 +119,7 @@ proc readFile*(self: FSDatastore, path: string): ?!seq[byte] =
|
|||||||
except CatchableError as e:
|
except CatchableError as e:
|
||||||
return failure e
|
return failure e
|
||||||
|
|
||||||
method get*(self: FSDatastore, key: Key): Future[?!seq[byte]] {.async.} =
|
method get*(self: FSDatastore, key: Key): Future[?!seq[byte]] {.async: (raises: [CancelledError]).} =
|
||||||
without path =? self.path(key), error:
|
without path =? self.path(key), error:
|
||||||
return failure error
|
return failure error
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ method get*(self: FSDatastore, key: Key): Future[?!seq[byte]] {.async.} =
|
|||||||
method put*(
|
method put*(
|
||||||
self: FSDatastore,
|
self: FSDatastore,
|
||||||
key: Key,
|
key: Key,
|
||||||
data: seq[byte]): Future[?!void] {.async.} =
|
data: seq[byte]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
|
|
||||||
without path =? self.path(key), error:
|
without path =? self.path(key), error:
|
||||||
return failure error
|
return failure error
|
||||||
@ -147,7 +147,7 @@ method put*(
|
|||||||
|
|
||||||
method put*(
|
method put*(
|
||||||
self: FSDatastore,
|
self: FSDatastore,
|
||||||
batch: seq[BatchEntry]): Future[?!void] {.async.} =
|
batch: seq[BatchEntry]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
|
|
||||||
for entry in batch:
|
for entry in batch:
|
||||||
if err =? (await self.put(entry.key, entry.data)).errorOption:
|
if err =? (await self.put(entry.key, entry.data)).errorOption:
|
||||||
|
|||||||
@ -20,27 +20,27 @@ type
|
|||||||
db: LevelDb
|
db: LevelDb
|
||||||
locks: TableRef[Key, AsyncLock]
|
locks: TableRef[Key, AsyncLock]
|
||||||
|
|
||||||
method has*(self: LevelDbDatastore, key: Key): Future[?!bool] {.async.} =
|
method has*(self: LevelDbDatastore, key: Key): Future[?!bool] {.async: (raises: [CancelledError]).} =
|
||||||
try:
|
try:
|
||||||
let str = self.db.get($key)
|
let str = self.db.get($key)
|
||||||
return success(str.isSome)
|
return success(str.isSome)
|
||||||
except LevelDbException as e:
|
except LevelDbException as e:
|
||||||
return failure("LevelDbDatastore.has exception: " & e.msg)
|
return failure("LevelDbDatastore.has exception: " & e.msg)
|
||||||
|
|
||||||
method delete*(self: LevelDbDatastore, key: Key): Future[?!void] {.async.} =
|
method delete*(self: LevelDbDatastore, key: Key): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
try:
|
try:
|
||||||
self.db.delete($key, sync = true)
|
self.db.delete($key, sync = true)
|
||||||
return success()
|
return success()
|
||||||
except LevelDbException as e:
|
except LevelDbException as e:
|
||||||
return failure("LevelDbDatastore.delete exception: " & e.msg)
|
return failure("LevelDbDatastore.delete exception: " & e.msg)
|
||||||
|
|
||||||
method delete*(self: LevelDbDatastore, keys: seq[Key]): Future[?!void] {.async.} =
|
method delete*(self: LevelDbDatastore, keys: seq[Key]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if err =? (await self.delete(key)).errorOption:
|
if err =? (await self.delete(key)).errorOption:
|
||||||
return failure(err.msg)
|
return failure(err.msg)
|
||||||
return success()
|
return success()
|
||||||
|
|
||||||
method get*(self: LevelDbDatastore, key: Key): Future[?!seq[byte]] {.async.} =
|
method get*(self: LevelDbDatastore, key: Key): Future[?!seq[byte]] {.async: (raises: [CancelledError]).} =
|
||||||
try:
|
try:
|
||||||
let str = self.db.get($key)
|
let str = self.db.get($key)
|
||||||
if not str.isSome:
|
if not str.isSome:
|
||||||
@ -50,7 +50,7 @@ method get*(self: LevelDbDatastore, key: Key): Future[?!seq[byte]] {.async.} =
|
|||||||
except LevelDbException as e:
|
except LevelDbException as e:
|
||||||
return failure("LevelDbDatastore.get exception: " & $e.msg)
|
return failure("LevelDbDatastore.get exception: " & $e.msg)
|
||||||
|
|
||||||
method put*(self: LevelDbDatastore, key: Key, data: seq[byte]): Future[?!void] {.async.} =
|
method put*(self: LevelDbDatastore, key: Key, data: seq[byte]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
try:
|
try:
|
||||||
let str = string.fromBytes(data)
|
let str = string.fromBytes(data)
|
||||||
self.db.put($key, str)
|
self.db.put($key, str)
|
||||||
@ -58,7 +58,7 @@ method put*(self: LevelDbDatastore, key: Key, data: seq[byte]): Future[?!void] {
|
|||||||
except LevelDbException as e:
|
except LevelDbException as e:
|
||||||
return failure("LevelDbDatastore.put exception: " & $e.msg)
|
return failure("LevelDbDatastore.put exception: " & $e.msg)
|
||||||
|
|
||||||
method put*(self: LevelDbDatastore, batch: seq[BatchEntry]): Future[?!void] {.async.} =
|
method put*(self: LevelDbDatastore, batch: seq[BatchEntry]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
try:
|
try:
|
||||||
let b = newBatch()
|
let b = newBatch()
|
||||||
for entry in batch:
|
for entry in batch:
|
||||||
|
|||||||
@ -63,7 +63,7 @@ proc dispatch(
|
|||||||
|
|
||||||
method has*(
|
method has*(
|
||||||
self: MountedDatastore,
|
self: MountedDatastore,
|
||||||
key: Key): Future[?!bool] {.async.} =
|
key: Key): Future[?!bool] {.async: (raises: [CancelledError]).} =
|
||||||
|
|
||||||
without mounted =? self.dispatch(key):
|
without mounted =? self.dispatch(key):
|
||||||
return failure "No mounted datastore found"
|
return failure "No mounted datastore found"
|
||||||
@ -72,7 +72,7 @@ method has*(
|
|||||||
|
|
||||||
method delete*(
|
method delete*(
|
||||||
self: MountedDatastore,
|
self: MountedDatastore,
|
||||||
key: Key): Future[?!void] {.async.} =
|
key: Key): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
|
|
||||||
without mounted =? self.dispatch(key), error:
|
without mounted =? self.dispatch(key), error:
|
||||||
return failure(error)
|
return failure(error)
|
||||||
@ -81,7 +81,7 @@ method delete*(
|
|||||||
|
|
||||||
method delete*(
|
method delete*(
|
||||||
self: MountedDatastore,
|
self: MountedDatastore,
|
||||||
keys: seq[Key]): Future[?!void] {.async.} =
|
keys: seq[Key]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
|
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if err =? (await self.delete(key)).errorOption:
|
if err =? (await self.delete(key)).errorOption:
|
||||||
@ -91,7 +91,7 @@ method delete*(
|
|||||||
|
|
||||||
method get*(
|
method get*(
|
||||||
self: MountedDatastore,
|
self: MountedDatastore,
|
||||||
key: Key): Future[?!seq[byte]] {.async.} =
|
key: Key): Future[?!seq[byte]] {.async: (raises: [CancelledError]).} =
|
||||||
|
|
||||||
without mounted =? self.dispatch(key), error:
|
without mounted =? self.dispatch(key), error:
|
||||||
return failure(error)
|
return failure(error)
|
||||||
@ -101,7 +101,7 @@ method get*(
|
|||||||
method put*(
|
method put*(
|
||||||
self: MountedDatastore,
|
self: MountedDatastore,
|
||||||
key: Key,
|
key: Key,
|
||||||
data: seq[byte]): Future[?!void] {.async.} =
|
data: seq[byte]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
|
|
||||||
without mounted =? self.dispatch(key), error:
|
without mounted =? self.dispatch(key), error:
|
||||||
return failure(error)
|
return failure(error)
|
||||||
@ -110,7 +110,7 @@ method put*(
|
|||||||
|
|
||||||
method put*(
|
method put*(
|
||||||
self: MountedDatastore,
|
self: MountedDatastore,
|
||||||
batch: seq[BatchEntry]): Future[?!void] {.async.} =
|
batch: seq[BatchEntry]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
|
|
||||||
for entry in batch:
|
for entry in batch:
|
||||||
if err =? (await self.put(entry.key, entry.data)).errorOption:
|
if err =? (await self.put(entry.key, entry.data)).errorOption:
|
||||||
|
|||||||
@ -146,7 +146,7 @@ method modify*(self: SQLiteDatastore, key: Key, fn: Modify): Future[?!void] {.as
|
|||||||
else:
|
else:
|
||||||
return success()
|
return success()
|
||||||
|
|
||||||
method has*(self: SQLiteDatastore, key: Key): Future[?!bool] {.async.} =
|
method has*(self: SQLiteDatastore, key: Key): Future[?!bool] {.async: (raises: [CancelledError]).} =
|
||||||
var
|
var
|
||||||
exists = false
|
exists = false
|
||||||
|
|
||||||
@ -158,10 +158,10 @@ method has*(self: SQLiteDatastore, key: Key): Future[?!bool] {.async.} =
|
|||||||
|
|
||||||
return success exists
|
return success exists
|
||||||
|
|
||||||
method delete*(self: SQLiteDatastore, key: Key): Future[?!void] {.async.} =
|
method delete*(self: SQLiteDatastore, key: Key): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
return self.db.deleteStmt.exec((key.id))
|
return self.db.deleteStmt.exec((key.id))
|
||||||
|
|
||||||
method delete*(self: SQLiteDatastore, keys: seq[Key]): Future[?!void] {.async.} =
|
method delete*(self: SQLiteDatastore, keys: seq[Key]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
if err =? self.db.beginStmt.exec().errorOption:
|
if err =? self.db.beginStmt.exec().errorOption:
|
||||||
return failure(err)
|
return failure(err)
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ method delete*(self: SQLiteDatastore, keys: seq[Key]): Future[?!void] {.async.}
|
|||||||
|
|
||||||
return success()
|
return success()
|
||||||
|
|
||||||
method get*(self: SQLiteDatastore, key: Key): Future[?!seq[byte]] {.async.} =
|
method get*(self: SQLiteDatastore, key: Key): Future[?!seq[byte]] {.async: (raises: [CancelledError]).} =
|
||||||
# see comment in ./filesystem_datastore re: finer control of memory
|
# see comment in ./filesystem_datastore re: finer control of memory
|
||||||
# allocation in `method get`, could apply here as well if bytes were read
|
# allocation in `method get`, could apply here as well if bytes were read
|
||||||
# incrementally with `sqlite3_blob_read`
|
# incrementally with `sqlite3_blob_read`
|
||||||
@ -197,10 +197,10 @@ method get*(self: SQLiteDatastore, key: Key): Future[?!seq[byte]] {.async.} =
|
|||||||
|
|
||||||
return success bytes
|
return success bytes
|
||||||
|
|
||||||
method put*(self: SQLiteDatastore, key: Key, data: seq[byte]): Future[?!void] {.async.} =
|
method put*(self: SQLiteDatastore, key: Key, data: seq[byte]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
return self.db.putStmt.exec((key.id, data, initVersion, timestamp()))
|
return self.db.putStmt.exec((key.id, data, initVersion, timestamp()))
|
||||||
|
|
||||||
method put*(self: SQLiteDatastore, batch: seq[BatchEntry]): Future[?!void] {.async.} =
|
method put*(self: SQLiteDatastore, batch: seq[BatchEntry]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
if err =? self.db.beginStmt.exec().errorOption:
|
if err =? self.db.beginStmt.exec().errorOption:
|
||||||
return failure err
|
return failure err
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ proc stores*(self: TieredDatastore): seq[Datastore] =
|
|||||||
|
|
||||||
method has*(
|
method has*(
|
||||||
self: TieredDatastore,
|
self: TieredDatastore,
|
||||||
key: Key): Future[?!bool] {.async.} =
|
key: Key): Future[?!bool] {.async: (raises: [CancelledError]).} =
|
||||||
|
|
||||||
for store in self.stores:
|
for store in self.stores:
|
||||||
without res =? (await store.has(key)), err:
|
without res =? (await store.has(key)), err:
|
||||||
@ -41,32 +41,34 @@ method has*(
|
|||||||
|
|
||||||
method delete*(
|
method delete*(
|
||||||
self: TieredDatastore,
|
self: TieredDatastore,
|
||||||
key: Key): Future[?!void] {.async.} =
|
key: Key): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
|
|
||||||
let
|
let
|
||||||
pending = await allFinished(self.stores.mapIt(it.delete(key)))
|
pending = await allFinished(self.stores.mapIt(it.delete(key)))
|
||||||
|
|
||||||
for fut in pending:
|
for fut in pending:
|
||||||
if fut.read().isErr: return fut.read()
|
without res =? fut.read().catch, error:
|
||||||
|
return failure error
|
||||||
|
|
||||||
return success()
|
return success()
|
||||||
|
|
||||||
method delete*(
|
method delete*(
|
||||||
self: TieredDatastore,
|
self: TieredDatastore,
|
||||||
keys: seq[Key]): Future[?!void] {.async.} =
|
keys: seq[Key]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
|
|
||||||
for key in keys:
|
for key in keys:
|
||||||
let
|
let
|
||||||
pending = await allFinished(self.stores.mapIt(it.delete(key)))
|
pending = await allFinished(self.stores.mapIt(it.delete(key)))
|
||||||
|
|
||||||
for fut in pending:
|
for fut in pending:
|
||||||
if fut.read().isErr: return fut.read()
|
without res =? fut.read().catch, error:
|
||||||
|
return failure error
|
||||||
|
|
||||||
return success()
|
return success()
|
||||||
|
|
||||||
method get*(
|
method get*(
|
||||||
self: TieredDatastore,
|
self: TieredDatastore,
|
||||||
key: Key): Future[?!seq[byte]] {.async.} =
|
key: Key): Future[?!seq[byte]] {.async: (raises: [CancelledError]).} =
|
||||||
|
|
||||||
var
|
var
|
||||||
bytes: seq[byte]
|
bytes: seq[byte]
|
||||||
@ -91,26 +93,28 @@ method get*(
|
|||||||
method put*(
|
method put*(
|
||||||
self: TieredDatastore,
|
self: TieredDatastore,
|
||||||
key: Key,
|
key: Key,
|
||||||
data: seq[byte]): Future[?!void] {.async.} =
|
data: seq[byte]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
|
|
||||||
let
|
let
|
||||||
pending = await allFinished(self.stores.mapIt(it.put(key, data)))
|
pending = await allFinished(self.stores.mapIt(it.put(key, data)))
|
||||||
|
|
||||||
for fut in pending:
|
for fut in pending:
|
||||||
if fut.read().isErr: return fut.read()
|
without res =? fut.read().catch, error:
|
||||||
|
return failure error
|
||||||
|
|
||||||
return success()
|
return success()
|
||||||
|
|
||||||
method put*(
|
method put*(
|
||||||
self: TieredDatastore,
|
self: TieredDatastore,
|
||||||
batch: seq[BatchEntry]): Future[?!void] {.async.} =
|
batch: seq[BatchEntry]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
|
|
||||||
for entry in batch:
|
for entry in batch:
|
||||||
let
|
let
|
||||||
pending = await allFinished(self.stores.mapIt(it.put(entry.key, entry.data)))
|
pending = await allFinished(self.stores.mapIt(it.put(entry.key, entry.data)))
|
||||||
|
|
||||||
for fut in pending:
|
for fut in pending:
|
||||||
if fut.read().isErr: return fut.read()
|
without res =? fut.read().catch, error:
|
||||||
|
return failure error
|
||||||
|
|
||||||
return success()
|
return success()
|
||||||
|
|
||||||
|
|||||||
@ -71,16 +71,16 @@ template requireEncoder*(T: typedesc): untyped =
|
|||||||
{.error: "provide an encoder: `proc encode(a: " & $T & "): seq[byte]`".}
|
{.error: "provide an encoder: `proc encode(a: " & $T & "): seq[byte]`".}
|
||||||
|
|
||||||
# Original Datastore API
|
# Original Datastore API
|
||||||
proc has*(self: TypedDatastore, key: Key): Future[?!bool] {.async.} =
|
proc has*(self: TypedDatastore, key: Key): Future[?!bool] {.async: (raises: [CancelledError]).} =
|
||||||
await self.ds.has(key)
|
await self.ds.has(key)
|
||||||
|
|
||||||
proc contains*(self: TypedDatastore, key: Key): Future[bool] {.async.} =
|
proc contains*(self: TypedDatastore, key: Key): Future[bool] {.async: (raises: [CancelledError]).} =
|
||||||
return (await self.ds.has(key)) |? false
|
return (await self.ds.has(key)) |? false
|
||||||
|
|
||||||
proc delete*(self: TypedDatastore, key: Key): Future[?!void] {.async.} =
|
proc delete*(self: TypedDatastore, key: Key): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
await self.ds.delete(key)
|
await self.ds.delete(key)
|
||||||
|
|
||||||
proc delete*(self: TypedDatastore, keys: seq[Key]): Future[?!void] {.async.} =
|
proc delete*(self: TypedDatastore, keys: seq[Key]): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
await self.ds.delete(keys)
|
await self.ds.delete(keys)
|
||||||
|
|
||||||
proc close*(self: TypedDatastore): Future[?!void] {.async.} =
|
proc close*(self: TypedDatastore): Future[?!void] {.async.} =
|
||||||
@ -90,12 +90,12 @@ proc close*(self: TypedDatastore): Future[?!void] {.async.} =
|
|||||||
proc init*(T: type TypedDatastore, ds: Datastore): T =
|
proc init*(T: type TypedDatastore, ds: Datastore): T =
|
||||||
TypedDatastore(ds: ds)
|
TypedDatastore(ds: ds)
|
||||||
|
|
||||||
proc put*[T](self: TypedDatastore, key: Key, t: T): Future[?!void] {.async.} =
|
proc put*[T](self: TypedDatastore, key: Key, t: T): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
requireEncoder(T)
|
requireEncoder(T)
|
||||||
|
|
||||||
await self.ds.put(key, t.encode)
|
await self.ds.put(key, t.encode)
|
||||||
|
|
||||||
proc get*[T](self: TypedDatastore, key: Key): Future[?!T] {.async.} =
|
proc get*[T](self: TypedDatastore, key: Key): Future[?!T] {.async: (raises: [CancelledError]).} =
|
||||||
requireDecoder(T)
|
requireDecoder(T)
|
||||||
|
|
||||||
without bytes =? await self.ds.get(key), error:
|
without bytes =? await self.ds.get(key), error:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user