request

package
v0.0.0-...-fb1d941 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

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 SeatSeconds

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

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

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

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

func (SeatSeconds) String

func (ss SeatSeconds) String() string

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

func (SeatSeconds) ToFloat

func (ss SeatSeconds) ToFloat() float64

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

type StorageObjectCountTracker

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)
}

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

func NewStorageObjectCountTracker(stopCh <-chan struct{}) 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

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

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

	// 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

func (we *WorkEstimate) MaxSeats() int

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

type WorkEstimatorFunc

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

func NewWorkEstimator(objectCountFn objectCountGetterFunc, watchCountFn watchCountGetterFunc) 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

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