analytics

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package analytics builds the AnalyticsStore: the zero-infrastructure stub (the default) or the CQL store (Apache Cassandra locally, Amazon Keyspaces in staging, chosen by the nested CQL config). NewFromConfig selects the backend by Kind and runs it through the client tier (Decorate).

Index

Constants

View Source
const (
	// KindStub accepts writes and answers empty results (the default).
	KindStub = client.KindStub
	// KindCassandra stores partial rows over a CQL session (Cassandra or Keyspaces).
	KindCassandra client.Kind = "cassandra"
)

Variables

This section is empty.

Functions

func Decorate added in v0.0.7

Decorate runs Aggregate, Write and Compact of base through the client tier as the client named name. The lifecycle and health probes pass through undecorated: a probe is not an operation to retry, trace or count.

func NewFromConfig

func NewFromConfig(
	ctx context.Context,
	cfg Config,
	deps Deps,
) (interfaces.AnalyticsStore, error)

NewFromConfig builds the AnalyticsStore cfg.Kind names, decorated by the client tier, without I/O: the cassandra kind dials its session at Start (and, with EnsureSchema, creates its tables there, awaiting ACTIVE on Keyspaces). An unknown kind is CodeInvalidInput.

Types

type Config

type Config struct {
	// Kind selects the backend; empty means KindStub.
	Kind client.Kind `mapstructure:"kind"`
	// BucketWidth is the partition bucket of each grain, as a coarser grain (a
	// grain's groups never span buckets): minute→hour, hour→day, day→month, month→month.
	BucketWidth map[types.Grain]types.Grain `mapstructure:"bucket_width"`
	// Cubes declares each cube and the grains it is rolled up at (one table each).
	Cubes map[string][]types.Grain `mapstructure:"cubes"`
	// TTL is how long a row of each grain is kept (0 or absent = forever).
	TTL map[types.Grain]time.Duration `mapstructure:"ttl"`
	// Name labels the client in decoration overrides, metrics, spans and logs; empty
	// uses the family name ("analytics").
	Name string `yaml:"name" mapstructure:"name"`
	// CQL is the session config; its Kind picks Cassandra or Keyspaces.
	CQL cql.Config `mapstructure:"cql"`
	// MaxConcurrentBuckets bounds how many buckets a query reads at once.
	MaxConcurrentBuckets int `mapstructure:"max_concurrent_buckets"`
	// EnsureSchema makes the cassandra kind create every declared table at Start
	// and, on Amazon Keyspaces (CQL.Kind), wait until each one is ACTIVE.
	EnsureSchema bool `mapstructure:"ensure_schema"`
}

Config is the analytics store configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the stub kind with the default bucket widths, 8 concurrent buckets and the default CQL session config.

type Deps added in v0.0.7

type Deps struct {
	// Decorations decorates the client from the decoration config (decoration.clients)
	// and supplies its observability.
	decorate.Decorations
	// Dial opens the CQL session at Start; nil dials with cql.NewFromConfig.
	Dial Dial
}

Deps carries the store's runtime collaborators.

type Dial added in v0.0.7

type Dial func(ctx context.Context, cfg cql.Config) (interfaces.CQLSession, error)

Dial opens the CQL session a cassandra-kind store runs on.

Directories

Path Synopsis
Package cassandra is the Cassandra-protocol AnalyticsStore (Apache Cassandra or Amazon Keyspaces behind clients/interfaces.CQLSession).
Package cassandra is the Cassandra-protocol AnalyticsStore (Apache Cassandra or Amazon Keyspaces behind clients/interfaces.CQLSession).
Package stub is the default analytics store: it accepts every write and answers every query with an empty result, so the graph boots with no Cassandra.
Package stub is the default analytics store: it accepts every write and answers every query with an empty result, so the graph boots with no Cassandra.

Jump to

Keyboard shortcuts

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