Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OnEndFunc ¶
type OnEndFunc[T any] func(data T, lastUpdated *SessionMetadata)
OnEndFunc is a function that will be invoked whenever a session ends whether because of the inactivity timeout or because of the maximum session lifetime being exceeded.
type Option ¶
type Option[T any] func(*config[T])
Option represents a configuration option for a Tracker.
func WithInactivityTimeout ¶
WithInactivityTimeout sets the Tracker's inactivity timeout i.e. how long of a period of inactivity must pass before any new event is considered a new session.
func WithJanitorInterval ¶
WithJanitorInterval sets the Tracker's janitor interval.
func WithMaxSessionTimeout ¶
WithMaxSessionTimeout sets the Tracker's max session timeout i.e. how long a session can be before any new events produce a new session.
func WithOnSessionEnd ¶
WithOnSessionEnd sets the Tracker's onSessionEnd handler, i.e. a function that will be ran on every session after its done.
type Session ¶
type Session[T any] struct { // contains filtered or unexported fields }
Session represents a unique session.
type SessionInitFunc ¶
SessionInitFunc is a function that will be invoked to initialize a new session whenever an event merits a new session.
type SessionMetadata ¶
SessionMetadata represents public data regarding a session.
type Tracker ¶
type Tracker[T any] interface { Stop() EventStart(sessionDedupKey string, eventID string) *Session[T] EventEnd(eventID string) error }
Tracker represents a sliding window tracker.
func NewTracker ¶
func NewTracker[T any](sessionInitFunc SessionInitFunc[T], opts ...Option[T]) Tracker[T]
NewTracker returns a new sliding window tracker.