Documentation
¶
Overview ¶
Package grpcproxy provides the proxy filter of gRPC.
Index ¶
- Constants
- type BaseServerPool
- type BaseServerPoolSpec
- type GrpcCodec
- type LoadBalanceSpec
- type LoadBalancer
- type MultiPool
- type Proxy
- func (p *Proxy) Close()
- func (p *Proxy) Handle(ctx *context.Context) (result string)
- func (p *Proxy) Inherit(previousGeneration filters.Filter)
- func (p *Proxy) Init()
- func (p *Proxy) InjectResiliencePolicy(policies map[string]resilience.Policy)
- func (p *Proxy) Kind() *filters.Kind
- func (p *Proxy) Name() string
- func (p *Proxy) Spec() filters.Spec
- func (p *Proxy) Status() interface{}
- type RequestMatcher
- type RequestMatcherSpec
- type Server
- type ServerPool
- type ServerPoolSpec
- type Spec
Constants ¶
const (
// Kind is the kind of Proxy.
Kind = "GRPCProxy"
)
const (
// LoadBalancePolicyForward is the load balance policy of forward.
LoadBalancePolicyForward = "forward"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseServerPool ¶
type BaseServerPool = proxies.ServerPoolBase
BaseServerPool is the base of a server pool.
type BaseServerPoolSpec ¶
type BaseServerPoolSpec = proxies.ServerPoolBaseSpec
BaseServerPoolSpec is the spec of BaseServerPool.
type GrpcCodec ¶
type GrpcCodec struct{}
GrpcCodec impl grpc.Codec instead of encoding.Codec, because encoding.Codec would changed grpc.header eg: if use encoding.Codec, then header's content-type=application/grpc -> content-type=application/grpc+xxx xxx from encoding.Codec.Name()
type LoadBalanceSpec ¶
type LoadBalanceSpec = proxies.LoadBalanceSpec
LoadBalanceSpec is the spec of a load balancer.
type LoadBalancer ¶
type LoadBalancer = proxies.LoadBalancer
LoadBalancer is the interface of a load balancer.
type MultiPool ¶
type MultiPool struct {
// contains filtered or unexported fields
}
MultiPool manage multi Pool.
func NewMultiWithSpec ¶
func NewMultiWithSpec(spec *objectpool.Spec) *MultiPool
NewMultiWithSpec return a new MultiPool
func (*MultiPool) Close ¶
func (m *MultiPool) Close()
Close closes the pool and clean all the objects
func (*MultiPool) Get ¶
func (m *MultiPool) Get(key string, ctx stdcontext.Context, new objectpool.CreateObjectFn) (objectpool.PoolObject, error)
Get returns an object from the pool,
if there's an exists single, it will try to get an available object; if there's no exists single, it will create a one and try to get an available object;
func (*MultiPool) Put ¶
func (m *MultiPool) Put(key string, obj objectpool.PoolObject)
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is the filter Proxy.
func (*Proxy) InjectResiliencePolicy ¶
func (p *Proxy) InjectResiliencePolicy(policies map[string]resilience.Policy)
InjectResiliencePolicy injects resilience policies to the proxy.
type RequestMatcher ¶
type RequestMatcher = proxies.RequestMatcher
RequestMatcher is the interface of a request matcher
func NewRequestMatcher ¶
func NewRequestMatcher(spec *RequestMatcherSpec) RequestMatcher
NewRequestMatcher creates a new traffic matcher according to spec.
type RequestMatcherSpec ¶
type RequestMatcherSpec struct { proxies.RequestMatcherBaseSpec `json:",inline"` Methods []*stringtool.StringMatcher `json:"methods,omitempty"` }
RequestMatcherSpec describe RequestMatcher
func (*RequestMatcherSpec) Validate ¶
func (s *RequestMatcherSpec) Validate() error
Validate validates the RequestMatcherSpec.
type ServerPool ¶
type ServerPool struct { BaseServerPool // contains filtered or unexported fields }
ServerPool defines a server pool.
func NewServerPool ¶
func NewServerPool(proxy *Proxy, spec *ServerPoolSpec, name string) *ServerPool
NewServerPool creates a new server pool according to spec.
func (*ServerPool) CreateLoadBalancer ¶
func (sp *ServerPool) CreateLoadBalancer(spec *LoadBalanceSpec, servers []*Server) LoadBalancer
CreateLoadBalancer creates a load balancer according to spec.
func (*ServerPool) InjectResiliencePolicy ¶
func (sp *ServerPool) InjectResiliencePolicy(policies map[string]resilience.Policy)
InjectResiliencePolicy injects resilience policies to the server pool.
type ServerPoolSpec ¶
type ServerPoolSpec struct { BaseServerPoolSpec `json:",inline"` SpanName string `json:"spanName,omitempty"` Filter *RequestMatcherSpec `json:"filter,omitempty"` CircuitBreakerPolicy string `json:"circuitBreakerPolicy,omitempty"` }
ServerPoolSpec is the spec for a server pool.
func (*ServerPoolSpec) Validate ¶
func (sps *ServerPoolSpec) Validate() error
Validate validates ServerPoolSpec.
type Spec ¶
type Spec struct { filters.BaseSpec `json:",inline"` Pools []*ServerPoolSpec `json:"pools" jsonschema:"required"` // Timeout could be specified in unary calls case, and in stream calls case, it should not be specified Timeout string `json:"timeout,omitempty" jsonschema:"format=duration"` BorrowTimeout string `json:"borrowTimeout,omitempty" jsonschema:"format=duration"` ConnectTimeout string `json:"connectTimeout,omitempty" jsonschema:"format=duration"` MaxIdleConnsPerHost int `json:"maxIdleConnsPerHost,omitempty"` }
Spec describes the Proxy.