decorators

package
v0.3.2 Latest Latest
Warning

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

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

Documentation

Overview

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. Apply them at the composition root; a nil collaborator or zero timeout skips its layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Session

Session wraps a cassandra.Session so every statement execution (Query.Exec) and batch runs through the client stack (Bulkhead → Retry → CircuitBreaker → Timeout → Tracing → Metrics → Logging). Only statements marked Idempotent are retried — the store's writes are, so a transient failure is retried within the stack's retry budget. Reads (Iter) are paged by the caller and protected by the store decorators instead.

Types

type Builder

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

Builder composes the decorators around a base AnalyticsStore.

func NewBuilder

func NewBuilder(base interfaces.AnalyticsStore, name string) *Builder

NewBuilder starts a decorator chain around base, labelled name.

func (*Builder) Build

func (b *Builder) Build() interfaces.AnalyticsStore

Build returns the decorated store.

func (*Builder) WithCircuitBreaker

func (b *Builder) WithCircuitBreaker(cb interfaces.CircuitBreaker) *Builder

WithCircuitBreaker sheds operations while the breaker is open (CodeUnavailable).

func (*Builder) WithLogger

func (b *Builder) WithLogger(l interfaces.Logger) *Builder

WithLogger logs recovered panics.

func (*Builder) WithMetrics

func (b *Builder) WithMetrics(m interfaces.Metrics) *Builder

WithMetrics records analytics_executions_total, analytics_errors_total and analytics_execute_duration_seconds per operation.

func (*Builder) WithTimeout

func (b *Builder) WithTimeout(d time.Duration) *Builder

WithTimeout bounds opening a stream, each write and each compaction; an expired deadline is CodeTimeout.

func (*Builder) WithTracer

func (b *Builder) WithTracer(t interfaces.Tracer) *Builder

WithTracer opens a span per operation.

Jump to

Keyboard shortcuts

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