aspect

package
Version: v0.0.0-...-5253b6b Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2017 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package aspect contains the various aspect managers which are responsible for mapping incoming requests into the interface expected by individual types of aspects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateAspectFunc

type CreateAspectFunc func(env adapter.Env, c adapter.Config, optional ...interface{}) (adapter.Aspect, error)

CreateAspectFunc represents a function capable of returning an aspect instance. It accepts optional params that may be required for some aspects (Metrics, Quotas).

func FromBuilder

func FromBuilder(builder adapter.Builder, kind cfg.Kind) (CreateAspectFunc, error)

FromBuilder creates a CreateAspectFunc from the provided builder instance, dispatching to New*Aspect methods based on the kind parameter.

func FromHandler

func FromHandler(handler adapter.Handler) CreateAspectFunc

FromHandler creates a CreateAspectFunc from the provided handler instance.

type Executor

type Executor interface {
	io.Closer
}

Executor encapsulates a single aspect and allows it to be invoked.

type Manager

type Manager interface {
	config.AspectValidator

	// Kind return the kind of aspect handled by this manager
	Kind() config.Kind
}

Manager is responsible for a specific aspect and presents a uniform interface to the rest of the system.

type ManagerInventory

type ManagerInventory struct {
	Preprocess []PreprocessManager
	Quota      []QuotaManager
}

ManagerInventory holds a set of aspect managers.

func Inventory

func Inventory() ManagerInventory

Inventory returns the authoritative set of aspect managers used by Mixer.

type PreprocessExecutor

type PreprocessExecutor interface {
	Executor

	// Execute dispatches to the aspect manager.
	Execute(attrs attribute.Bag, mapper expr.Evaluator) (*PreprocessResult, rpc.Status)
}

PreprocessExecutor encapsulates a single PreprocessManager aspect and allows it to be invoked.

type PreprocessManager

type PreprocessManager interface {
	Manager

	// NewPreprocessExecutor creates a new executor given configuration.
	NewPreprocessExecutor(cfg *cpb.Combined, createAspect CreateAspectFunc, env adapter.Env, df descriptor.Finder) (PreprocessExecutor, error)
}

A PreprocessManager handles adapter execution for pre-processing of requests before request dispatch to managers of the various API methods.

type PreprocessResult

type PreprocessResult struct {
	// Attrs holds the set of attributes generated by a PreprocessExecutor.
	Attrs *attribute.MutableBag
}

PreprocessResult holds the generated data from the preprocess adapters.

type QuotaExecutor

type QuotaExecutor interface {
	Executor

	// Execute dispatches to the aspect manager.
	Execute(attrs attribute.Bag, mapper expr.Evaluator, qma *QuotaMethodArgs) (rpc.Status, *QuotaMethodResp)
}

QuotaExecutor encapsulates a single QuotaManager aspect and allows it to be invoked.

type QuotaManager

type QuotaManager interface {
	Manager

	// NewQuotaExecutor creates a new aspect executor given configuration.
	NewQuotaExecutor(cfg *cpb.Combined, createAspect CreateAspectFunc, env adapter.Env, df descriptor.Finder, tmpl string) (QuotaExecutor, error)
}

QuotaManager take care of aspects used to implement the Quota API method

type QuotaMethodArgs

type QuotaMethodArgs struct {
	// Used for deduplicating quota allocation/free calls in the case of
	// failed RPCs and retries. This should be a UUID per call, where the same
	// UUID is used for retries of the same quota allocation call.
	DeduplicationID string

	// The quota to allocate from.
	Quota string

	// The amount of quota to allocate.
	Amount int64

	// If true, allows a response to return less quota than requested. When
	// false, the exact requested amount is returned or 0 if not enough quota
	// was available.
	BestEffort bool
}

QuotaMethodArgs is supplied by invocations of the Quota method.

type QuotaMethodResp

type QuotaMethodResp struct {
	// The amount of time until which the returned quota expires, this is 0 for non-expiring quotas.
	Expiration time.Duration

	// The total amount of quota returned, may be less than requested.
	Amount int64
}

QuotaMethodResp is returned by invocations of the Quota method.

Directories

Path Synopsis
Package test provides utilities for testing the //pkg/aspect code.
Package test provides utilities for testing the //pkg/aspect code.

Jump to

Keyboard shortcuts

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