grpcproxy

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package grpcproxy provides the proxy filter of gRPC.

Index

Constants

View Source
const (
	// Kind is the kind of Proxy.
	Kind = "GRPCProxy"
)
View Source
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()

func (GrpcCodec) Marshal

func (GrpcCodec) Marshal(v interface{}) ([]byte, error)

Marshal object to []byte

func (GrpcCodec) Name added in v2.6.1

func (GrpcCodec) Name() string

Name return codec name

func (GrpcCodec) Unmarshal

func (GrpcCodec) Unmarshal(data []byte, v interface{}) error

Unmarshal []byte to object

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

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) Close

func (p *Proxy) Close()

Close closes Proxy.

func (*Proxy) Handle

func (p *Proxy) Handle(ctx *context.Context) (result string)

Handle handles GRPCContext.

func (*Proxy) Inherit

func (p *Proxy) Inherit(previousGeneration filters.Filter)

Inherit inherits previous generation of Proxy.

func (*Proxy) Init

func (p *Proxy) Init()

Init initializes Proxy.

func (*Proxy) InjectResiliencePolicy

func (p *Proxy) InjectResiliencePolicy(policies map[string]resilience.Policy)

InjectResiliencePolicy injects resilience policies to the proxy.

func (*Proxy) Kind

func (p *Proxy) Kind() *filters.Kind

Kind returns the kind of Proxy.

func (*Proxy) Name

func (p *Proxy) Name() string

Name returns the name of the Proxy filter instance.

func (*Proxy) Spec

func (p *Proxy) Spec() filters.Spec

Spec returns the spec used by the Proxy

func (*Proxy) Status

func (p *Proxy) Status() interface{}

Status returns Proxy status.

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 Server

type Server = proxies.Server

Server is the backend server.

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.

func (*Spec) Validate

func (s *Spec) Validate() error

Validate validates Spec.

Jump to

Keyboard shortcuts

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