usage

package
v3.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LastSentUpdateNotificationOp is an op for Centrifuge Notification in which we
	// send last sent time to all nodes.
	LastSentUpdateNotificationOp = "usage_stats.last_sent_at"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Features

type Features struct {
	// Build info.
	Version string
	Edition string

	// Engine or broker usage.
	Engine     string
	EngineMode string
	Broker     string
	BrokerMode string

	// Transports.
	Websocket     bool
	HTTPStream    bool
	SSE           bool
	SockJS        bool
	UniWebsocket  bool
	UniGRPC       bool
	UniSSE        bool
	UniHTTPStream bool

	// Proxies.
	ConnectProxy   bool
	RefreshProxy   bool
	SubscribeProxy bool
	PublishProxy   bool
	RPCProxy       bool

	// Uses GRPC server API.
	GrpcAPI bool
	// Admin interface enabled.
	Admin bool
	// Uses automatic personal channel subscribe.
	SubscribeToPersonal bool

	// PRO features.
	ClickhouseAnalytics bool
	UserStatus          bool
	Throttling          bool
	Singleflight        bool
}

Features is a helper struct to build metrics.

type Sender

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

Sender can send anonymous usage stats. Centrifugo does not collect any sensitive info. Only impersonal counters to estimate installation size distribution and feature use.

func NewSender

func NewSender(node *centrifuge.Node, rules *rule.Container, features Features) *Sender

NewSender creates usage stats sender.

func (*Sender) Start

func (s *Sender) Start(ctx context.Context)

Start sending usage stats. How it works: First send in between 24-48h from node start. After the initial delay has passed: every hour check last time stats were sent by all the nodes in a Centrifugo cluster. If no points were sent in last 24h, then push metrics and update push time on all nodes (broadcast current time). There is still a chance of duplicate data sending – but should be rare and tolerable for the purpose.

func (*Sender) UpdateLastSentAt

func (s *Sender) UpdateLastSentAt(data []byte)

UpdateLastSentAt sets the lastSentAt received from other node only if received value greater than local one (so that we can avoid sending duplicated stats).

Jump to

Keyboard shortcuts

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