request

package
v0.28.6 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: Apache-2.0 Imports: 16 Imported by: 23

Documentation

Index

Constants

View Source
const MaxSeatSeconds = SeatSeconds(math.MaxUint64)

MaxSeatsSeconds is the maximum representable value of SeatSeconds

View Source
const MinSeatSeconds = SeatSeconds(0)

MinSeatSeconds is the lowest representable value of SeatSeconds

Variables

View Source
var (
	// ObjectCountNotFoundErr is returned when the object count for
	// a given resource is not being tracked.
	ObjectCountNotFoundErr = errors.New("object count not found for the given resource")

	// ObjectCountStaleErr is returned when the object count for a
	// given resource has gone stale due to transient failures.
	ObjectCountStaleErr = errors.New("object count has gone stale for the given resource")
)

Functions

This section is empty.

Types

type ListWorkEstimatorConfig added in v0.25.0

type ListWorkEstimatorConfig struct {
	ObjectsPerSeat float64 `json:"objectsPerSeat,omitempty"`
}

ListWorkEstimatorConfig holds work estimator parameters related to list requests.

type MutatingWorkEstimatorConfig added in v0.25.0

type MutatingWorkEstimatorConfig struct {
	// TODO(wojtekt): Remove it once we tune the algorithm to not fail
	// scalability tests.
	Enabled                 bool            `json:"enable,omitempty"`
	EventAdditionalDuration metav1.Duration `json:"eventAdditionalDurationMs,omitempty"`
	WatchesPerSeat          float64         `json:"watchesPerSeat,omitempty"`
}

MutatingWorkEstimatorConfig holds work estimator parameters related to watches of mutating objects.

type SeatSeconds added in v0.23.0

type SeatSeconds uint64

SeatSeconds is a measure of work, in units of seat-seconds, using a fixed-point representation. `SeatSeconds(n)` represents `n/ssScale` seat-seconds. The `ssScale` constant is private to the implementation here, no other code should use it.

func SeatsTimesDuration added in v0.23.0

func SeatsTimesDuration(seats float64, duration time.Duration) SeatSeconds

SeatsTimeDuration produces the SeatSeconds value for the given factors. This is intended only to produce small values, increments in work rather than amount of work done since process start.

func (SeatSeconds) DurationPerSeat added in v0.23.0

func (ss SeatSeconds) DurationPerSeat(seats float64) time.Duration

DurationPerSeat returns duration per seat. This division may lose precision.

func (SeatSeconds) String added in v0.23.0

func (ss SeatSeconds) String() string

String converts to a string. This is suitable for large as well as small values.

func (SeatSeconds) ToFloat added in v0.23.0

func (ss SeatSeconds) ToFloat() float64

ToFloat converts to a floating-point representation. This conversion may lose precision.

type StorageObjectCountTracker added in v0.23.0

type StorageObjectCountTracker interface {
	// Set is invoked to update the current number of total
	// objects for the given resource
	Set(string, int64)

	// Get returns the total number of objects for the given resource.
	// The following errors are returned:
	//  - if the count has gone stale for a given resource due to transient
	//    failures ObjectCountStaleErr is returned.
	//  - if the given resource is not being tracked then
	//    ObjectCountNotFoundErr is returned.
	Get(string) (int64, error)

	// RunUntil starts all the necessary maintenance.
	RunUntil(stopCh <-chan struct{})
}

StorageObjectCountTracker is an interface that is used to keep track of of the total number of objects for each resource. {group}.{resource} is used as the key name to update and retrieve the total number of objects for a given resource.

func NewStorageObjectCountTracker added in v0.23.0

func NewStorageObjectCountTracker() StorageObjectCountTracker

NewStorageObjectCountTracker returns an instance of StorageObjectCountTracker interface that can be used to keep track of the total number of objects for each resource.

type WorkEstimate added in v0.23.0

type WorkEstimate struct {
	// InitialSeats is the number of seats occupied while the server is
	// executing this request.
	InitialSeats uint64

	// FinalSeats is the number of seats occupied at the end,
	// during the AdditionalLatency.
	FinalSeats uint64

	// AdditionalLatency specifies the additional duration the seats allocated
	// to this request must be reserved after the given request had finished.
	// AdditionalLatency should not have any impact on the user experience, the
	// caller must not experience this additional latency.
	AdditionalLatency time.Duration
}

WorkEstimate carries three of the four parameters that determine the work in a request. The fourth parameter is the duration of the initial phase of execution.

func (*WorkEstimate) MaxSeats added in v0.23.0

func (we *WorkEstimate) MaxSeats() int

MaxSeats returns the maximum number of seats the request occupies over the phases of being served.

type WorkEstimatorConfig added in v0.25.0

type WorkEstimatorConfig struct {
	*ListWorkEstimatorConfig     `json:"listWorkEstimatorConfig,omitempty"`
	*MutatingWorkEstimatorConfig `json:"mutatingWorkEstimatorConfig,omitempty"`

	// MinimumSeats is the minimum number of seats a request must occupy.
	MinimumSeats uint64 `json:"minimumSeats,omitempty"`

	// MaximumSeatsLimit is an upper limit on the max seats a request can occupy.
	//
	// NOTE: work_estimate_seats_samples metric uses the value of maximumSeats
	// as the upper bound, so when we change maximumSeats we should also
	// update the buckets of the metric.
	MaximumSeatsLimit uint64 `json:"maximumSeatsLimit,omitempty"`
}

WorkEstimatorConfig holds work estimator parameters.

func DefaultWorkEstimatorConfig added in v0.25.0

func DefaultWorkEstimatorConfig() *WorkEstimatorConfig

DefaultWorkEstimatorConfig creates a new WorkEstimatorConfig with default values.

type WorkEstimatorFunc added in v0.23.0

type WorkEstimatorFunc func(request *http.Request, flowSchemaName, priorityLevelName string) WorkEstimate

WorkEstimatorFunc returns the estimated work of a given request. This function will be used by the Priority & Fairness filter to estimate the work of of incoming requests.

func NewWorkEstimator added in v0.23.0

func NewWorkEstimator(objectCountFn objectCountGetterFunc, watchCountFn watchCountGetterFunc, config *WorkEstimatorConfig, maxSeatsFn maxSeatsFunc) WorkEstimatorFunc

NewWorkEstimator estimates the work that will be done by a given request, if no WorkEstimatorFunc matches the given request then the default work estimate of 1 seat is allocated to the request.

func (WorkEstimatorFunc) EstimateWork added in v0.23.0

func (e WorkEstimatorFunc) EstimateWork(r *http.Request, flowSchemaName, priorityLevelName string) WorkEstimate

Jump to

Keyboard shortcuts

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