bus

package module
v0.1.0-alpha7 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

README

go-bus GoDoc Test

go-bus is a lightweight golang library for implementing the pub/sub pattern. It supports wildcard topics as well as dynamic topic subscription.

Usage

Basic pub/sub usage:

package main

import (
	"fmt"
	"github.com/qryio/go-bus"
)

func main() {
	b := bus.New()
	sub := b.Subscribe([]string{"my", "topic"}, func(t []string, s *bus.Subscription, p interface{}) {
		fmt.Printf("%v world", p)
	})
	b.Publish([]string{"my", "topic"}, "hello")
	sub.Terminate()
}

Check out more examples

License

Code and documentation released under Apache License 2.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus struct {
	// contains filtered or unexported fields
}

func New

func New() *Bus

func (*Bus) Publish

func (b *Bus) Publish(t []string, p interface{})

func (*Bus) Subscribe

func (b *Bus) Subscribe(t []string, h Handler) *Subscription

type Handler

type Handler func(t []string, s *Subscription, p interface{})

type Subscription

type Subscription struct {
	// contains filtered or unexported fields
}

func (*Subscription) Terminate

func (s *Subscription) Terminate()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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