2022-11-22 18:40:24 +00:00
|
|
|
when (NimMajor, NimMinor) < (1, 4):
|
|
|
|
{.push raises: [Defect].}
|
|
|
|
else:
|
|
|
|
{.push raises: [].}
|
|
|
|
|
|
|
|
import
|
|
|
|
std/options,
|
2023-05-25 15:34:34 +00:00
|
|
|
stew/results,
|
|
|
|
chronos
|
2022-11-22 18:40:24 +00:00
|
|
|
import
|
2023-04-19 11:29:23 +00:00
|
|
|
../waku_core,
|
2022-11-22 18:40:24 +00:00
|
|
|
./common
|
|
|
|
|
|
|
|
const DefaultPageSize*: uint = 25
|
|
|
|
|
|
|
|
type
|
|
|
|
ArchiveDriverResult*[T] = Result[T, string]
|
|
|
|
ArchiveDriver* = ref object of RootObj
|
2023-09-06 17:16:37 +00:00
|
|
|
OnErrHandler* = proc(errMsg: string) {.gcsafe, closure.}
|
2022-11-22 18:40:24 +00:00
|
|
|
|
2023-10-24 14:05:39 +00:00
|
|
|
type ArchiveRow* = (PubsubTopic, WakuMessage, seq[byte], Timestamp)
|
2022-11-22 18:40:24 +00:00
|
|
|
|
|
|
|
# ArchiveDriver interface
|
|
|
|
|
2023-05-25 15:34:34 +00:00
|
|
|
method put*(driver: ArchiveDriver,
|
|
|
|
pubsubTopic: PubsubTopic,
|
|
|
|
message: WakuMessage,
|
|
|
|
digest: MessageDigest,
|
|
|
|
receivedTime: Timestamp):
|
|
|
|
Future[ArchiveDriverResult[void]] {.base, async.} = discard
|
|
|
|
|
|
|
|
method getAllMessages*(driver: ArchiveDriver):
|
|
|
|
Future[ArchiveDriverResult[seq[ArchiveRow]]] {.base, async.} = discard
|
|
|
|
|
|
|
|
method getMessages*(driver: ArchiveDriver,
|
|
|
|
contentTopic: seq[ContentTopic] = @[],
|
|
|
|
pubsubTopic = none(PubsubTopic),
|
|
|
|
cursor = none(ArchiveCursor),
|
|
|
|
startTime = none(Timestamp),
|
|
|
|
endTime = none(Timestamp),
|
|
|
|
maxPageSize = DefaultPageSize,
|
|
|
|
ascendingOrder = true):
|
|
|
|
Future[ArchiveDriverResult[seq[ArchiveRow]]] {.base, async.} = discard
|
|
|
|
|
|
|
|
method getMessagesCount*(driver: ArchiveDriver):
|
|
|
|
Future[ArchiveDriverResult[int64]] {.base, async.} = discard
|
|
|
|
|
2023-10-10 09:59:09 +00:00
|
|
|
method getPagesCount*(driver: ArchiveDriver):
|
|
|
|
Future[ArchiveDriverResult[int64]] {.base, async.} = discard
|
|
|
|
|
|
|
|
method getPagesSize*(driver: ArchiveDriver):
|
|
|
|
Future[ArchiveDriverResult[int64]] {.base, async.} = discard
|
|
|
|
|
|
|
|
method performVacuum*(driver: ArchiveDriver):
|
|
|
|
Future[ArchiveDriverResult[void]] {.base, async.} = discard
|
|
|
|
|
2023-05-25 15:34:34 +00:00
|
|
|
method getOldestMessageTimestamp*(driver: ArchiveDriver):
|
|
|
|
Future[ArchiveDriverResult[Timestamp]] {.base, async.} = discard
|
|
|
|
|
|
|
|
method getNewestMessageTimestamp*(driver: ArchiveDriver):
|
|
|
|
Future[ArchiveDriverResult[Timestamp]] {.base, async.} = discard
|
|
|
|
|
|
|
|
method deleteMessagesOlderThanTimestamp*(driver: ArchiveDriver,
|
|
|
|
ts: Timestamp):
|
|
|
|
Future[ArchiveDriverResult[void]] {.base, async.} = discard
|
|
|
|
|
|
|
|
method deleteOldestMessagesNotWithinLimit*(driver: ArchiveDriver,
|
|
|
|
limit: int):
|
|
|
|
Future[ArchiveDriverResult[void]] {.base, async.} = discard
|
|
|
|
|
|
|
|
method close*(driver: ArchiveDriver):
|
|
|
|
Future[ArchiveDriverResult[void]] {.base, async.} = discard
|
2023-10-10 09:59:09 +00:00
|
|
|
|