Documentation
¶
Index ¶
- type DataError
- type Structure
- func (s *Structure) Close()
- func (s *Structure) GetID() uint64
- func (s *Structure) RegisterRequest(_ context.Context, clientIdentifier []byte) *request.RegisterRequestResult
- func (s *Structure) ReportOutcome(_ context.Context, clientIdentifier []byte, outcome request.Outcome) *request.ReportOutcomeResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataError ¶
DataError represents an error related to the underlying data structure used by the tracker.
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) 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.