pubsub

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PubSub

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

PubSub contains channel and subscribers.

func New

func New(buffer int) (*PubSub, error)

New return new PubSub intreface.

func (*PubSub) Close

func (ps *PubSub) Close() error

Close closes PubSub. To inspect unbsubscribing for another subscruber, you must create message structure to notify them. After publish notifycations, Close should be called.

func (*PubSub) Publish

func (ps *PubSub) Publish(v interface{}) error

Publish will publish message to subscribers

func (*PubSub) Subscribe

func (ps *PubSub) Subscribe(s Subscriber) error

Subscribe subscribe to the PubSub.

func (*PubSub) UnSubscribe

func (ps *PubSub) UnSubscribe(s Subscriber)

UnSubscribe un subscribe to the PubSub.

type Subscriber

type Subscriber interface {
	// should be unique to used as a map key
	SubscriberName() string
	// receive message from publisher
	OnMessage(v interface{})
}

Subscriber is interface that who want to consume message

Jump to

Keyboard shortcuts

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