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 ¶
- func Session(inner cassandra.Session, stack *clientdecorators.Stack) cassandra.Session
- type Builder
- func (b *Builder) Build() interfaces.AnalyticsStore
- func (b *Builder) WithCircuitBreaker(cb interfaces.CircuitBreaker) *Builder
- func (b *Builder) WithLogger(l interfaces.Logger) *Builder
- func (b *Builder) WithMetrics(m interfaces.Metrics) *Builder
- func (b *Builder) WithTimeout(d time.Duration) *Builder
- func (b *Builder) WithTracer(t interfaces.Tracer) *Builder
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 ¶
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.