Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phonkee/go-pubsub
simple pubsub for golang.
https://github.com/phonkee/go-pubsub
Last synced: 8 days ago
JSON representation
simple pubsub for golang.
- Host: GitHub
- URL: https://github.com/phonkee/go-pubsub
- Owner: phonkee
- License: mit
- Created: 2017-09-29T21:36:38.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-30T13:52:33.000Z (almost 6 years ago)
- Last Synced: 2024-08-01T13:28:42.190Z (3 months ago)
- Language: Go
- Size: 8.79 KB
- Stars: 6
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-pubsub
Simple publish subscribe queue. This is available only inside application.
There is no intent to make this span across processes/machines.## Examples
```go
ps := pubsub.New()
subscriber := ps.Subscribe("user:1", "user:2").Do(func(message Message) {
println("We got meessage on topic", message.Topic())
})defer subscriber.Close()
count := ps.Publish(NewMessage("user:1:username", "hello"))
fmt.Printf("Published messages to %v subscribers", count)
```
go-pubsub has also default Hub, if you don't need to track your own Hub.
```go
subscriber := pubsub.Subscribe("user:1", "user:2").Do(func(message Message) {
println("We got meessage on topic", message.Topic())
})defer subscriber.Close()
count := pubsub.Publish(NewMessage("user:1:username", "hello"))
fmt.Printf("Published messages to %v subscribers", count)
```
# tests
If you want to run tests, you need goconvey to be installed. You can install it by typing:
$ go get github.com/smartystreets/goconvey
and then you can run
go test
or you can run goconvey for more info, navigate into go-pubsub directory and run:
goconvey
# author
Peter Vrba