Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pengux/pub-sub
Example of pub-sub in Go
https://github.com/pengux/pub-sub
Last synced: about 2 months ago
JSON representation
Example of pub-sub in Go
- Host: GitHub
- URL: https://github.com/pengux/pub-sub
- Owner: pengux
- License: gpl-3.0
- Created: 2015-11-23T23:08:25.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-25T16:58:34.000Z (about 9 years ago)
- Last Synced: 2024-06-20T15:01:12.937Z (7 months ago)
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pub-sub
Example of pub-sub in Go using simple maps## How to run
```sh
go get
go run main.go
```
then point your requests at [http://localhost:8080](http://localhost:8080)to run the tests:
```sh
go test -race
```## API
### Publisher:
- publishing: POST /:topic_name with JSON body as a message (response 204)### Subscriber:
- subscribing: POST /:topic_name/:subscriber_name (response 201)
- unsubscribing: DELETE /:topic_name/:subscriber_name (response 204)
- polling: GET /:topic_name/:subscriber_name (200 with JSON body as a message or 404 if no subscription found or 204 if no new messages are available)### Message format:
```
{
"message" : "variable content string",
"published" : "date" // returned only for polling
}
```## Improvements
- Make the pub-sub non-locking
- Add tests for concurrency
- Use in a demo chat application