interceptor

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 1 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallInfo added in v0.6.0

type CallInfo struct {
	// The impl of the called component.
	Impl any
	// The component name of the called method.
	Component string
	// The full name of the called method, in the format of "package/service.method".
	FullMethod string
	// The name of the method.
	Method string
}

CallInfo contains information about the call.

type Condition

type Condition func(ctx context.Context, info CallInfo) bool

Condition is the type of the function used to determine whether an interceptor should be used.

func And

func And(first, second Condition, conditions ...Condition) Condition

And groups conditions with the AND operator.

func IsMethod

func IsMethod(method string) Condition

IsMethod returns a condition that checks if the method name matches the given method.

func Not

func Not(condition Condition) Condition

Not negates the given condition.

func Or

func Or(first, second Condition, conditions ...Condition) Condition

Or groups conditions with the OR operator.

type HandleFunc added in v0.6.0

type HandleFunc func(ctx context.Context, info CallInfo, req, reply []any) error

HandleFunc is the type of the function invoked by Components.

type Interceptor added in v0.6.0

type Interceptor func(ctx context.Context, info CallInfo, req, reply []any, invoker HandleFunc) error

Interceptor is the type of the function used to intercept Components.

func Chain

func Chain(interceptors []Interceptor) Interceptor

Chain converts a slice of Interceptors into a single Interceptor.

func If

func If(interceptor Interceptor, condition Condition) Interceptor

If returns an Interceptor that only invokes the given interceptor if the given condition is true.

Jump to

Keyboard shortcuts

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