data

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataError

type DataError struct {
	*utils.BaseError
}

DataError represents an error related to the underlying data structure used by the tracker.

func NewDataError

func NewDataError(wrapped error, msg string, args ...any) *DataError

NewDataError wraps the given error with additional context for data layer issues.

type Structure

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

Structure implements the Tracker interface using a multi-level Bloom filter style bucket layout. Each bucket tracks the probability that a request should be throttled based on the observed successes and failures for the hashed client identifier.

func NewStructure

func NewStructure(config *config.FairnessTrackerConfig, id uint64, includeStats bool) (*Structure, error)

NewStructure creates a Structure using the real system clock.

func NewStructureWithClock

func NewStructureWithClock(config *config.FairnessTrackerConfig, id uint64, includeStats bool, clock utils.IClock) (*Structure, error)

NewStructureWithClock creates a Structure using the provided clock. This is primarily used in tests and simulations where time needs to be controlled.

func (*Structure) Close

func (s *Structure) Close()

Close releases any resources associated with the Structure.

func (*Structure) GetID

func (s *Structure) GetID() uint64

GetID returns the identifier of this data structure.

func (*Structure) RegisterRequest

func (s *Structure) RegisterRequest(_ context.Context, clientIdentifier []byte) *request.RegisterRequestResult

RegisterRequest records an incoming request from the client and returns the throttling decision based on current probabilities.

func (*Structure) ReportOutcome

func (s *Structure) ReportOutcome(_ context.Context, clientIdentifier []byte, outcome request.Outcome) *request.ReportOutcomeResult

ReportOutcome updates the probabilities for the buckets associated with the given client identifier based on the observed outcome.

Jump to

Keyboard shortcuts

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