polarstreams/polar

Support consuming without long lived connections

Closed this issue · 0 comments

Currently we support producing in a stateless manner, for example you can send a message :

curl -X POST -d '{"hello":"world"}' \
    -H "Content-Type: application/json" \
    "http://barco.streams:9251/v1/topic/my-topic/messages"

It would be awesome if we could also support the same level of client statelessness for consumers, to enable stuff like curl for consuming, for example:

curl -X PUT "http://barco.streams:9252/v1/consumer/register?consumer_id=1"
curl -X POST -H "Accept: application/vnd.barco.consumermessage+json" \ 
    "http://barco.streams:9252/v1/consumer/poll?consumer_id=1"

This would represent a registration of a consumer with id "1", belonging to the "default" consumer group, to get data from all topics, followed by a request to poll the data. The poll response would contain multiple messages:

[
  {
    "topic": "my-topic",
    "token": "-9223372036854775808",
    "rangeIndex": "1",
    "version": "1",
    "startOffset": 123
    "values": [
      {"hello": 1},
      {"hello": 2},
      {"hello": 3}
    ]
  }
]