go-libp2p-pubsub
go-libp2p-pubsub copied to clipboard
Enabling applications to remove/override messages in the message queue
Discussed in #240 and #217
Some applications send messages which can render previous messages obsolete (e.g. I originally sent version 1, but now am sending version 2 of some data). In these cases it would be great if instead of the pubsub queue being backed up we could simply send less messages by not sending the obsolete messages.
Two example approaches to handle this might be:
- Using topic options to handle shrinking the queue within pubsub
- Add an topic option for a
Merge(M1,M2 RPC) RPCfunction`- Could also use something simpler like
FirstBetter(M1, M2) bool
- Could also use something simpler like
- Senders could have a per topic queue (relates to, but is not dependent on #210)
- When adding to the topic queue run the merge function to determine the new message (or keep both messages)
- Add the new message to the per topic queue
- Add an topic option for a
- Exposing more data (e.g. via events/callbacks) outside of pubsub
- Add a trigger to allow cancelling published messages
- Add an event to learn about slow peers
- If a peer is "too slow" then fire an event that causes the application to cancel the message
- Add a callback for when messages would be dropped to figure out what to do with them (e.g. drop, keep)
@protolambda wanted this too