subscribe

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheRemove

func CacheRemove(ctx context.Context, keys ...interface{})

func NewSubPub

func NewSubPub() *subPub

NewSubPub return a subPub

func ProcessMetricMsg

func ProcessMetricMsg(sub *rpc.Subscription, metrics []prometheus.Metric) (send bool, out map[string]interface{})

Types

type INotifier

type INotifier interface {
	Notify(key string, data interface{}) error
	Err() <-chan error
}

type Notifier

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

func NewNotifier

func NewNotifier(n *rpc.Notifier, sub *rpc.Subscription) *Notifier

NewNotifier wrap *rpc.INotifier to meet the interface named INotifier

func (*Notifier) Err

func (n *Notifier) Err() <-chan error

func (*Notifier) Notify

func (n *Notifier) Notify(_ string, data interface{}) error

type NotifierWithDelay

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

func NewNotifierWithDelay

func NewNotifierWithDelay(notifier *rpc.Notifier, sub *rpc.Subscription, delay int, sendArray bool) *NotifierWithDelay

NewNotifierWithDelay wrap *rpc.INotifier to add some extra features

func (*NotifierWithDelay) Err

func (n *NotifierWithDelay) Err() <-chan error

func (*NotifierWithDelay) Notify

func (n *NotifierWithDelay) Notify(key string, data interface{}) error

type NotifierWithMsgChan

type NotifierWithMsgChan struct {
	MsgChan chan interface{} // msg will be sent to this chan
	ErrChan chan error       // close this chan if you want to unsubscribe
}

func NewNotifierWithMsgChan

func NewNotifierWithMsgChan() *NotifierWithMsgChan

NewNotifierWithMsgChan return a notifier which will use method named Notify to send message to a field named MsgChan in the notifier

func (*NotifierWithMsgChan) Err

func (n *NotifierWithMsgChan) Err() <-chan error

func (*NotifierWithMsgChan) Notify

func (n *NotifierWithMsgChan) Notify(_ string, data interface{}) error

type SubPub

type SubPub interface {
	// Subscribe a subscription,creates a mapping from nameSpace_kind_param to INotifier
	Subscribe(iNotifier INotifier, nameSpace string, kind string, param string) error
	// Publish finds the notifier corresponding to the key nameSpace_kind_param, and then calls the Notify method of
	// notify to publish message
	Publish(nameSpace string, kind string, param string, message interface{}) error
	// PublishArray finds the notifier corresponding to the key nameSpace_kind_param, and then calls the Notify method of
	// notify to publish a group of message
	PublishArray(nameSpace string, kind string, field string, messageList []interface{}) error
}

Jump to

Keyboard shortcuts

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