dispatcher

package
v0.0.0-...-865e90e Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package dispatcher is used to dispatch incoming requests to one or more handlers. The main entry point is the Impl struct, which implements the main dispatcher.Dispatcher interface.

Once the dispatcher receives a request, it acquires the current routing table, and uses it until the end of the request. Additionally, it acquires an executor from a pool, which is used to perform and track the parallel calls that will be performed against the handlers. The executors scatter the calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher interface {
	// Preprocess dispatches to the set of adapters that will run before any
	// other adapters in Mixer (aka: the Check, Report, Quota adapters).
	Preprocess(ctx context.Context, requestBag attribute.Bag, responseBag *attribute.MutableBag) error

	// Check dispatches to the set of adapters associated with the Check API method
	Check(ctx context.Context, requestBag attribute.Bag) (adapter.CheckResult, error)

	// GetReporter get an interface where reports are buffered.
	GetReporter(ctx context.Context) Reporter

	// Quota dispatches to the set of adapters associated with the Quota API method
	Quota(ctx context.Context, requestBag attribute.Bag,
		qma QuotaMethodArgs) (adapter.QuotaResult, error)
}

Dispatcher dispatches incoming API calls to configured adapters.

type Impl

type Impl struct {
	// contains filtered or unexported fields
}

Impl is the runtime implementation of the Dispatcher interface.

func New

func New(handlerGP *pool.GoroutinePool, enableTracing bool) *Impl

New returns a new Impl instance. The Impl instance is initialized with an empty routing table.

func (*Impl) ChangeRoute

func (d *Impl) ChangeRoute(new *routing.Table) *RoutingContext

ChangeRoute changes the routing table on the Impl which, in turn, ends up creating a new RoutingContext.

func (*Impl) Check

func (d *Impl) Check(ctx context.Context, bag attribute.Bag) (adapter.CheckResult, error)

Check implementation of runtime.Impl.

func (*Impl) GetReporter

func (d *Impl) GetReporter(ctx context.Context) Reporter

GetReporter implementation of runtime.Impl.

func (*Impl) Preprocess

func (d *Impl) Preprocess(ctx context.Context, bag attribute.Bag, responseBag *attribute.MutableBag) error

Preprocess implementation of runtime.Impl.

func (*Impl) Quota

Quota implementation of runtime.Impl.

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 Reporter

type Reporter interface {
	// Report adds an entry to the report state
	Report(requestBag attribute.Bag) error

	// Flush dispatches all buffered state to the appropriate adapters.
	Flush() error

	// Completes use of the reporter
	Done()
}

Reporter is used to produce a series of reports

type RoutingContext

type RoutingContext struct {
	// the routing table of this context.
	Routes *routing.Table
	// contains filtered or unexported fields
}

RoutingContext is the currently active dispatching context, based on a config snapshot. As config changes, the current/live RoutingContext also changes.

func (*RoutingContext) GetRefs

func (rc *RoutingContext) GetRefs() int32

GetRefs returns the current reference count on the dispatch context.

Jump to

Keyboard shortcuts

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