Skip to content

v1nte/pubsub-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PubSub Patern in Go

Implementation of Publisher and Suscribers patter in Go

How to run

You can, maybe, run mongodb on your own, an then do something like go run main.go. But, I highly recommend you to just use docker compose as:

docker compose up

And you're ready to go.

Usage

Connect

You'll need a websocket client, either build one or use one like wscat as I do. Connect to ws://localhost:9876/ws

All comunnication must be in json format

First Message

First message have to be a name otherwise it'll close the connection: e.g.:

{ "name": "Jhon" }

Subscribe

Then you can subscribe to a topic with the SUB command to receive messages from a topic:

{ "Command": "SUB", "Topic": "news" }

Publish

Or, send message to a topic with PUB command. You can send a message without being subscribed to it. Feature, not a bug.

{
  "Command": "PUB",
  "Topic": "Sports",
  "Message": "Germany 7-1 Brazil"
}

Features

  • Subscribe
  • Unsubscribe
  • Unsubscribe all
  • Send msg via Broker
  • Handle multiples clients
  • Include name in messages
  • Use channels
  • Dockerize
  • Logs
  • DB connection
  • Auth

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors