iface

package
v2.34.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheTypeStrings added in v2.25.0

func CacheTypeStrings() []string

CacheTypeStrings returns a slice of all String values of the enum

func ComponentKey

func ComponentKey(component Component) string

ComponentKey returns a unique Key for a component.

Types

type Cache added in v2.24.0

type Cache interface {
	// Lookup looks up specified keys in cache. It takes flowcontrolv1.LookupRequest and returns flowcontrolv1.LookupResponse.
	Lookup(ctx context.Context, request *flowcontrolv1.CacheLookupRequest) *flowcontrolv1.CacheLookupResponse
	// LookupWait starts lookup for specified keys in cache. It does not wait for response. It takes flowcontrolv1.LookupRequest and returns flowcontrolv1.LookupResponse and result and global wait groups.
	LookupNoWait(ctx context.Context, request *flowcontrolv1.CacheLookupRequest) (*flowcontrolv1.CacheLookupResponse, *sync.WaitGroup, *sync.WaitGroup)
	// LookupGlobal looks up specified keys in global cache. It takes flowcontrolv1.LookupRequest and returns flowcontrolv1.KeyLookupResponse.
	LookupGlobal(ctx context.Context, request *flowcontrolv1.CacheLookupRequest) map[string]*flowcontrolv1.KeyLookupResponse
	// LookupGlobalNoWait starts lookup for specified keys in global cache. It does not wait for response. It takes flowcontrolv1.LookupRequest and returns flowcontrolv1.KeyLookupResponse and global wait group.
	LookupGlobalNoWait(ctx context.Context, request *flowcontrolv1.CacheLookupRequest) (map[string]*flowcontrolv1.KeyLookupResponse, *sync.WaitGroup)
	// LookupResult looks up specified keys in result cache. It takes flowcontrolv1.LookupRequest and returns flowcontrolv1.KeyLookupResponse.
	LookupResult(ctx context.Context, request *flowcontrolv1.CacheLookupRequest) *flowcontrolv1.KeyLookupResponse
	// LookupResultNoWait starts lookup for specified keys in result cache. It does not wait for response. It takes flowcontrolv1.LookupRequest and returns flowcontrolv1.KeyLookupResponse and result wait group.
	LookupResultNoWait(ctx context.Context, request *flowcontrolv1.CacheLookupRequest) (*flowcontrolv1.KeyLookupResponse, *sync.WaitGroup)
	// Upsert inserts or updates specified cache entries. It takes flowcontrolv1.UpsertRequest and returns flowcontrolv1.UpsertResponse.
	Upsert(ctx context.Context, req *flowcontrolv1.CacheUpsertRequest) *flowcontrolv1.CacheUpsertResponse
	// Delete deletes specified keys from cache. It takes flowcontrolv1.DeleteRequest and returns flowcontrolv1.DeleteResponse.
	Delete(ctx context.Context, req *flowcontrolv1.CacheDeleteRequest) *flowcontrolv1.CacheDeleteResponse
}

Cache is an interface for the cache.

type CacheType added in v2.25.0

type CacheType int

CacheType is the type of cache.

const (
	// Result is the type of cache for saving results.
	Result CacheType = iota
	// CacheTypeState is the type of cache for saving state.
	Global
)

func CacheTypeString added in v2.25.0

func CacheTypeString(s string) (CacheType, error)

CacheTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func CacheTypeValues added in v2.25.0

func CacheTypeValues() []CacheType

CacheTypeValues returns all values of the enum

func (CacheType) IsACacheType added in v2.25.0

func (i CacheType) IsACacheType() bool

IsACacheType returns "true" if the value is listed in the enum definition. "false" otherwise

func (CacheType) String added in v2.25.0

func (i CacheType) String() string

type ClassificationEngine

type ClassificationEngine interface {
	RegisterClassifier(classifier Classifier) error
	UnregisterClassifier(classifier Classifier) error
	GetClassifier(classifierID ClassifierID) Classifier
}

ClassificationEngine is the interface for registering classifiers.

type Classifier

type Classifier interface {
	// GetSelectors returns the selectors.
	GetSelectors() []*policylangv1.Selector

	// GetClassifierID returns ClassifierID object that should uniquely identify classifier.
	GetClassifierID() ClassifierID

	// GetRequestCounter returns the counter for the classifier.
	GetRequestCounter() prometheus.Counter
}

Classifier interface.

type ClassifierID

type ClassifierID struct {
	PolicyName      string
	PolicyHash      string
	ClassifierIndex int64
}

ClassifierID is the ID of the Classifier.

func (ClassifierID) String

func (cID ClassifierID) String() string

String function returns the ClassifierID as a string.

type Component

type Component interface {
	Policy
	GetComponentId() string
}

Component is the interface that wraps the GetPolicyName, GetPolicyHash, and GetComponentID methods.

type ConcurrencyLimiter added in v2.29.0

type ConcurrencyLimiter interface {
	Limiter
	FlowEnder
}

ConcurrencyLimiter interface.

type ConcurrencyScheduler added in v2.29.0

type ConcurrencyScheduler interface {
	Scheduler
	FlowEnder
}

ConcurrencyScheduler interface.

type Engine

type Engine interface {
	ProcessRequest(
		ctx context.Context,
		requestContext RequestContext,
	) *flowcontrolv1.CheckResponse

	GetAgentInfo() *agentinfo.AgentInfo

	RegisterScheduler(ls Scheduler) error
	UnregisterScheduler(ls Scheduler) error
	GetScheduler(limiterID LimiterID) Scheduler

	RegisterFluxMeter(fm FluxMeter) error
	UnregisterFluxMeter(fm FluxMeter) error
	GetFluxMeter(fluxMeterName string) FluxMeter

	RegisterRateLimiter(l Limiter) error
	UnregisterRateLimiter(l Limiter) error
	GetRateLimiter(limiterID LimiterID) Limiter

	RegisterSampler(l Limiter) error
	UnregisterSampler(l Limiter) error
	GetSampler(limiterID LimiterID) Limiter

	RegisterLabelPreview(l LabelPreview) error
	UnregisterLabelPreview(l LabelPreview) error

	RegisterCache(c Cache)

	RegisterConcurrencyLimiter(l ConcurrencyLimiter) error
	UnregisterConcurrencyLimiter(l ConcurrencyLimiter) error

	RegisterConcurrencyScheduler(l ConcurrencyScheduler) error
	UnregisterConcurrencyScheduler(l ConcurrencyScheduler) error

	GetFlowEnder(limiterID LimiterID) FlowEnder

	FlowEnd(
		ctx context.Context,
		request *flowcontrolv1.FlowEndRequest,
	) *flowcontrolv1.FlowEndResponse
}

Engine is an interface for registering fluxmeters and schedulers.

type FlowEnder added in v2.29.0

type FlowEnder interface {
	Return(ctx context.Context, label string, tokens float64, requestID string) (bool, error)
}

FlowEnder interface.

type FluxMeter

type FluxMeter interface {
	// GetSelectors returns the selectors
	GetSelectors() []*policylangv1.Selector

	// GetAttributeKey returns the attribute key
	GetAttributeKey() string

	// GetFluxMeterName returns the metric name
	GetFluxMeterName() string

	// GetFluxMeterID returns the flux meter ID
	GetFluxMeterID() FluxMeterID

	// GetHistogram returns the histogram observer for given labels.
	// It expects the following labels to be set:
	//  * metrics.DecisionTypeLabel,
	//  * metrics.ResponseStatusLabel,
	//  * metrics.StatusCodeLabel,
	//  * metrics.FeatureStatusLabel.
	GetHistogram(labels map[string]string) prometheus.Observer

	// GetInvalidFluxMeterTotal returns a counter metric for the total number of invalid flux meters with the specified labels.
	GetInvalidFluxMeterTotal(labels map[string]string) (prometheus.Counter, error)
}

FluxMeter in an interface for interacting with fluxmeters.

type FluxMeterID

type FluxMeterID struct {
	FluxMeterName string
}

FluxMeterID is the ID of the FluxMeter.

func (FluxMeterID) String

func (fmID FluxMeterID) String() string

String function returns the FluxMeterID as a string.

type HTTPRequestPreview

type HTTPRequestPreview interface {
	PreviewBase
	// AddHTTPRequestPreview adds labels to preview.
	AddHTTPRequestPreview(request map[string]interface{})
}

HTTPRequestPreview interface.

type LabelPreview

type LabelPreview interface {
	PreviewBase
	// AddLabelPreview adds labels to preview.
	AddLabelPreview(labels map[string]string)
}

LabelPreview interface.

type Limiter

type Limiter interface {
	GetPolicyName() string
	GetSelectors() []*policylangv1.Selector
	Decide(context.Context, labels.Labels) *flowcontrolv1.LimiterDecision
	Revert(context.Context, labels.Labels, *flowcontrolv1.LimiterDecision)
	GetLimiterID() LimiterID
	GetRequestCounter(labels map[string]string) prometheus.Counter
	GetRampMode() bool
}

Limiter interface. Lifetime of this interface is per policy/component.

type LimiterID

type LimiterID struct {
	PolicyName  string
	PolicyHash  string
	ComponentID string
}

LimiterID is the ID of the Limiter.

func (LimiterID) String

func (limiterID LimiterID) String() string

String function returns the LimiterID as a string.

type Policy

type Policy interface {
	GetPolicyName() string
	GetPolicyHash() string
}

Policy is the interface that wraps the GetPolicyName, GetPolicyHash methods.

type PreviewBase

type PreviewBase interface {
	// GetPreviewID returns the ID of the preview.
	GetPreviewID() PreviewID
	// GetSelectors returns the selectors.
	GetSelectors() []*policylangv1.Selector
}

PreviewBase is the base interface for all preview requests.

type PreviewID

type PreviewID struct {
	RequestID string
}

PreviewID is the ID of a preview.

func (PreviewID) String

func (id PreviewID) String() string

String returns the string representation of the ID.

type RequestContext

type RequestContext struct {
	FlowLabels         labels.Labels
	ControlPoint       string
	CacheLookupRequest *flowcontrolv1.CacheLookupRequest
	Services           []string
	RampMode           bool
	ExpectEnd          bool
}

RequestContext provides the request parameters for the Check method.

type Scheduler added in v2.2.0

type Scheduler interface {
	Limiter
	GetLatencyObserver(labels map[string]string) prometheus.Observer
}

Scheduler interface.

Jump to

Keyboard shortcuts

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