atomix / atomix

A Kubernetes toolkit for building distributed applications using cloud native principles

Home Page:https://atomix.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Queues need a take / poll that behaves like a real take / poll

doctorpangloss opened this issue · comments

Is your feature request related to a problem? Please describe.

Repeatedly polling for items on a queue is an awful replacement for a real poll.

Describe the solution you'd like

poll(long timeout) (take()) returns a CompleteableFuture that only completes once, in the cluster, with an item. poll(long timeout) completes with null if it times out.

Describe alternatives you've considered

Sleeping and looping.

Additional context

WorkQueue and broadcast messaging aren't really the same thing here. I want a queue that actually works like an async queue! It's such a useful primitive.

The current work around I'm using involves broadcasting to all nodes when an item is added to the queue (i.e., notEmpty.signal). It's easier to use signalAll instead of trying to show that you have a real condition.