plugin pubsub cache: more resilient node caching:
- cache only latest 20 items when disco infos are hidden and thus we can't discover feature/RSM implementation - better handling of args when calling `storage.getItems` rel 365
This commit is contained in:
parent
d20e609a5c
commit
4e441258b3
1 changed files with 19 additions and 2 deletions
|
|
@ -277,6 +277,19 @@ class PubsubCache:
|
|||
await self.host.checkFeatures(
|
||||
client, [rsm.NS_RSM, self._p.DISCO_RSM], pubsub_node.service
|
||||
)
|
||||
except error.StanzaError as e:
|
||||
if e.condition == "service-unavailable":
|
||||
log.warning(
|
||||
"service is hidding disco infos, we'll only cache latest 20 items"
|
||||
)
|
||||
items, __ = await client.pubsub_client.items(
|
||||
pubsub_node.service, pubsub_node.name, maxItems=20
|
||||
)
|
||||
await self.cacheItems(
|
||||
client, pubsub_node, items
|
||||
)
|
||||
else:
|
||||
raise e
|
||||
except exceptions.FeatureNotFound:
|
||||
log.warning(
|
||||
f"service {service} doesn't handle Result Set Management "
|
||||
|
|
@ -493,12 +506,16 @@ class PubsubCache:
|
|||
raise NotImplementedError("MAM queries are not supported yet")
|
||||
if max_items is None and rsm_request is None:
|
||||
max_items = 20
|
||||
if max_items is not None:
|
||||
pubsub_items, metadata = await self.host.memory.storage.getItems(
|
||||
node, max_items=max_items, item_ids=item_ids,
|
||||
order_by=extra.get(C.KEY_ORDER_BY)
|
||||
)
|
||||
elif max_items is not None:
|
||||
if rsm_request is not None:
|
||||
raise exceptions.InternalError(
|
||||
"Pubsub max items and RSM must not be used at the same time"
|
||||
)
|
||||
elif item_ids is None:
|
||||
elif item_ids:
|
||||
raise exceptions.InternalError(
|
||||
"Pubsub max items and item IDs must not be used at the same time"
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue