sessions

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package sessions provides session management functionality for the tracking system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBatchingSchemaLayout

func NewBatchingSchemaLayout(layout schema.Layout) schema.Layout

NewBatchingSchemaLayout creates a new layout that makes sure that all the rows from a single table will be written to the warehouse in a single call.

func NewBrokenFilteringSchemaLayout added in v0.19.0

func NewBrokenFilteringSchemaLayout(layout schema.Layout) schema.Layout

Types

type DirectCloser added in v0.13.0

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

func NewDirectCloser

func NewDirectCloser(writer SessionWriter, failureSleepDuration time.Duration) *DirectCloser

NewDirectCloser creates a new protosessions.Closer that writes the session directly to warehouse.Driver, without intermediate queue (suitable only for single-tenant setup)

func (*DirectCloser) Close added in v0.13.0

func (c *DirectCloser) Close(protosessions [][]*hits.Hit) error

Close implements protosessions.Closer

type Option added in v0.32.0

type Option func(*config)

Option is a functional option for configuring the writer.

func WithEncoderDecoder added in v0.32.0

func WithEncoderDecoder(encoder encoding.EncoderFunc, decoder encoding.DecoderFunc) Option

WithEncoderDecoder sets the encoder and decoder functions.

func WithLvl1MaxAge added in v0.32.0

func WithLvl1MaxAge(d time.Duration) Option

WithLvl1MaxAge sets the maximum age for lvl1 buffers.

func WithLvl1MaxSessions added in v0.32.0

func WithLvl1MaxSessions(n int) Option

WithLvl1MaxSessions sets the maximum number of sessions in lvl1 buffer.

func WithLvl1SweepInterval added in v0.32.0

func WithLvl1SweepInterval(d time.Duration) Option

WithLvl1SweepInterval sets the sweep interval for lvl1 buffers.

func WithLvl2FlushInterval added in v0.32.0

func WithLvl2FlushInterval(d time.Duration) Option

WithLvl2FlushInterval sets the flush interval for lvl2 to child writer.

func WithMaxConsecutiveChildWriteFailures added in v0.32.0

func WithMaxConsecutiveChildWriteFailures(n int) Option

WithMaxConsecutiveChildWriteFailures sets the maximum number of consecutive child writer failures before a spool file is discarded.

func WithSpoolDir added in v0.32.0

func WithSpoolDir(dir string) Option

WithSpoolDir sets the directory for lvl2 spool files.

func WithWriteChanBuffer added in v0.32.0

func WithWriteChanBuffer(n int) Option

WithWriteChanBuffer sets the capacity of the channel used for incoming Write calls. Larger values reduce blocking of callers when the actor is busy (e.g. during L2 flush) at the cost of more in-memory sessions on process crash. Zero means unbuffered. Default is 1000.

type SessionWriter

type SessionWriter interface {
	Write(sessions ...*schema.Session) error
}

SessionWriter defines the interface for writing sessions

func NewBackgroundBatchingWriter added in v0.32.0

func NewBackgroundBatchingWriter(
	ctx context.Context,
	childWriter SessionWriter,
	opts ...Option,
) (SessionWriter, func(), error)

NewBackgroundBatchingWriter creates a writer that uses spool file to queue the writes. Returns the writer, a cleanup function (to be deferred), and an error.

func NewNoopWriter added in v0.13.0

func NewNoopWriter() SessionWriter

NewNoopWriter creates a new NoopWriter

func NewSessionWriter

func NewSessionWriter(
	parentCtx context.Context,
	whr warehouse.Registry,
	columnsRegistry schema.ColumnsRegistry,
	layouts schema.LayoutRegistry,
	splitterRegistry splitter.Registry,
	opts ...SessionWriterOption,
) SessionWriter

NewSessionWriter creates a new SessionWriter with the provided warehouse, column sources, and layout sources. It caches each entity (warehouse, columns, layout) for 5 minutes.

type SessionWriterOption added in v0.13.0

type SessionWriterOption func(*sessionWriterImpl)

SessionWriterOption configures the SessionWriter.

func WithCacheTTL added in v0.13.0

func WithCacheTTL(d time.Duration) SessionWriterOption

WithCacheTTL sets the TTL for cached registries.

func WithConcurrency added in v0.13.0

func WithConcurrency(n int) SessionWriterOption

WithConcurrency sets the concurrency limit for parallel writes.

func WithWriteTimeout added in v0.13.0

func WithWriteTimeout(d time.Duration) SessionWriterOption

WithWriteTimeout sets the timeout for individual write operations.

Jump to

Keyboard shortcuts

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