mirror of https://github.com/waku-org/nwaku.git
refactor(store): extend message store interface with store manipulation methods
This commit is contained in:
parent
70fdd85066
commit
706c355b18
|
@ -46,4 +46,16 @@ method getMessagesByHistoryQuery*(
|
|||
ascendingOrder = true
|
||||
): MessageStoreResult[MessageStorePage] {.base.} = discard
|
||||
|
||||
|
||||
# Store manipulation
|
||||
|
||||
method getMessagesCount*(ms: MessageStore): MessageStoreResult[int64] {.base.} = discard
|
||||
|
||||
method getOldestMessageTimestamp*(ms: MessageStore): MessageStoreResult[Timestamp] {.base.} = discard
|
||||
|
||||
method getNewestMessageTimestamp*(ms: MessageStore): MessageStoreResult[Timestamp] {.base.} = discard
|
||||
|
||||
|
||||
method deleteMessagesOlderThanTimestamp*(ms: MessageStore, ts: Timestamp): MessageStoreResult[void] {.base.} = discard
|
||||
|
||||
method deleteOldestMessagesNotWithinLimit*(ms: MessageStore, limit: int): MessageStoreResult[void] {.base.} = discard
|
|
@ -158,3 +158,16 @@ method getMessagesByHistoryQuery*(
|
|||
|
||||
method getMessagesCount*(s: SqliteStore): MessageStoreResult[int64] =
|
||||
s.db.getMessageCount()
|
||||
|
||||
method getOldestMessageTimestamp*(s: SqliteStore): MessageStoreResult[Timestamp] =
|
||||
s.db.selectOldestReceiverTimestamp()
|
||||
|
||||
method getNewestMessageTimestamp*(s: SqliteStore): MessageStoreResult[Timestamp] =
|
||||
s.db.selectnewestReceiverTimestamp()
|
||||
|
||||
|
||||
method deleteMessagesOlderThanTimestamp*(s: SqliteStore, ts: Timestamp): MessageStoreResult[void] =
|
||||
s.db.deleteMessagesOlderThanTimestamp(ts)
|
||||
|
||||
method deleteOldestMessagesNotWithinLimit*(s: SqliteStore, limit: int): MessageStoreResult[void] =
|
||||
s.db.deleteOldestMessagesNotWithinLimit(limit)
|
||||
|
|
|
@ -430,3 +430,17 @@ method getMessagesByHistoryQuery*(
|
|||
method getMessagesCount*(s: StoreQueueRef): MessageStoreResult[int64] =
|
||||
ok(int64(s.len()))
|
||||
|
||||
method getOldestMessageTimestamp*(s: StoreQueueRef): MessageStoreResult[Timestamp] =
|
||||
s.first().map(proc(msg: IndexedWakuMessage): Timestamp = msg.index.receiverTime)
|
||||
|
||||
method getNewestMessageTimestamp*(s: StoreQueueRef): MessageStoreResult[Timestamp] =
|
||||
s.last().map(proc(msg: IndexedWakuMessage): Timestamp = msg.index.receiverTime)
|
||||
|
||||
|
||||
method deleteMessagesOlderThanTimestamp*(s: StoreQueueRef, ts: Timestamp): MessageStoreResult[void] =
|
||||
# TODO: Implement this message_store method
|
||||
err("interface method not implemented")
|
||||
|
||||
method deleteOldestMessagesNotWithinLimit*(s: StoreQueueRef, limit: int): MessageStoreResult[void] =
|
||||
# TODO: Implement this message_store method
|
||||
err("interface method not implemented")
|
Loading…
Reference in New Issue