bus

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TopicMatch

func TopicMatch(topic []byte, topicFilter []byte) bool

TopicMatch 返回topic和topic filter是否

TopicMatch returns whether the topic and topic filter is matched.

Types

type Bus

type Bus interface {
	// Publish publishes arguments to the given topic subscribers
	// Publish block only when the buffer of one of the subscribers is full.
	Publish(topic string, args ...interface{})
	// CloseTopic unsubscribe all subscribers from given topic
	CloseTopic(topic string)
	// Subscribe subscribes to the given topic
	Subscribe(topic string, fn interface{}, options ...interface{}) error
	// Unsubscribe handler from the given topic
	Unsubscribe(topic string, fn interface{}) error
	// Stat ...
	Stat(ctx context.Context, limit, offset int64, orderBy, sort string) (stats Stats, total int64, err error)
	// Purge ...
	Purge()
}

Bus implements publish/subscribe messaging paradigm

func NewBus

func NewBus() Bus

NewBus ...

type RPSCounter added in v0.16.0

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

func (*RPSCounter) Inc added in v0.16.0

func (c *RPSCounter) Inc()

func (*RPSCounter) Stop added in v0.16.0

func (c *RPSCounter) Stop()

func (*RPSCounter) Value added in v0.16.0

func (c *RPSCounter) Value() float64

type StatItem added in v0.16.0

type StatItem struct {
	Topic       string
	Subscribers int
	Min         time.Duration
	Max         time.Duration
	Avg         time.Duration
	Rps         float64
}

StatItem ...

type Statistic added in v0.16.0

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

func NewStatistic added in v0.16.0

func NewStatistic() *Statistic

type Stats

type Stats []*StatItem

Stats ...

func (Stats) Len

func (s Stats) Len() int

func (Stats) Less

func (s Stats) Less(i, j int) bool

func (Stats) Swap

func (s Stats) Swap(i, j int)

type Topic added in v0.16.0

type Topic struct {
	*Statistic
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewTopic added in v0.16.0

func NewTopic(name string) *Topic

func (*Topic) Close added in v0.16.0

func (t *Topic) Close()

func (*Topic) Publish added in v0.16.0

func (t *Topic) Publish(args ...interface{})

func (*Topic) Stat added in v0.16.0

func (t *Topic) Stat() *StatItem

func (*Topic) Subscribe added in v0.16.0

func (t *Topic) Subscribe(fn interface{}, options ...interface{}) error

func (*Topic) Unsubscribe added in v0.16.0

func (t *Topic) Unsubscribe(fn interface{}) (empty bool, err error)

Jump to

Keyboard shortcuts

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