core: Index | Files

package stats

import ""


Package Files

errors.generated.go stats.go

func ManagerType Uses

func ManagerType() interface{}

ManagerType returns the type of Manager interface. Can be used to implement common.HasType.


func SubscribeRunnableChannel Uses

func SubscribeRunnableChannel(c Channel) (chan interface{}, error)

SubscribeRunnableChannel subscribes the channel and starts it if there is first subscriber coming.

func UnsubscribeClosableChannel Uses

func UnsubscribeClosableChannel(c Channel, sub chan interface{}) error

UnsubscribeClosableChannel unsubcribes the channel and close it if there is no more subscriber.

type Channel Uses

type Channel interface {
    // Channel is a runnable unit.
    // Publish broadcasts a message through the channel with a controlling context.
    Publish(context.Context, interface{})
    // SubscriberCount returns the number of the 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.


func GetOrRegisterChannel Uses

func GetOrRegisterChannel(m Manager, name string) (Channel, error)

GetOrRegisterChannel tries to get the StatChannel first. If not exist, it then tries to create a new channel.

type Counter Uses

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.


func GetOrRegisterCounter Uses

func GetOrRegisterCounter(m Manager, name string) (Counter, error)

GetOrRegisterCounter tries to get the StatCounter first. If not exist, it then tries to create a new counter.

type Manager Uses

type Manager interface {

    // 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

    // RegisterChannel registers a new channel to the manager. The identifier string must not be empty, and unique among other channels.
    RegisterChannel(string) (Channel, error)
    // UnregisterCounter unregisters a channel from the manager by its identifier.
    UnregisterChannel(string) error
    // GetChannel returns a channel by its identifier.
    GetChannel(string) Channel

Manager is the interface for stats manager.


type NoopManager Uses

type NoopManager struct{}

NoopManager is an implementation of Manager, which doesn't has actual functionalities.

func (NoopManager) Close Uses

func (NoopManager) Close() error

Close implements common.Closable.

func (NoopManager) GetChannel Uses

func (NoopManager) GetChannel(string) Channel

GetChannel implements Manager.

func (NoopManager) GetCounter Uses

func (NoopManager) GetCounter(string) Counter

GetCounter implements Manager.

func (NoopManager) RegisterChannel Uses

func (NoopManager) RegisterChannel(string) (Channel, error)

RegisterChannel implements Manager.

func (NoopManager) RegisterCounter Uses

func (NoopManager) RegisterCounter(string) (Counter, error)

RegisterCounter implements Manager.

func (NoopManager) Start Uses

func (NoopManager) Start() error

Start implements common.Runnable.

func (NoopManager) Type Uses

func (NoopManager) Type() interface{}

Type implements common.HasType.

func (NoopManager) UnregisterChannel Uses

func (NoopManager) UnregisterChannel(string) error

UnregisterChannel implements Manager.

func (NoopManager) UnregisterCounter Uses

func (NoopManager) UnregisterCounter(string) error

UnregisterCounter implements Manager.

Package stats imports 4 packages (graph) and is imported by 55 packages. Updated 2020-10-15. Refresh now. Tools for package owners.