notify

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddJobTimeout          = 1 * time.Second
	HeartbeatInterval      = 30 * time.Second
	ReadTimeout            = HeartbeatInterval * 4
	SendTimeout            = 5 * time.Second
	InstanceEventQueueSize = 5000
	ReadMaxBody            = 64
	Websocket              = "Websocket"
	GRPC                   = "gRPC"
)

Variables

Functions

func DoStreamListAndWatch

func DoStreamListAndWatch(ctx context.Context, serviceID string, f func() ([]*pb.WatchInstanceResponse, int64), stream proto.ServiceInstanceCtrl_WatchServer) (err error)

func DoWebSocketListAndWatch

func DoWebSocketListAndWatch(ctx context.Context, serviceID string, f func() ([]*pb.WatchInstanceResponse, int64), conn *websocket.Conn)

func EstablishWebSocketError

func EstablishWebSocketError(conn *websocket.Conn, err error)

func GetNotifyCenter

func GetNotifyCenter() *notify.Service

func HandleWatchJob

func HandleWatchJob(watcher *InstanceEventListWatcher, stream proto.ServiceInstanceCtrl_WatchServer) (err error)

func ReportPublishCompleted

func ReportPublishCompleted(evt notify.Event, err error)

func ReportSubscriber

func ReportSubscriber(domain, scheme string, n float64)

Types

type InstanceEvent

type InstanceEvent struct {
	notify.Event
	Revision int64
	Response *pb.WatchInstanceResponse
}

状态变化推送

func NewInstanceEvent

func NewInstanceEvent(serviceID, domainProject string, rev int64, response *pb.WatchInstanceResponse) *InstanceEvent

func NewInstanceEventWithTime

func NewInstanceEventWithTime(serviceID, domainProject string, rev int64, createAt simple.Time, response *pb.WatchInstanceResponse) *InstanceEvent

type InstanceEventListWatcher

type InstanceEventListWatcher struct {
	notify.Subscriber
	Job          chan *InstanceEvent
	ListRevision int64
	ListFunc     func() (results []*pb.WatchInstanceResponse, rev int64)
	// contains filtered or unexported fields
}

func NewInstanceEventListWatcher

func NewInstanceEventListWatcher(serviceID, domainProject string,
	listFunc func() (results []*pb.WatchInstanceResponse, rev int64)) *InstanceEventListWatcher

func (*InstanceEventListWatcher) Close

func (w *InstanceEventListWatcher) Close()

func (*InstanceEventListWatcher) OnAccept

func (w *InstanceEventListWatcher) OnAccept()

func (*InstanceEventListWatcher) OnMessage

func (w *InstanceEventListWatcher) OnMessage(job notify.Event)

被通知

func (*InstanceEventListWatcher) SetError

func (w *InstanceEventListWatcher) SetError(err error)

func (*InstanceEventListWatcher) Timeout

func (w *InstanceEventListWatcher) Timeout() time.Duration

type Publisher

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

func NewPublisher

func NewPublisher() *Publisher

func (*Publisher) Accept

func (wh *Publisher) Accept(ws *WebSocket)

func (*Publisher) Run

func (wh *Publisher) Run()

func (*Publisher) Stop

func (wh *Publisher) Stop()

type WebSocket

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

func (*WebSocket) HandleWatchWebSocketControlMessage

func (wh *WebSocket) HandleWatchWebSocketControlMessage()

func (*WebSocket) HandleWatchWebSocketJob

func (wh *WebSocket) HandleWatchWebSocketJob(o interface{})

HandleWatchWebSocketJob will be called if Pick() returns not nil

func (*WebSocket) Init

func (wh *WebSocket) Init() error

func (*WebSocket) Pick

func (wh *WebSocket) Pick() interface{}

Pick will be called by publisher

func (*WebSocket) ReadTimeout

func (wh *WebSocket) ReadTimeout() time.Duration

func (*WebSocket) Ready

func (wh *WebSocket) Ready() <-chan struct{}

func (*WebSocket) SendTimeout

func (wh *WebSocket) SendTimeout() time.Duration

func (*WebSocket) SetReady

func (wh *WebSocket) SetReady()

func (*WebSocket) Stop

func (wh *WebSocket) Stop()

func (*WebSocket) WriteMessage

func (wh *WebSocket) WriteMessage(message []byte) error

Jump to

Keyboard shortcuts

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