Documentation
¶
Index ¶
- Constants
- type Client
- type CompressionSpec
- type FallbackSpec
- type LoadBalance
- type MTLS
- type PoolSpec
- type PoolStatus
- type Proxy
- func (b *Proxy) Close()
- func (b *Proxy) DefaultSpec() interface{}
- func (b *Proxy) Description() string
- func (b *Proxy) Handle(ctx context.HTTPContext) (result string)
- func (b *Proxy) Inherit(filterSpec *httppipeline.FilterSpec, previousGeneration httppipeline.Filter)
- func (b *Proxy) Init(filterSpec *httppipeline.FilterSpec)
- func (b *Proxy) Kind() string
- func (b *Proxy) Results() []string
- func (b *Proxy) Status() interface{}
- type Server
- type Spec
- type Status
Constants ¶
const ( // PolicyRoundRobin is the policy of round-robin. PolicyRoundRobin = "roundRobin" // PolicyRandom is the policy of random. PolicyRandom = "random" // PolicyWeightedRandom is the policy of weighted random. PolicyWeightedRandom = "weightedRandom" // PolicyIPHash is the policy of ip hash. PolicyIPHash = "ipHash" // PolicyHeaderHash is the policy of header hash. PolicyHeaderHash = "headerHash" )
const (
// Kind is the kind of Proxy.
Kind = "Proxy"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v1.5.2
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper around http.Client.
type CompressionSpec ¶
type CompressionSpec struct {
MinLength uint32 `yaml:"minLength"`
}
CompressionSpec describes the compression.
type FallbackSpec ¶
FallbackSpec describes the fallback policy.
type LoadBalance ¶
type LoadBalance struct { Policy string `yaml:"policy" jsonschema:"required,enum=roundRobin,enum=random,enum=weightedRandom,enum=ipHash,enum=headerHash"` HeaderHashKey string `yaml:"headerHashKey" jsonschema:"omitempty"` }
LoadBalance is load balance for multiple servers.
func (LoadBalance) Validate ¶
func (lb LoadBalance) Validate() error
Validate validates LoadBalance.
type MTLS ¶ added in v1.3.1
type MTLS struct { CertBase64 string `yaml:"certBase64" jsonschema:"required,format=base64"` KeyBase64 string `yaml:"keyBase64" jsonschema:"required,format=base64"` RootCertBase64 string `yaml:"rootCertBase64" jsonschema:"required,format=base64"` }
MTLS is the configuration for client side mTLS.
type PoolSpec ¶
type PoolSpec struct { SpanName string `yaml:"spanName" jsonschema:"omitempty"` Filter *httpfilter.Spec `yaml:"filter" jsonschema:"omitempty"` ServersTags []string `yaml:"serversTags" jsonschema:"omitempty,uniqueItems=true"` Servers []*Server `yaml:"servers" jsonschema:"omitempty"` ServiceRegistry string `yaml:"serviceRegistry" jsonschema:"omitempty"` ServiceName string `yaml:"serviceName" jsonschema:"omitempty"` LoadBalance *LoadBalance `yaml:"loadBalance" jsonschema:"required"` MemoryCache *memorycache.Spec `yaml:"memoryCache,omitempty" jsonschema:"omitempty"` }
PoolSpec describes a pool of servers.
type PoolStatus ¶
PoolStatus is the status of Pool.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is the filter Proxy.
func (*Proxy) DefaultSpec ¶
func (b *Proxy) DefaultSpec() interface{}
DefaultSpec returns the default spec of Proxy.
func (*Proxy) Description ¶
Description returns the description of Proxy.
func (*Proxy) Handle ¶
func (b *Proxy) Handle(ctx context.HTTPContext) (result string)
Handle handles HTTPContext. When we create new request for backend, we call http.NewRequestWithContext method and use context.Request().Body() as body. Based on golang std lib comments: https://github.com/golang/go/blob/95b68e1e02fa713719f02f6c59fb1532bd05e824/src/net/http/request.go#L856-L860 If body is of type *bytes.Buffer, *bytes.Reader, or *strings.Reader, the returned request's ContentLength is set to its exact value (instead of -1), GetBody is populated (so 307 and 308 redirects can replay the body), and Body is set to NoBody if the ContentLength is 0.
So in this way, http.Request.ContentLength will be 0, and when http.Client send this request, it will delete "Content-Length" key in header. We solve this problem by set http.Request.ContentLength equal to http.Request.Header["Content-Length"] (if it is presented). Reading all context.Request().Body() and create new request with bytes.NewReader is another way, but it may cause performance loss.
It is important that "Content-Length" in the Header is equal to the length of the Body. In easegress, when a filter change Request.Body, it will delete the header of "Content-Length". So, you should not worry about this when using our filters. But for customer filters, developer should make sure to delete or set "Context-Length" value in header when change Request.Body.
func (*Proxy) Inherit ¶
func (b *Proxy) Inherit(filterSpec *httppipeline.FilterSpec, previousGeneration httppipeline.Filter)
Inherit inherits previous generation of Proxy.
func (*Proxy) Init ¶
func (b *Proxy) Init(filterSpec *httppipeline.FilterSpec)
Init initializes Proxy.
type Server ¶
type Server struct { URL string `yaml:"url" jsonschema:"required,format=url"` Tags []string `yaml:"tags" jsonschema:"omitempty,uniqueItems=true"` Weight int `yaml:"weight" jsonschema:"omitempty,minimum=0,maximum=100"` KeepHost bool `yaml:"keepHost" jsonschema:"omitempty,default=false` // contains filtered or unexported fields }
Server is proxy server.
type Spec ¶
type Spec struct { Fallback *FallbackSpec `yaml:"fallback,omitempty" jsonschema:"omitempty"` MainPool *PoolSpec `yaml:"mainPool" jsonschema:"required"` CandidatePools []*PoolSpec `yaml:"candidatePools,omitempty" jsonschema:"omitempty"` MirrorPool *PoolSpec `yaml:"mirrorPool,omitempty" jsonschema:"omitempty"` FailureCodes []int `yaml:"failureCodes" jsonschema:"omitempty,uniqueItems=true,format=httpcode-array"` Compression *CompressionSpec `yaml:"compression,omitempty" jsonschema:"omitempty"` MTLS *MTLS `yaml:"mtls,omitempty" jsonschema:"omitempty"` MaxIdleConns int `yaml:"maxIdleConns" jsonschema:"omitempty"` MaxIdleConnsPerHost int `yaml:"maxIdleConnsPerHost" jsonschema:"omitempty"` }
Spec describes the Proxy.
type Status ¶
type Status struct { MainPool *PoolStatus `yaml:"mainPool"` CandidatePools []*PoolStatus `yaml:"candidatePools,omitempty"` MirrorPool *PoolStatus `yaml:"mirrorPool,omitempty"` }
Status is the status of Proxy.