pubsub

package
v0.0.0-...-e4caca2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDriver

func AddDriver(driver Interface)

func DriverName

func DriverName() string

func Drivers

func Drivers() map[string]Interface

func Publish

func Publish(topic string, message []byte, params ...interface{}) error

func Register

func Register() error

func SetDefaultDriver

func SetDefaultDriver(driver Interface)

func Subscribe

func Subscribe(topic string, onMessage func(topic string, message []byte, driver Interface), params ...interface{})

Types

type Interface

type Interface interface {
	Name() string
	Register() error
	Subscribe(topic string, onMessage func(topic string, message []byte, driver Interface), params ...interface{})
	Publish(topic string, message []byte, params ...interface{}) error

	// SetMarshaller set interface{} to []byte marshalling function
	SetMarshaller(func(input interface{}) ([]byte, error))

	// SetUnMarshaller set []byte to interface{} unmarshalling function
	SetUnMarshaller(func(bytes []byte, out interface{}) error)
}

func Driver

func Driver(driver string) (Interface, bool)

func Use

func Use(driver string) Interface

type Message

type Message struct {
	Time    time.Time
	Message []byte
}

Directories

Path Synopsis
drivers

Jump to

Keyboard shortcuts

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