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 ¶
- type Dispatcher
- type Impl
- func (d *Impl) ChangeRoute(new *routing.Table) *RoutingContext
- func (d *Impl) Check(ctx context.Context, bag attribute.Bag) (*adapter.CheckResult, error)
- func (d *Impl) Preprocess(ctx context.Context, bag attribute.Bag, responseBag *attribute.MutableBag) error
- func (d *Impl) Quota(ctx context.Context, bag attribute.Bag, qma *QuotaMethodArgs) (*adapter.QuotaResult, error)
- func (d *Impl) Report(ctx context.Context, bag attribute.Bag) error
- type QuotaMethodArgs
- type RoutingContext
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) // Report dispatches to the set of adapters associated with the Report API method Report(ctx context.Context, requestBag attribute.Bag) error // 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(identityAttribute string, 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) Preprocess ¶
func (d *Impl) Preprocess(ctx context.Context, bag attribute.Bag, responseBag *attribute.MutableBag) error
Preprocess 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 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) DecRef ¶
func (t *RoutingContext) DecRef()
DecRef decreases the reference count on the RoutingContext.
func (*RoutingContext) GetRefs ¶
func (t *RoutingContext) GetRefs() int32
GetRefs returns the current reference count on the dispatch context.
func (*RoutingContext) IncRef ¶
func (t *RoutingContext) IncRef()
IncRef increases the reference count on the RoutingContext.