Documentation
¶
Overview ¶
Package protosessions provides functionality for aggregating hits into proto-sessions
Index ¶
- Constants
- func BucketNumber(time time.Time, tickInterval time.Duration) int64
- func BucketsKey(bucketNumber int64) string
- func BucketsParseNumber(bucketKey string) (int64, error)
- func CompactedHitsKey(authoritativeClientID hits.ClientID) string
- func DoTick(closeTriggerCandidate Middleware)
- func ExpirationKey(authoritativeClientID string) string
- func Handler(ctx context.Context, set storage.Set, kv storage.KV, ...) func(_ map[string]string, h *hits.HitProcessingTask) *worker.Error
- func ProtoSessionHitsKey(authoritativeClientID hits.ClientID) string
- func SessionStampByClientIDKey(clientID string) string
- func SessionStampKey(sessionStamp string) string
- func StopCloseTrigger(closeTriggerCandidate Middleware)
- type Closer
- type Context
- type Middleware
- func NewCloseTriggerMiddleware(kv storage.KV, set storage.Set, sessionDuration, tickInterval time.Duration, ...) Middleware
- func NewCompactorMiddleware(kv storage.KV, encoder encoding.EncoderFunc, decoder encoding.DecoderFunc, ...) Middleware
- func NewEvicterMiddleware(kv storage.KV, rs receiver.Storage) Middleware
Constants ¶
const BucketsPrefix = "sessions.buckets"
BucketsPrefix is the prefix for session buckets keys.
const CompactedHitsPrefix = "sessions.hits.compacted"
CompactedHitsPrefix is the prefix for the compacted hits key
const NextBucketKey = "sessions.buckets.next"
NextBucketKey is the key for the next session bucket.
const ProtoSessionHitsPrefix = "sessions.hits"
ProtoSessionHitsPrefix is the prefix for session hits keys.
const SessionStampByClientIDPrefix = "sessions.stamps.by.client.id"
SessionStampByClientIDPrefix is the prefix for session stamps by client ID keys.
const SessionStampPrefix = "sessions.stamps"
SessionStampPrefix is the prefix for session stamps keys.
Variables ¶
This section is empty.
Functions ¶
func BucketNumber ¶
BucketNumber returns the bucket number for a given time and session duration.
func BucketsKey ¶
BucketsKey returns the key for the buckets of the session.
func BucketsParseNumber ¶
BucketsParseNumber parses the bucket number from a bucket key.
func CompactedHitsKey ¶
CompactedHitsKey returns the key for the compacted hits
func DoTick ¶
func DoTick(closeTriggerCandidate Middleware)
DoTick is an e2e test utility function that performs a single tick of the closeTriggerMiddleware.
func ExpirationKey ¶
ExpirationKey returns the expiration key for a given client ID.
func Handler ¶
func Handler( ctx context.Context, set storage.Set, kv storage.KV, encoder encoding.EncoderFunc, decoder encoding.DecoderFunc, middlewares []Middleware, ) func(_ map[string]string, h *hits.HitProcessingTask) *worker.Error
Handler returns a function that processes hit processing tasks.
func ProtoSessionHitsKey ¶
ProtoSessionHitsKey returns the key for the session hits of the given authoritative client ID.
func SessionStampByClientIDKey ¶
SessionStampByClientIDKey returns the key for the session stamp by client ID.
func SessionStampKey ¶
SessionStampKey returns the key for the session stamp.
func StopCloseTrigger ¶
func StopCloseTrigger(closeTriggerCandidate Middleware)
StopCloseTrigger is an e2e test utility function that stops the closeTriggerMiddleware.
Types ¶
type Closer ¶
Closer defines an interface for closing and processing hit sessions
func NewPrintingCloser ¶
func NewPrintingCloser() Closer
NewPrintingCloser creates a new Closer implementation that prints the hits to stdout
type Context ¶
type Context struct {
StorageSet storage.Set
StorageKV storage.KV
Encoder encoding.EncoderFunc
Decoder encoding.DecoderFunc
// contains filtered or unexported fields
}
Context holds the context for protosessions operations.
func (*Context) CollectAll ¶
CollectAll collects all hits for the given clientID from all middlewares and storage.
type Middleware ¶
type Middleware interface {
Handle(ctx *Context, hit *hits.Hit, next func() error) error
// OnCleanup is called when the data for proto-session for given clientID should be cleared
OnCleanup(ctx *Context, authoritativeClientID hits.ClientID) error
OnCollect(ctx *Context, authoritativeClientID hits.ClientID) ([]*hits.Hit, error)
OnPing(ctx *Context, pingTimestamp time.Time) error
}
Middleware defines an interface for task processing middleware
func NewCloseTriggerMiddleware ¶
func NewCloseTriggerMiddleware( kv storage.KV, set storage.Set, sessionDuration, tickInterval time.Duration, closer Closer, ) Middleware
NewCloseTriggerMiddleware creates a new closer middleware for session management.
func NewCompactorMiddleware ¶
func NewCompactorMiddleware( kv storage.KV, encoder encoding.EncoderFunc, decoder encoding.DecoderFunc, thresholdBytes uint32, ) Middleware
NewCompactorMiddleware creates a new middleware, that compresses bigger proto-sessions
func NewEvicterMiddleware ¶
func NewEvicterMiddleware(kv storage.KV, rs receiver.Storage) Middleware
NewEvicterMiddleware creates a new evicter middleware instance.