https://github.com/pascalallen/pubsub
pubsub is a Go module that offers a concurrent pub/sub service leveraging goroutines and channels.
https://github.com/pascalallen/pubsub
Last synced: over 1 year ago
JSON representation
pubsub is a Go module that offers a concurrent pub/sub service leveraging goroutines and channels.
- Host: GitHub
- URL: https://github.com/pascalallen/pubsub
- Owner: pascalallen
- License: mit
- Created: 2023-03-23T16:20:14.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-29T15:57:24.000Z (about 3 years ago)
- Last Synced: 2025-01-06T05:41:49.895Z (over 1 year ago)
- Language: Go
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pubsub
[](https://pkg.go.dev/github.com/pascalallen/pubsub)

[](https://goreportcard.com/report/github.com/pascalallen/pubsub)



pubsub is a Go module that offers a concurrent pub/sub service leveraging goroutines and channels.
## Installation
Use the Go CLI tool [go](https://go.dev/dl/) to install hmac.
```bash
go get github.com/pascalallen/pubsub
```
## Usage
```go
...
import (
"fmt"
"github.com/pascalallen/pubsub"
)
...
c := make(chan pubsub.Message)
t := pubsub.CreateTopic("my-topic", c)
m := pubsub.CreateMessage([]byte("hello, jupiter!"))
t.AddMessage(*m)
s := pubsub.CreateSubscriber("my-subscription", *t, c)
go t.Publish()
for m := range s.Channel {
fmt.Printf("Message received for subscriber %s: %s\n", s.Name, m)
}
...
```
## Testing
Run tests and create coverage profile:
```bash
go test -covermode=count -coverprofile=coverage.out
```
View test coverage profile:
```bash
go tool cover -html=coverage.out
```
## Contributing
Pull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.
Please make sure to update tests as appropriate.
## License
[MIT](LICENSE)