mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-07-25 22:13:12 +00:00
chore(rest): refactor message cache (#2221)
This commit is contained in:
@@ -229,11 +229,11 @@ when isMainModule:
|
||||
|
||||
# Install enabled API handlers:
|
||||
if conf.relay:
|
||||
let cache = MessageCache[string].init(capacity=30)
|
||||
let cache = MessageCache.init(capacity=30)
|
||||
installRelayApiHandlers(node, rpcServer, cache)
|
||||
|
||||
if conf.filter:
|
||||
let messageCache = filter_api.MessageCache.init(capacity=30)
|
||||
let messageCache = MessageCache.init(capacity=30)
|
||||
installFilterApiHandlers(node, rpcServer, messageCache)
|
||||
|
||||
if conf.store:
|
||||
|
||||
+11
-13
@@ -687,18 +687,17 @@ proc startRestServer(app: App, address: ValidIpAddress, port: Port, conf: WakuNo
|
||||
|
||||
## Relay REST API
|
||||
if conf.relay:
|
||||
let cache = MessageCache[string].init(capacity=conf.restRelayCacheCapacity)
|
||||
let cache = MessageCache.init(int(conf.restRelayCacheCapacity))
|
||||
|
||||
let handler = messageCacheHandler(cache)
|
||||
let autoHandler = autoMessageCacheHandler(cache)
|
||||
|
||||
for pubsubTopic in conf.pubsubTopics:
|
||||
cache.subscribe(pubsubTopic)
|
||||
cache.pubsubSubscribe(pubsubTopic)
|
||||
app.node.subscribe((kind: PubsubSub, topic: pubsubTopic), some(handler))
|
||||
|
||||
for contentTopic in conf.contentTopics:
|
||||
cache.subscribe(contentTopic)
|
||||
app.node.subscribe((kind: ContentSub, topic: contentTopic), some(autoHandler))
|
||||
cache.contentSubscribe(contentTopic)
|
||||
app.node.subscribe((kind: ContentSub, topic: contentTopic), some(handler))
|
||||
|
||||
installRelayApiHandlers(server.router, app.node, cache)
|
||||
else:
|
||||
@@ -709,10 +708,10 @@ proc startRestServer(app: App, address: ValidIpAddress, port: Port, conf: WakuNo
|
||||
app.node.wakuFilterClient != nil and
|
||||
app.node.wakuFilterClientLegacy != nil:
|
||||
|
||||
let legacyFilterCache = rest_legacy_filter_api.MessageCache.init()
|
||||
let legacyFilterCache = MessageCache.init()
|
||||
rest_legacy_filter_api.installLegacyFilterRestApiHandlers(server.router, app.node, legacyFilterCache)
|
||||
|
||||
let filterCache = rest_filter_api.MessageCache.init()
|
||||
let filterCache = MessageCache.init()
|
||||
|
||||
let filterDiscoHandler =
|
||||
if app.wakuDiscv5.isSome():
|
||||
@@ -765,23 +764,22 @@ proc startRpcServer(app: App, address: ValidIpAddress, port: Port, conf: WakuNod
|
||||
installDebugApiHandlers(app.node, server)
|
||||
|
||||
if conf.relay:
|
||||
let cache = MessageCache[string].init(capacity=30)
|
||||
let cache = MessageCache.init(capacity=50)
|
||||
|
||||
let handler = messageCacheHandler(cache)
|
||||
let autoHandler = autoMessageCacheHandler(cache)
|
||||
|
||||
for pubsubTopic in conf.pubsubTopics:
|
||||
cache.subscribe(pubsubTopic)
|
||||
cache.pubsubSubscribe(pubsubTopic)
|
||||
app.node.subscribe((kind: PubsubSub, topic: pubsubTopic), some(handler))
|
||||
|
||||
for contentTopic in conf.contentTopics:
|
||||
cache.subscribe(contentTopic)
|
||||
app.node.subscribe((kind: ContentSub, topic: contentTopic), some(autoHandler))
|
||||
cache.contentSubscribe(contentTopic)
|
||||
app.node.subscribe((kind: ContentSub, topic: contentTopic), some(handler))
|
||||
|
||||
installRelayApiHandlers(app.node, server, cache)
|
||||
|
||||
if conf.filternode != "":
|
||||
let filterMessageCache = rpc_filter_api.MessageCache.init(capacity=30)
|
||||
let filterMessageCache = MessageCache.init(capacity=50)
|
||||
installFilterApiHandlers(app.node, server, filterMessageCache)
|
||||
|
||||
installStoreApiHandlers(app.node, server)
|
||||
|
||||
Reference in New Issue
Block a user