Documentation
¶
Overview ¶
Package analytics builds the AnalyticsStore: the zero-infrastructure stub (the default) or the Cassandra-protocol store (Apache Cassandra locally, Amazon Keyspaces in staging, chosen by the nested Cassandra config). Use New() or NewFromConfig(); decorate the result with the decorators subpackage.
Index ¶
- func New(kind Kind, opts ...options.Option[Config]) (interfaces.AnalyticsStore, error)
- func NewFromConfig(cfg *Config) (interfaces.AnalyticsStore, error)
- func WithCassandra(kind cassandra.Kind, opts ...options.Option[cassandra.Config]) options.Option[Config]
- func WithCube(name string, grains ...types.Grain) options.Option[Config]
- func WithEnsureSchema() options.Option[Config]
- func WithMaxConcurrentBuckets(n int) options.Option[Config]
- func WithSessionFactory(f SessionFactory) options.Option[Config]
- func WithTTL(grain types.Grain, d time.Duration) options.Option[Config]
- type Config
- type Kind
- type SessionFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(kind Kind, opts ...options.Option[Config]) (interfaces.AnalyticsStore, error)
New creates an AnalyticsStore of the given kind with optional functional options.
func NewFromConfig ¶
func NewFromConfig(cfg *Config) (interfaces.AnalyticsStore, error)
NewFromConfig creates an AnalyticsStore from cfg without I/O. The cassandra kind dials its session from cfg.Cassandra at Start (and, with EnsureSchema, creates its tables there, awaiting ACTIVE on Keyspaces); an unknown kind is CodeInvalidInput.
func WithCassandra ¶
func WithCassandra( kind cassandra.Kind, opts ...options.Option[cassandra.Config], ) options.Option[Config]
WithCassandra sets the nested session kind and applies session options.
func WithEnsureSchema ¶ added in v0.3.6
WithEnsureSchema makes Start create the declared tables (see Config.EnsureSchema).
func WithMaxConcurrentBuckets ¶
WithMaxConcurrentBuckets bounds a query's bucket fan-out.
func WithSessionFactory ¶
func WithSessionFactory(f SessionFactory) options.Option[Config]
WithSessionFactory overrides how the Cassandra session is dialed.
Types ¶
type Config ¶
type Config struct {
// SessionFactory dials the session for KindCassandra (nil = cassandra.NewFromConfig).
SessionFactory SessionFactory
// 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
// Cubes declares each cube and the grains it is rolled up at (one table each).
Cubes map[string][]types.Grain
// TTL is how long a row of each grain is kept (0 or absent = forever).
TTL map[types.Grain]time.Duration
// Cassandra is the session config; its Kind picks Cassandra or Keyspaces.
Cassandra cassandra.Config
// Kind selects the backend.
Kind Kind
// MaxConcurrentBuckets bounds how many buckets a query reads at once.
MaxConcurrentBuckets int
// EnsureSchema makes the cassandra kind create every declared table at Start
// and, on Amazon Keyspaces (Cassandra.Kind), wait until each one is ACTIVE.
EnsureSchema bool
}
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 Cassandra session config.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cassandra is the Cassandra-protocol AnalyticsStore (Apache Cassandra or Amazon Keyspaces behind clients/cassandra.Session).
|
Package cassandra is the Cassandra-protocol AnalyticsStore (Apache Cassandra or Amazon Keyspaces behind clients/cassandra.Session). |
|
Package decorators wraps an AnalyticsStore with resilience and observability, in the order recovery → metrics → tracing → circuit breaker → timeout (outermost first), and wraps a clients/cassandra.Session's writes in the client stack.
|
Package decorators wraps an AnalyticsStore with resilience and observability, in the order recovery → metrics → tracing → circuit breaker → timeout (outermost first), and wraps a clients/cassandra.Session's writes in the client stack. |
|
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. |