Skip to content

pubsub is a Go module that offers a concurrent pub/sub service leveraging goroutines and channels.

License

Notifications You must be signed in to change notification settings

pascalallen/pubsub

Repository files navigation

pubsub

Go Reference GitHub go.mod Go version Go Report Card GitHub Workflow Status (with branch) GitHub GitHub code size in bytes

pubsub is a Go module that offers a concurrent pub/sub service leveraging goroutines and channels.

Installation

Use the Go CLI tool go to install hmac.

go get github.com/pascalallen/pubsub

Usage

...

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:

go test -covermode=count -coverprofile=coverage.out

View test coverage profile:

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

About

pubsub is a Go module that offers a concurrent pub/sub service leveraging goroutines and channels.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages