batchstats

package
v2.10.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batcher

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

Batcher holds a buffer of agent stats and periodically flushes them to its configured store. It also updates the workspace's last used time.

func New

func New(ctx context.Context, opts ...Option) (*Batcher, func(), error)

New creates a new Batcher and starts it.

func (*Batcher) Add

func (b *Batcher) Add(
	now time.Time,
	agentID uuid.UUID,
	templateID uuid.UUID,
	userID uuid.UUID,
	workspaceID uuid.UUID,
	st *agentproto.Stats,
) error

Add adds a stat to the batcher for the given workspace and agent.

type Option

type Option func(b *Batcher)

Option is a functional option for configuring a Batcher.

func WithBatchSize

func WithBatchSize(size int) Option

WithBatchSize sets the number of stats to store in a batch.

func WithInterval

func WithInterval(d time.Duration) Option

WithInterval sets the interval for flushes.

func WithLogger

func WithLogger(log slog.Logger) Option

WithLogger sets the logger to use for logging.

func WithStore

func WithStore(store database.Store) Option

WithStore sets the store to use for storing stats.

Jump to

Keyboard shortcuts

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