Skip to content
/ dsps Public

Durable & Simple PubSub system

License

Notifications You must be signed in to change notification settings

saiya/dsps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DSPS - Durable & Simple PubSub

DSPS Banner

MIT License Server Test Codecov Go Report Card DockerHub saiya/dsps npm version


Intro

DSPS is a PubSub server that provides following advantages:

  • Durable message handling
    • No misfire, supports buffering & resending & deduplication
  • Simple messaging interface
    • Just curl is enough to communicate with the DSPS server
    • Supports JWT to control access simply
    • Also supports outgoing webhook

DSPS system diagram

Non goal

Note that DSPS does not aim to provide followings:

  • Very low latency message passing
    • DSPS suppose milliseconds latency tolerant use-case
  • Too massive message flow rate comparing to your storage spec
    • DSPS temporary stores messages to resend message
  • Warehouse to keep long-living message
    • DSPS aim to provide message passing, not archiving message

3 minutes to getting started with DSPS

# Download & run DSPS server
docker run --rm -p 3099:3000/tcp saiya/dsps:latest

#
# ... Open another terminal window to run following tutorial ...
#

CHANNEL="my-channel"
SUBSCRIBER="my-subscriber"

# Create a HTTP polling subscriber.
curl -X PUT "http://localhost:3099/channel/${CHANNEL}/subscription/polling/${SUBSCRIBER}"

# Publish message to the channel.
curl -X PUT -H "Content-Type: application/json" \
  -d '{ "hello": "Hi!" }' \
  "http://localhost:3099/channel/${CHANNEL}/message/my-first-message"

# Receive messages with HTTP long-polling.
# In this example, this API immediately returns
# because the subscriber already have been received a message.
curl -X GET "http://localhost:3099/channel/${CHANNEL}/subscription/polling/${SUBSCRIBER}?timeout=30s&max=64"

ACK_HANDLE="<< set string returned in the above API response >>"

# Cleanup received messages from the subscriber.
curl -i -X DELETE \
  "http://localhost:3099/channel/${CHANNEL}/subscription/polling/${SUBSCRIBER}/message?ackHandle=${ACK_HANDLE}"

Tips: see server interface documentation for more API interface detail.

Message resending - you have to DELETE received messages

You may notice that your receive same messages every time you GET the subscriber endpoint. Because DSPS resend messages until you explicitly delete it to prevent message loss due to network/client error.

The way to delete message depends on the subscriber type. For example, HTTP polling subscriber (used in above example) supports HTTP DELETE method to remove messages from the subscriber.

More Documentations