Documentation
¶
Index ¶
- func ManagerType() interface{}
- func SubscribeRunnableChannel(c Channel) (chan interface{}, error)
- func UnsubscribeClosableChannel(c Channel, sub chan interface{}) error
- type Channel
- type Counter
- type Manager
- type NoopManager
- func (NoopManager) Close() error
- func (NoopManager) GetAllOnlineUsers() []string
- func (NoopManager) GetChannel(string) Channel
- func (NoopManager) GetCounter(string) Counter
- func (NoopManager) GetOnlineMap(string) OnlineMap
- func (NoopManager) RegisterChannel(string) (Channel, error)
- func (NoopManager) RegisterCounter(string) (Counter, error)
- func (NoopManager) RegisterOnlineMap(string) (OnlineMap, error)
- func (NoopManager) Start() error
- func (NoopManager) Type() interface{}
- func (NoopManager) UnregisterChannel(string) error
- func (NoopManager) UnregisterCounter(string) error
- func (NoopManager) UnregisterOnlineMap(string) error
- type OnlineMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ManagerType ¶
func ManagerType() interface{}
ManagerType returns the type of Manager interface. Can be used to implement common.HasType.
xray:api:stable
func SubscribeRunnableChannel ¶
SubscribeRunnableChannel subscribes the channel and starts it if there is first subscriber coming.
func UnsubscribeClosableChannel ¶
UnsubscribeClosableChannel unsubscribes the channel and close it if there is no more subscriber.
Types ¶
type Channel ¶
type Channel interface {
// Runnable implies that Channel is a runnable unit.
common.Runnable
// Publish broadcasts a message through the channel with a controlling context.
Publish(context.Context, interface{})
// Subscribers returns all subscribers.
Subscribers() []chan interface{}
// Subscribe registers for listening to channel stream and returns a new listener channel.
Subscribe() (chan interface{}, error)
// Unsubscribe unregisters a listener channel from current Channel object.
Unsubscribe(chan interface{}) error
}
Channel is the interface for stats channel.
xray:api:stable
type Counter ¶
type Counter interface {
// Value is the current value of the counter.
Value() int64
// Set sets a new value to the counter, and returns the previous one.
Set(int64) int64
// Add adds a value to the current counter value, and returns the previous value.
Add(int64) int64
}
Counter is the interface for stats counters.
xray:api:stable
type Manager ¶
type Manager interface {
features.Feature
// RegisterCounter registers a new counter to the manager. The identifier string must not be empty, and unique among other counters.
RegisterCounter(string) (Counter, error)
// UnregisterCounter unregisters a counter from the manager by its identifier.
UnregisterCounter(string) error
// GetCounter returns a counter by its identifier.
GetCounter(string) Counter
// RegisterOnlineMap registers a new onlinemap to the manager. The identifier string must not be empty, and unique among other onlinemaps.
RegisterOnlineMap(string) (OnlineMap, error)
// UnregisterOnlineMap unregisters a onlinemap from the manager by its identifier.
UnregisterOnlineMap(string) error
// GetOnlineMap returns a onlinemap by its identifier.
GetOnlineMap(string) OnlineMap
// RegisterChannel registers a new channel to the manager. The identifier string must not be empty, and unique among other channels.
RegisterChannel(string) (Channel, error)
// UnregisterChannel unregisters a channel from the manager by its identifier.
UnregisterChannel(string) error
// GetChannel returns a channel by its identifier.
GetChannel(string) Channel
// GetAllOnlineUsers returns all online users from all OnlineMaps.
GetAllOnlineUsers() []string
}
Manager is the interface for stats manager.
xray:api:stable
type NoopManager ¶
type NoopManager struct{}
NoopManager is an implementation of Manager, which doesn't has actual functionalities.
func (NoopManager) GetAllOnlineUsers ¶ added in v1.260113.0
func (NoopManager) GetAllOnlineUsers() []string
GetAllOnlineUsers implements Manager.
func (NoopManager) GetChannel ¶
func (NoopManager) GetChannel(string) Channel
GetChannel implements Manager.
func (NoopManager) GetCounter ¶
func (NoopManager) GetCounter(string) Counter
GetCounter implements Manager.
func (NoopManager) GetOnlineMap ¶ added in v1.250306.0
func (NoopManager) GetOnlineMap(string) OnlineMap
GetOnlineMap implements Manager.
func (NoopManager) RegisterChannel ¶
func (NoopManager) RegisterChannel(string) (Channel, error)
RegisterChannel implements Manager.
func (NoopManager) RegisterCounter ¶
func (NoopManager) RegisterCounter(string) (Counter, error)
RegisterCounter implements Manager.
func (NoopManager) RegisterOnlineMap ¶ added in v1.250306.0
func (NoopManager) RegisterOnlineMap(string) (OnlineMap, error)
RegisterOnlineMap implements Manager.
func (NoopManager) UnregisterChannel ¶
func (NoopManager) UnregisterChannel(string) error
UnregisterChannel implements Manager.
func (NoopManager) UnregisterCounter ¶
func (NoopManager) UnregisterCounter(string) error
UnregisterCounter implements Manager.
func (NoopManager) UnregisterOnlineMap ¶ added in v1.250306.0
func (NoopManager) UnregisterOnlineMap(string) error
UnregisterOnlineMap implements Manager.
type OnlineMap ¶ added in v1.250306.0
type OnlineMap interface {
// Count is the current value of the OnlineMap.
Count() int
// AddIP adds a ip to the current OnlineMap.
AddIP(string)
// List is the current OnlineMap ip list.
List() []string
// IpTimeMap return client ips and their last access time.
IpTimeMap() map[string]time.Time
}
OnlineMap is the interface for stats.
xray:api:stable