aperture

package
v2.33.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: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrResultCacheResponseNil is returned when the result cache response is nil.
	ErrResultCacheResponseNil = errors.New("result cache response is nil")

	// ErrResultCacheKeyNotSet is returned when empty result cache key is provided by the caller during start flow.
	ErrResultCacheKeyNotSet = errors.New("result cache key not set")

	// ErrKeyMissingFromGlobalCacheResponse is returned when the global cache response does not contain the key.
	ErrKeyMissingFromGlobalCacheResponse = errors.New("key missing from global cache response")
)

Functions

func FlowStatusStrings

func FlowStatusStrings() []string

FlowStatusStrings returns a slice of all String values of the enum

Types

type CacheEntry added in v2.25.0

type CacheEntry struct {
	Value []byte
	TTL   time.Duration
}

CacheEntry describes the properties of cache entry.

type Client

type Client interface {
	StartFlow(ctx context.Context, controlPoint string, flowParams FlowParams) Flow
	StartHTTPFlow(ctx context.Context, request *checkhttpv1.CheckHTTPRequest, middlewareParams MiddlewareParams) HTTPFlow
	Shutdown(ctx context.Context) error
	GetLogger() *slog.Logger
	GetGRPClientConn() *grpc.ClientConn
}

Client is the interface that is provided to the user upon which they can perform Check calls for their service and eventually shut down in case of error.

func NewClient

func NewClient(ctx context.Context, opts Options) (Client, error)

NewClient returns a new Client that can be used to perform Check calls. The user will pass in options which will be used to create a connection with otel and a tracerProvider retrieved from such connection.

type EndResponse added in v2.29.0

type EndResponse struct {
	// FlowEndResponse is populated if the flow end request succeeded.
	FlowEndResponse *checkv1.FlowEndResponse

	// Error is populated if the flow end request failed.
	Error error
}

EndResponse is the response returned by the End method of the Flow interface.

type Flow

type Flow interface {
	ShouldRun() bool
	SetStatus(status FlowStatus)
	ResultCache() KeyLookupResponse
	SetResultCache(ctx context.Context, cacheEntry CacheEntry, opts ...grpc.CallOption) KeyUpsertResponse
	DeleteResultCache(ctx context.Context, opts ...grpc.CallOption) KeyDeleteResponse
	GlobalCache(key string) KeyLookupResponse
	SetGlobalCache(ctx context.Context, key string, cacheEntry CacheEntry, opts ...grpc.CallOption) KeyUpsertResponse
	DeleteGlobalCache(ctx context.Context, key string, opts ...grpc.CallOption) KeyDeleteResponse
	Error() error
	Span() trace.Span
	End() EndResponse
	CheckResponse() *checkv1.CheckResponse
	RetryAfter() time.Duration
	HTTPResponseCode() int
}

Flow is the interface that is returned to the user every time a CheckHTTP call through ApertureClient is made. The user can check the status of the check call, response from the server, and end the flow once the workload is executed.

type FlowParams added in v2.24.0

type FlowParams struct {
	// Labels are the labels that get passed to Aperture Agent via flowcontrolv1.Check call.
	Labels map[string]string
	// CallOptions are the grpc call options that get passed to Aperture Agent via flowcontrolv1.Check call.
	CallOptions []grpc.CallOption
	// If RampMode is set to true, then flow must be accepted by at least 1 LoadRamp component.
	RampMode bool
	// ResultCacheKey is key to the result cache entry which needs to be fetched at flow start.
	ResultCacheKey string
	// GlobalCacheKeys are keys to global cache entries that need to be fetched at flow start.
	GlobalCacheKeys []string
}

FlowParams is a struct that contains parameters for StartFlow call.

type FlowStatus

type FlowStatus uint8

FlowStatus represents status of flow execution.

const (
	// OK indicates successful flow execution.
	OK FlowStatus = iota
	// Error indicate error on flow execution.
	Error
)

User passes a code to indicate status of flow execution.

func FlowStatusString

func FlowStatusString(s string) (FlowStatus, error)

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

func FlowStatusValues

func FlowStatusValues() []FlowStatus

FlowStatusValues returns all values of the enum

func (FlowStatus) IsAFlowStatus

func (i FlowStatus) IsAFlowStatus() bool

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

func (FlowStatus) String

func (i FlowStatus) String() string

type HTTPFlow added in v2.22.0

type HTTPFlow interface {
	ShouldRun() bool
	SetStatus(status FlowStatus)
	Error() error
	Span() trace.Span
	End() EndResponse
	CheckResponse() *checkhttpv1.CheckHTTPResponse
}

HTTPFlow is the interface that is returned to the user every time a CheckHTTP call through ApertureClient is made. The user can check the status of the check call, response from the server, and end the flow once the workload is executed.

type KeyDeleteResponse added in v2.25.0

type KeyDeleteResponse interface {
	Error() error
}

KeyDeleteResponse is the interface to read the response from a delete cached value operation.

type KeyLookupResponse added in v2.25.0

type KeyLookupResponse interface {
	Value() []byte
	LookupStatus() LookupStatus
	Error() error
}

KeyLookupResponse is the interface to read the response from a get cached value operation.

type KeyUpsertResponse added in v2.25.0

type KeyUpsertResponse interface {
	Error() error
}

KeyUpsertResponse is the interface to read the response from a set cached value operation.

type LookupStatus added in v2.24.0

type LookupStatus string

LookupStatus is the status of a cache lookup, either HIT or MISS.

const (
	// LookupStatusHit indicates that the cache lookup was a hit.
	LookupStatusHit LookupStatus = "HIT"
	// LookupStatusMiss indicates that the cache lookup was a miss.
	LookupStatusMiss LookupStatus = "MISS"
)

type MiddlewareParams added in v2.24.0

type MiddlewareParams struct {
	IgnoredPaths         []string
	IgnoredPathsCompiled []*regexp.Regexp // New field for the compiled regex patterns
	FlowParams           FlowParams
	Timeout              time.Duration
}

MiddlewareParams is the interface for the middleware params.

type OperationStatus added in v2.24.0

type OperationStatus string

OperationStatus is the status of a cache operation, either SUCCESS or ERROR.

const (
	// OperationStatusSuccess indicates that the cache operation was successful.
	OperationStatusSuccess OperationStatus = "SUCCESS"
	// OperationStatusError indicates that the cache operation was unsuccessful.
	OperationStatusError OperationStatus = "ERROR"
)

type Options

type Options struct {
	Logger      *slog.Logger
	Address     string
	APIKey      string
	DialOptions []grpc.DialOption
}

Options that the user can pass to Aperture in order to receive a new Client. FlowControlClientConn and OTLPExporterClientConn are required.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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