mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-02 13:43:11 +00:00
proper query iterator interface
This commit is contained in:
parent
60e0ea5573
commit
ec4015a404
@ -1,3 +1,6 @@
|
||||
import pkg/upraises
|
||||
import pkg/chronos
|
||||
|
||||
import ./key
|
||||
|
||||
type
|
||||
@ -13,7 +16,15 @@ type
|
||||
sort*: SortOrder
|
||||
|
||||
QueryResponse* = tuple[key: Key, data: seq[byte]]
|
||||
QueryIter* = iterator(): QueryResponse {.closure.}
|
||||
|
||||
GetNext* = proc(): Future[QueryResponse] {.upraises: [], gcsafe, closure.}
|
||||
QueryIter* = object
|
||||
finished: bool
|
||||
next*: GetNext
|
||||
|
||||
iterator items*(q: QueryIter): Future[QueryResponse] =
|
||||
while not q.finished:
|
||||
yield q.next()
|
||||
|
||||
proc init*(
|
||||
T: type Query,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user