Skip to content

darjun/message-bus

 
 

Repository files navigation

🚌 message-bus

Build Status Go Report Card codecov FOSSA Status license

logo

Go simple async message bus.

📖 ABOUT

Contributors:

Want to contribute ? Feel free to send pull requests!

Have problems, bugs, feature ideas? We are using the github issue tracker to manage them.

📚 Documentation

For documentation (including examples), visit rafallorenz.com/message-bus

For GoDoc reference, visit godoc.org/github.com/vardius/message-bus

🚏 HOW TO USE

🚅 Benchmark

Time complexity of a Publish method is considered to be linear time O(n). Where n corresponds to the number of subscribers for a given topic.

CPU: 3,3 GHz Intel Core i7

RAM: 16 GB 2133 MHz LPDDR3

➜  message-bus git:(master) ✗ go test -bench=. -cpu=4 -benchmem
goos: darwin
goarch: amd64
pkg: github.com/vardius/message-bus
BenchmarkPublish-4                   	 4430224	       250 ns/op	       0 B/op	       0 allocs/op
BenchmarkSubscribe-4                 	  598240	      2037 ns/op	     735 B/op	       5 allocs/op

🏫 Basic example

package main

import (
    "fmt"
    "sync"

    "github.com/vardius/message-bus"
)

func main() {
    queueSize := 100
    bus := messagebus.New(queueSize)

    var wg sync.WaitGroup
    wg.Add(2)

    _ = bus.Subscribe("topic", func(v bool) {
        defer wg.Done()
        fmt.Println(v)
    })

    _ = bus.Subscribe("topic", func(v bool) {
        defer wg.Done()
        fmt.Println(v)
    })

    // Publish block only when the buffer of one of the subscribers is full.
    // change the buffer size altering queueSize when creating new messagebus
    bus.Publish("topic", true)
    wg.Wait()
}

🐳 Docker service

pubsub - gRPC message-oriented middleware on top of message-bus, event ingestion and delivery system.

📜 License

This package is released under the MIT license. See the complete license in the package:

FOSSA Status

About

Go simple async message bus

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%