Documentation ¶
Index ¶
- Constants
- Variables
- func DoStreamListAndWatch(ctx context.Context, serviceID string, ...) (err error)
- func DoWebSocketListAndWatch(ctx context.Context, serviceID string, ...)
- func EstablishWebSocketError(conn *websocket.Conn, err error)
- func GetNotifyCenter() *notify.Service
- func HandleWatchJob(watcher *InstanceEventListWatcher, ...) (err error)
- func ReportPublishCompleted(evt notify.Event, err error)
- func ReportSubscriber(domain, scheme string, n float64)
- type InstanceEvent
- type InstanceEventListWatcher
- type Publisher
- type WebSocket
- func (wh *WebSocket) HandleWatchWebSocketControlMessage()
- func (wh *WebSocket) HandleWatchWebSocketJob(o interface{})
- func (wh *WebSocket) Init() error
- func (wh *WebSocket) Pick() interface{}
- func (wh *WebSocket) ReadTimeout() time.Duration
- func (wh *WebSocket) Ready() <-chan struct{}
- func (wh *WebSocket) SendTimeout() time.Duration
- func (wh *WebSocket) SetReady()
- func (wh *WebSocket) Stop()
- func (wh *WebSocket) WriteMessage(message []byte) error
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 ¶
View Source
var INSTANCE = notify.RegisterType("INSTANCE", InstanceEventQueueSize)
Functions ¶
func DoStreamListAndWatch ¶
func DoStreamListAndWatch(ctx context.Context, serviceID string, f func() ([]*pb.WatchInstanceResponse, int64), stream proto.ServiceInstanceCtrl_WatchServer) (err error)
func DoWebSocketListAndWatch ¶
func EstablishWebSocketError ¶
func GetNotifyCenter ¶
func HandleWatchJob ¶
func HandleWatchJob(watcher *InstanceEventListWatcher, stream proto.ServiceInstanceCtrl_WatchServer) (err error)
func ReportPublishCompleted ¶
func ReportSubscriber ¶
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
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) ReadTimeout ¶
func (*WebSocket) SendTimeout ¶
func (*WebSocket) WriteMessage ¶
Click to show internal directories.
Click to hide internal directories.