Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Latest commit

 

History

History

nats_example

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

NATS example

To run the example, first run the nats server using docker

docker run --rm -it -p 4222:4222 nats

Then, in another terminal session start the topic publisher

cd publisher
go run publisher.go

You can also configure how many topics the publisher should create and at what time interval every message is sent.

go run publisher.go --topics 100 --interval 1s

Then start the unifrost example server

go run main.go

Connect to the event streamer using the EventSource API in the browser or by using good old curl

curl 'localhost:3000/events?id=unique_id'

And in another terminal update the subscriptions of the consumer

curl -d '{"consumer_id": "unique_id", "add": ["topic1", "topic2"], "remove": []}' -XPOST 'localhost:3000/update_subscriptions'