Go simple async message bus
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
.gitignore
.hound.yml
.travis.yml
LICENSE.md
README.md
benchmark_test.go
bus.go
bus_test.go
doc.go
example_test.go

README.md

Vardius - message-bus

Build Status Go Report Card codecov license

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.

HOW TO USE

  1. GoDoc

Benchmark

CPU: 3,3 GHz Intel Core i7

RAM: 16 GB 2133 MHz LPDDR3

goos: darwin
goarch: amd64
pkg: github.com/vardius/message-bus
BenchmarkWorker100-4                           3         352169727 ns/op
BenchmarkWorkerNumCPU-4                        5         301247338 ns/op
BenchmarkWorker-4                             10         182287824 ns/op
BenchmarkWorker100Parallel-4                  10         117857721 ns/op
BenchmarkWorkerNumCPUParallel-4               10         113668659 ns/op
BenchmarkWorkerParallel-4                     10         105661820 ns/op
PASS
ok      github.com/vardius/message-bus  15.889s

Basic example

package main

import (
    "fmt"
    "runtime"

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

func main() {
    bus := messagebus.New(runtime.NumCPU())

    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)
    })

    bus.Publish("topic", true)
    wg.Wait()
}

License

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

LICENSE