newbus

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus struct {
	Events map[string]*EventInfo
	// contains filtered or unexported fields
}

Bus存储event消息channel及其handler Events map{eventName: eventInfo}

var UBus *Bus

func NewBus

func NewBus() (*Bus, error)

func (*Bus) Dispatch

func (b *Bus) Dispatch(event string)

func (*Bus) Publish

func (b *Bus) Publish(event string, msg message.Message) error

func (*Bus) RegisterHandler

func (b *Bus) RegisterHandler(event string, handlerfunc HandlerFunc) error

type DataChannel

type DataChannel chan message.Message

DataChannel 是一个能接收 message 的 channel

type EventInfo

type EventInfo struct {
	EventMsg    DataChannel
	HandlerFunc HandlerFunc
}

EventMsg save event message

type HandlerFunc

type HandlerFunc func(msg *message.Message) error

HandlerFunc defines a handler function interface.

Jump to

Keyboard shortcuts

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