messagebus

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2017 License: MIT Imports: 3 Imported by: 35

README

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

Basic example

package main

import (
    "fmt"

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

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

    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

Documentation

Overview

Package messagebus provides simple async message publisher

Basic example:

package main

import (
	"fmt"

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

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

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageBus

type MessageBus interface {
	Publish(topic string, args ...interface{})
	Subscribe(topic string, fn interface{}) error
	Unsubscribe(topic string, fn interface{}) error
}

MessageBus implements publish/subscribe messaging paradigm

func New

func New() MessageBus

New creates new MessageBus

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL