Skip to content

Latest commit

 

History

History
77 lines (54 loc) · 1.87 KB

README.md

File metadata and controls

77 lines (54 loc) · 1.87 KB

mqueue (Go)

In-memory message broker in Go over an HTTP API using a concurrent, thread-safe publisher/subscriber architecture with multiple topics.

Installation

$ go get github.com/ridwanmsharif/mqueue
$ cd $GOPATH/src/github.com/ridwanmsharif/mqueue/
$ go build -o mqueue
$ ./mqueue

Listening on :8081, ready for client/terminal use.

Examples/Usage

Subscriber (client library)

  ch, err := client.Subscribe("topic_of_your_choice")
  if err != nil {
    log.Println(err)
    return
  }

  for e := range ch {
    log.Println(string(e))
  }

  log.Println("Channel closed")

Publisher (client library)

  err := client.Publish("topic_of_your_choice", []byte("Arbitrary Message"))
  if err != nil {
      log.Println(err)
  }

Subscriber (command line)

curl -k -i -N -H "Connection: Upgrade" \
    -H "Upgrade: websocket" \
    -H "Host: localhost:8081" \
    -H "Origin:http://localhost:8081" \
    -H "Sec-Websocket-Version: 13" \
    -H "Sec-Websocket-Key: MQ" \
    "https://localhost:8081/sub?topic=
    topic_of_your_choice"

Publisher (command line)

curl -d "Any message you wish to post""http://localhost:8081/pub?topic=topic_of_your_choice"

Disclaimer

Purely experimental project. Designed for learning purposes not production use. This weas my first project in Go, the implementation here is largely based on asim/mq, I'm tracking his incremental progress and repeating the same

Contributing

Bug reports and pull requests are welcome on GitHub at @ridwanmsharif

Author

Ridwan M. Sharif: E-mail, @ridwanmsharif

License

The command line utility is available as open source under the terms of the MIT License