api

package
v1.30.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 4 Imported by: 16

Documentation

Index

Constants

View Source
const (
	NormalFinalize int = 0 // normal, finalize on destroy
	GCFinalize     int = 1 // finalize in GC sweep
)

Variables

View Source
var (
	ErrInternalFailure = errors.New("internal failure")
	ErrValueNotFound   = errors.New("value not found")
	// Failed to serialize the value when we fetch the value as string
	ErrSerializationFailure = errors.New("serialization failure")
)

*************** errors start **************//

Functions

func LogCritical added in v1.28.0

func LogCritical(message string)

func LogCriticalf added in v1.28.0

func LogCriticalf(format string, v ...any)

func LogDebug added in v1.28.0

func LogDebug(message string)

func LogDebugf added in v1.28.0

func LogDebugf(format string, v ...any)

func LogError added in v1.28.0

func LogError(message string)

func LogErrorf added in v1.28.0

func LogErrorf(format string, v ...any)

func LogInfo added in v1.28.0

func LogInfo(message string)

func LogInfof added in v1.28.0

func LogInfof(format string, v ...any)

func LogTrace added in v1.28.0

func LogTrace(message string)

func LogTracef added in v1.28.0

func LogTracef(format string, v ...any)

func LogWarn added in v1.28.0

func LogWarn(message string)

func LogWarnf added in v1.28.0

func LogWarnf(format string, v ...any)

func SetCommonCAPI added in v1.28.0

func SetCommonCAPI(api CommonCAPI)

SetCommonCAPI for mock cAPI

Types

type AccessLogType added in v1.28.0

type AccessLogType int

For each AccessLogType's meaning, see https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage Currently, only some downstream access log types are supported

const (
	AccessLogNotSet                                  AccessLogType = 0
	AccessLogTcpUpstreamConnected                    AccessLogType = 1
	AccessLogTcpPeriodic                             AccessLogType = 2
	AccessLogTcpConnectionEnd                        AccessLogType = 3
	AccessLogDownstreamStart                         AccessLogType = 4
	AccessLogDownstreamPeriodic                      AccessLogType = 5
	AccessLogDownstreamEnd                           AccessLogType = 6
	AccessLogUpstreamPoolReady                       AccessLogType = 7
	AccessLogUpstreamPeriodic                        AccessLogType = 8
	AccessLogUpstreamEnd                             AccessLogType = 9
	AccessLogDownstreamTunnelSuccessfullyEstablished AccessLogType = 10
)

type BufferAction

type BufferAction int

*************** BufferInstance start **************//

const (
	SetBuffer     BufferAction = 0
	AppendBuffer  BufferAction = 1
	PrependBuffer BufferAction = 2
)

type BufferInstance

type BufferInstance interface {
	DataBufferBase

	// Set overwrite the whole buffer content with byte slice.
	Set([]byte) error

	// SetString overwrite the whole buffer content with string.
	SetString(string) error

	// Prepend prepend the contents of the slice data to the buffer.
	Prepend(data []byte) error

	// Prepend prepend the contents of the string data to the buffer.
	PrependString(s string) error

	// Append append the contents of the string data to the buffer.
	AppendString(s string) error
}

type CommonCAPI added in v1.28.0

type CommonCAPI interface {
	Log(level LogType, message string)
	LogLevel() LogType
}

type ConfigCallbackHandler added in v1.28.0

type ConfigCallbackHandler interface {
	ConfigCallbacks
}

type ConfigCallbacks added in v1.28.0

type ConfigCallbacks interface {
	// Define a metric, for different MetricType, name must be different,
	// for same MetricType, the same name will share a metric.
	DefineCounterMetric(name string) CounterMetric
	DefineGaugeMetric(name string) GaugeMetric
}

type ConnectionCallback

type ConnectionCallback interface {
	// StreamInfo returns the stream info of the connection
	StreamInfo() StreamInfo
	// Write data to the connection.
	Write(buffer []byte, endStream bool)
	// Close the connection.
	Close(closeType ConnectionCloseType)
}

type ConnectionCloseType

type ConnectionCloseType int

Type of connection close to perform.

const (
	// Flush pending write data before raising ConnectionEvent::LocalClose
	FlushWrite ConnectionCloseType = 0
	// Do not flush any pending data. Write the pending data to buffer and then immediately
	// raise ConnectionEvent::LocalClose
	NoFlush ConnectionCloseType = 1
	// Flush pending write data and delay raising a ConnectionEvent::LocalClose
	// until the delayed_close_timeout expires
	FlushWriteAndDelay ConnectionCloseType = 2
	// Do not write/flush any pending data and immediately raise ConnectionEvent::LocalClose
	Abort ConnectionCloseType = 3
	// Do not write/flush any pending data and immediately raise
	// ConnectionEvent::LocalClose. Envoy will try to close the connection with RST flag.
	AbortReset ConnectionCloseType = 4
)

func (ConnectionCloseType) String

func (t ConnectionCloseType) String() string

type ConnectionEvent

type ConnectionEvent int

Events that occur on a connection.

const (
	RemoteClose      ConnectionEvent = 0
	LocalClose       ConnectionEvent = 1
	Connected        ConnectionEvent = 2
	ConnectedZeroRtt ConnectionEvent = 3
)

func (ConnectionEvent) String

func (e ConnectionEvent) String() string

type ConnectionInfoType

type ConnectionInfoType int
const (
	ConnectionInfoLocalAddr  ConnectionInfoType = 0
	ConnectionInfoRemoteAddr ConnectionInfoType = 1
)

func (ConnectionInfoType) String

func (t ConnectionInfoType) String() string

type CounterMetric added in v1.28.0

type CounterMetric interface {
	Increment(offset int64)
	Get() uint64
	Record(value uint64)
}

type DataBufferBase

type DataBufferBase interface {
	// Write appends the contents of p to the buffer, growing the buffer as
	// needed. The return value n is the length of p; err is always nil. If the
	// buffer becomes too large, Write will panic with ErrTooLarge.
	Write(p []byte) (n int, err error)

	// WriteString appends the string to the buffer, growing the buffer as
	// needed. The return value n is the length of s; err is always nil. If the
	// buffer becomes too large, Write will panic with ErrTooLarge.
	WriteString(s string) (n int, err error)

	// WriteByte appends the byte to the buffer, growing the buffer as
	// needed. The return value n is the length of s; err is always nil. If the
	// buffer becomes too large, Write will panic with ErrTooLarge.
	WriteByte(p byte) error

	// WriteUint16 appends the uint16 to the buffer, growing the buffer as
	// needed. The return value n is the length of s; err is always nil. If the
	// buffer becomes too large, Write will panic with ErrTooLarge.
	WriteUint16(p uint16) error

	// WriteUint32 appends the uint32 to the buffer, growing the buffer as
	// needed. The return value n is the length of s; err is always nil. If the
	// buffer becomes too large, Write will panic with ErrTooLarge.
	WriteUint32(p uint32) error

	// WriteUint64 appends the uint64 to the buffer, growing the buffer as
	// needed. The return value n is the length of s; err is always nil. If the
	// buffer becomes too large, Write will panic with ErrTooLarge.
	WriteUint64(p uint64) error

	// Bytes returns all bytes from buffer, without draining any buffered data.
	// It can be used to get fixed-length content, such as headers, body.
	// Note: do not change content in return bytes, use write instead
	Bytes() []byte

	// Drain drains a offset length of bytes in buffer.
	// It can be used with Bytes(), after consuming a fixed-length of data
	Drain(offset int)

	// Len returns the number of bytes of the unread portion of the buffer;
	// b.Len() == len(b.Bytes()).
	Len() int

	// Reset resets the buffer to be empty.
	Reset()

	// String returns the contents of the buffer as a string.
	String() string

	// Append append the contents of the slice data to the buffer.
	Append(data []byte) error
}

type DestroyReason

type DestroyReason int
const (
	Normal    DestroyReason = 0
	Terminate DestroyReason = 1
)

type DownstreamFilter

type DownstreamFilter interface {
	// Called when a connection is first established.
	OnNewConnection() FilterStatus
	// Called when data is read on the connection.
	OnData(buffer []byte, endOfStream bool) FilterStatus
	// Callback for connection events.
	OnEvent(event ConnectionEvent)
	// Called when data is to be written on the connection.
	OnWrite(buffer []byte, endOfStream bool) FilterStatus
}

type DynamicMetadata

type DynamicMetadata interface {
	Get(filterName string) map[string]interface{}
	Set(filterName string, key string, value interface{})
}

type EmptyDownstreamFilter added in v1.28.0

type EmptyDownstreamFilter struct{}

EmptyDownstreamFilter provides the no-op implementation of the DownstreamFilter interface

func (*EmptyDownstreamFilter) OnData added in v1.28.0

func (*EmptyDownstreamFilter) OnData(buffer []byte, endOfStream bool) FilterStatus

func (*EmptyDownstreamFilter) OnEvent added in v1.28.0

func (*EmptyDownstreamFilter) OnEvent(event ConnectionEvent)

func (*EmptyDownstreamFilter) OnNewConnection added in v1.28.0

func (*EmptyDownstreamFilter) OnNewConnection() FilterStatus

func (*EmptyDownstreamFilter) OnWrite added in v1.28.0

func (*EmptyDownstreamFilter) OnWrite(buffer []byte, endOfStream bool) FilterStatus

type EmptyUpstreamFilter added in v1.28.0

type EmptyUpstreamFilter struct{}

EmptyUpstreamFilter provides the no-op implementation of the UpstreamFilter interface

func (*EmptyUpstreamFilter) OnData added in v1.28.0

func (*EmptyUpstreamFilter) OnData(buffer []byte, endOfStream bool) FilterStatus

func (*EmptyUpstreamFilter) OnEvent added in v1.28.0

func (*EmptyUpstreamFilter) OnEvent(event ConnectionEvent)

func (*EmptyUpstreamFilter) OnPoolFailure added in v1.28.0

func (*EmptyUpstreamFilter) OnPoolFailure(poolFailureReason PoolFailureReason, transportFailureReason string)

func (*EmptyUpstreamFilter) OnPoolReady added in v1.28.0

func (*EmptyUpstreamFilter) OnPoolReady(cb ConnectionCallback)

type EnvoyRequestPhase

type EnvoyRequestPhase int
const (
	DecodeHeaderPhase EnvoyRequestPhase = iota + 1
	DecodeDataPhase
	DecodeTrailerPhase
	EncodeHeaderPhase
	EncodeDataPhase
	EncodeTrailerPhase
)

func (EnvoyRequestPhase) String

func (e EnvoyRequestPhase) String() string

type FilterCallbackHandler

type FilterCallbackHandler interface {
	FilterCallbacks
}

type FilterCallbacks

type FilterCallbacks interface {
	StreamFilterCallbacks
	// ClearRouteCache clears the route cache for the current request, and filtermanager will re-fetch the route in the next filter.
	// Please be careful to invoke it, since filtermanager will raise an 404 route_not_found response when failed to re-fetch a route.
	ClearRouteCache()
	// Continue or SendLocalReply should be last API invoked, no more code after them.
	Continue(StatusType)
	SendLocalReply(responseCode int, bodyText string, headers map[string][]string, grpcStatus int64, details string)
	// RecoverPanic recover panic in defer and terminate the request by SendLocalReply with 500 status code.
	RecoverPanic()
	Log(level LogType, msg string)
	LogLevel() LogType
	// GetProperty fetch Envoy attribute and return the value as a string.
	// The list of attributes can be found in https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/attributes.
	// If the fetch succeeded, a string will be returned.
	// If the value is a timestamp, it is returned as a timestamp string like "2023-07-31T07:21:40.695646+00:00".
	// If the fetch failed (including the value is not found), an error will be returned.
	//
	// The error can be one of:
	// * ErrInternalFailure
	// * ErrSerializationFailure (Currently, fetching attributes in List/Map type are unsupported)
	// * ErrValueNotFound
	GetProperty(key string) (string, error)
}

type FilterState

type FilterState interface {
	SetString(key, value string, stateType StateType, lifeSpan LifeSpan, streamSharing StreamSharing)
	GetString(key string) string
}

type FilterStatus

type FilterStatus int

Status codes returned by filters that can cause future filters to not get iterated to.

const (
	// Continue to further filters.
	NetworkFilterContinue FilterStatus = 0
	// Stop executing further filters.
	NetworkFilterStopIteration FilterStatus = 1
)

func (FilterStatus) String

func (s FilterStatus) String() string

type GaugeMetric added in v1.28.0

type GaugeMetric interface {
	Increment(offset int64)
	Get() uint64
	Record(value uint64)
}

type HeaderMap

type HeaderMap interface {
	// GetRaw is unsafe, reuse the memory from Envoy
	GetRaw(name string) string

	// Get value of key
	// If multiple values associated with this key, first one will be returned.
	Get(key string) (string, bool)

	// Values returns all values associated with the given key.
	// The returned slice is not a copy.
	Values(key string) []string

	// Set key-value pair in header map, the previous pair will be replaced if exists.
	// It may not take affects immediately in the Envoy thread side when it's invoked in a Go thread.
	// This won't refresh route cache, please invoke ClearRouteCache if needed.
	Set(key, value string)

	// Add value for given key.
	// Multiple headers with the same key may be added with this function.
	// Use Set for setting a single header for the given key.
	// It may not take affects immediately in the Envoy thread side when it's invoked in a Go thread.
	// This won't refresh route cache, please invoke ClearRouteCache if needed.
	Add(key, value string)

	// Del delete pair of specified key
	// It may not take affects immediately in the Envoy thread side when it's invoked in a Go thread.
	// This won't refresh route cache, please invoke ClearRouteCache if needed.
	Del(key string)

	// Range calls f sequentially for each key and value present in the map.
	// If f returns false, range stops the iteration.
	// When there are multiple values of a key, f will be invoked multiple times with the same key and each value.
	Range(f func(key, value string) bool)

	// RangeWithCopy calls f sequentially for each key and value copied from the map.
	RangeWithCopy(f func(key, value string) bool)
}

refer https://github.com/envoyproxy/envoy/blob/main/envoy/http/header_map.h

type HistogramMetric added in v1.28.0

type HistogramMetric interface {
}

TODO

type HttpCAPI

type HttpCAPI interface {
	ClearRouteCache(r unsafe.Pointer)
	HttpContinue(r unsafe.Pointer, status uint64)
	HttpSendLocalReply(r unsafe.Pointer, responseCode int, bodyText string, headers map[string][]string, grpcStatus int64, details string)

	// Send a specialized reply that indicates that the filter has failed on the go side. Internally this is used for
	// when unhandled panics are detected.
	HttpSendPanicReply(r unsafe.Pointer, details string)
	// experience api, memory unsafe
	HttpGetHeader(r unsafe.Pointer, key string) string
	HttpCopyHeaders(r unsafe.Pointer, num uint64, bytes uint64) map[string][]string
	HttpSetHeader(r unsafe.Pointer, key string, value string, add bool)
	HttpRemoveHeader(r unsafe.Pointer, key string)

	HttpGetBuffer(r unsafe.Pointer, bufferPtr uint64, length uint64) []byte
	HttpDrainBuffer(r unsafe.Pointer, bufferPtr uint64, length uint64)
	HttpSetBufferHelper(r unsafe.Pointer, bufferPtr uint64, value string, action BufferAction)
	HttpSetBytesBufferHelper(r unsafe.Pointer, bufferPtr uint64, value []byte, action BufferAction)

	HttpCopyTrailers(r unsafe.Pointer, num uint64, bytes uint64) map[string][]string
	HttpSetTrailer(r unsafe.Pointer, key string, value string, add bool)
	HttpRemoveTrailer(r unsafe.Pointer, key string)

	HttpGetStringValue(r unsafe.Pointer, id int) (string, bool)
	HttpGetIntegerValue(r unsafe.Pointer, id int) (uint64, bool)

	HttpGetDynamicMetadata(r unsafe.Pointer, filterName string) map[string]interface{}
	HttpSetDynamicMetadata(r unsafe.Pointer, filterName string, key string, value interface{})

	HttpLog(level LogType, message string)
	HttpLogLevel() LogType

	HttpFinalize(r unsafe.Pointer, reason int)
	HttpConfigFinalize(c unsafe.Pointer)

	HttpSetStringFilterState(r unsafe.Pointer, key string, value string, stateType StateType, lifeSpan LifeSpan, streamSharing StreamSharing)
	HttpGetStringFilterState(r unsafe.Pointer, key string) string

	HttpGetStringProperty(r unsafe.Pointer, key string) (string, error)

	HttpDefineMetric(c unsafe.Pointer, metricType MetricType, name string) uint32
	HttpIncrementMetric(c unsafe.Pointer, metricId uint32, offset int64)
	HttpGetMetric(c unsafe.Pointer, metricId uint32) uint64
	HttpRecordMetric(c unsafe.Pointer, metricId uint32, value uint64)
}

type LifeSpan

type LifeSpan int
const (
	LifeSpanFilterChain LifeSpan = 0
	LifeSpanRequest     LifeSpan = 1
	LifeSpanConnection  LifeSpan = 2
	LifeSpanTopSpan     LifeSpan = 3
)

type LogType

type LogType int

****************** log level start ******************//

const (
	Trace    LogType = 0
	Debug    LogType = 1
	Info     LogType = 2
	Warn     LogType = 3
	Error    LogType = 4
	Critical LogType = 5
)

refer https://github.com/envoyproxy/envoy/blob/main/source/common/common/base_logger.h

func GetLogLevel added in v1.28.0

func GetLogLevel() LogType

func (LogType) String

func (self LogType) String() string

type MetadataMap

type MetadataMap interface {
}

type MetricType added in v1.28.0

type MetricType uint32
const (
	Counter   MetricType = 0
	Gauge     MetricType = 1
	Histogram MetricType = 2
)

type NetworkCAPI

type NetworkCAPI interface {
	// DownstreamWrite writes buffer data into downstream connection.
	DownstreamWrite(f unsafe.Pointer, bufferPtr unsafe.Pointer, bufferLen int, endStream int)
	// DownstreamClose closes the downstream connection
	DownstreamClose(f unsafe.Pointer, closeType int)
	// DownstreamFinalize cleans up the resource of downstream connection, should be called only by runtime.SetFinalizer
	DownstreamFinalize(f unsafe.Pointer, reason int)
	// DownstreamInfo gets the downstream connection info of infoType
	DownstreamInfo(f unsafe.Pointer, infoType int) string
	// GetFilterState gets the filter state of key
	GetFilterState(f unsafe.Pointer, key string) string
	// SetFilterState sets the filter state of key to value
	SetFilterState(f unsafe.Pointer, key string, value string, stateType StateType, lifeSpan LifeSpan, streamSharing StreamSharing)

	// UpstreamConnect creates an envoy upstream connection to address
	UpstreamConnect(libraryID string, addr string, connID uint64) unsafe.Pointer
	// UpstreamWrite writes buffer data into upstream connection.
	UpstreamWrite(f unsafe.Pointer, bufferPtr unsafe.Pointer, bufferLen int, endStream int)
	// UpstreamClose closes the upstream connection
	UpstreamClose(f unsafe.Pointer, closeType int)
	// UpstreamFinalize cleans up the resource of upstream connection, should be called only by runtime.SetFinalizer
	UpstreamFinalize(f unsafe.Pointer, reason int)
	// UpstreamInfo gets the upstream connection info of infoType
	UpstreamInfo(f unsafe.Pointer, infoType int) string
}

type PassThroughStreamDecoderFilter

type PassThroughStreamDecoderFilter struct{}

PassThroughStreamDecoderFilter provides the no-op implementation of the StreamDecoderFilter interface.

func (*PassThroughStreamDecoderFilter) DecodeData

func (*PassThroughStreamDecoderFilter) DecodeHeaders

func (*PassThroughStreamDecoderFilter) DecodeTrailers

type PassThroughStreamEncoderFilter

type PassThroughStreamEncoderFilter struct{}

PassThroughStreamEncoderFilter provides the no-op implementation of the StreamEncoderFilter interface.

func (*PassThroughStreamEncoderFilter) EncodeData

func (*PassThroughStreamEncoderFilter) EncodeHeaders

func (*PassThroughStreamEncoderFilter) EncodeTrailers

type PassThroughStreamFilter

type PassThroughStreamFilter struct {
	PassThroughStreamDecoderFilter
	PassThroughStreamEncoderFilter
}

PassThroughStreamFilter provides the no-op implementation of the StreamFilter interface.

func (*PassThroughStreamFilter) OnDestroy

func (*PassThroughStreamFilter) OnLog added in v1.28.0

func (*PassThroughStreamFilter) OnLog()

func (*PassThroughStreamFilter) OnLogDownstreamPeriodic added in v1.28.0

func (*PassThroughStreamFilter) OnLogDownstreamPeriodic()

func (*PassThroughStreamFilter) OnLogDownstreamStart added in v1.28.0

func (*PassThroughStreamFilter) OnLogDownstreamStart()

type PoolFailureReason

type PoolFailureReason int
const (
	// A resource overflowed and policy prevented a new connection from being created.
	Overflow PoolFailureReason = 0
	// A local connection failure took place while creating a new connection.
	LocalConnectionFailure PoolFailureReason = 1
	// A remote connection failure took place while creating a new connection.
	RemoteConnectionFailure PoolFailureReason = 2
	// A timeout occurred while creating a new connection.
	Timeout PoolFailureReason = 3
)

func (PoolFailureReason) String

func (r PoolFailureReason) String() string

type RequestHeaderMap

type RequestHeaderMap interface {
	HeaderMap
	Scheme() string
	Method() string
	Host() string
	Path() string
	// SetMethod set method in header map
	// This won't refresh route cache, please invoke ClearRouteCache if needed.
	SetMethod(method string)
	// SetHost set host in header map
	// This won't refresh route cache, please invoke ClearRouteCache if needed.
	SetHost(host string)
	// SetPath set path in header map
	// This won't refresh route cache, please invoke ClearRouteCache if needed.
	SetPath(path string)
}

type RequestTrailerMap

type RequestTrailerMap interface {
	HeaderMap
}

type ResponseHeaderMap

type ResponseHeaderMap interface {
	HeaderMap
	Status() (int, bool)
}

type ResponseTrailerMap

type ResponseTrailerMap interface {
	HeaderMap
}

type StateType

type StateType int
const (
	StateTypeReadOnly StateType = 0
	StateTypeMutable  StateType = 1
)

type StatusType

type StatusType int

****************** filter status start ******************//

const (
	Running                StatusType = 0
	LocalReply             StatusType = 1
	Continue               StatusType = 2
	StopAndBuffer          StatusType = 3
	StopAndBufferWatermark StatusType = 4
	StopNoBuffer           StatusType = 5
)
const (
	HeaderContinue                     StatusType = 100
	HeaderStopIteration                StatusType = 101
	HeaderContinueAndDontEndStream     StatusType = 102
	HeaderStopAllIterationAndBuffer    StatusType = 103
	HeaderStopAllIterationAndWatermark StatusType = 104
)

header status refer https://github.com/envoyproxy/envoy/blob/main/envoy/http/filter.h

const (
	DataContinue                  StatusType = 200
	DataStopIterationAndBuffer    StatusType = 201
	DataStopIterationAndWatermark StatusType = 202
	DataStopIterationNoBuffer     StatusType = 203
)

data status refer https://github.com/envoyproxy/envoy/blob/main/envoy/http/filter.h

const (
	TrailerContinue      StatusType = 300
	TrailerStopIteration StatusType = 301
)

Trailer status refer https://github.com/envoyproxy/envoy/blob/main/envoy/http/filter.h

type StreamDecoderFilter

type StreamDecoderFilter interface {
	DecodeHeaders(RequestHeaderMap, bool) StatusType
	DecodeData(BufferInstance, bool) StatusType
	DecodeTrailers(RequestTrailerMap) StatusType
}

request

type StreamEncoderFilter

type StreamEncoderFilter interface {
	EncodeHeaders(ResponseHeaderMap, bool) StatusType
	EncodeData(BufferInstance, bool) StatusType
	EncodeTrailers(ResponseTrailerMap) StatusType
}

response

type StreamFilter

type StreamFilter interface {
	// http request
	StreamDecoderFilter
	// response stream
	StreamEncoderFilter

	// log
	OnLog()
	OnLogDownstreamStart()
	OnLogDownstreamPeriodic()

	// destroy filter
	OnDestroy(DestroyReason)
}

type StreamFilterCallbacks

type StreamFilterCallbacks interface {
	StreamInfo() StreamInfo
}

type StreamFilterConfigParser

type StreamFilterConfigParser interface {
	// Parse the proto message to any Go value, and return error to reject the config.
	// This is called when Envoy receives the config from the control plane.
	// Also, you can define Metrics through the callbacks, and the callbacks will be nil when parsing the route config.
	Parse(any *anypb.Any, callbacks ConfigCallbackHandler) (interface{}, error)
	// Merge the two configs(filter level config or route level config) into one.
	// May merge multi-level configurations, i.e. filter level, virtualhost level, router level and weighted cluster level,
	// into a single one recursively, by invoking this method multiple times.
	Merge(parentConfig interface{}, childConfig interface{}) interface{}
}

type StreamFilterFactory

type StreamFilterFactory func(config interface{}, callbacks FilterCallbackHandler) StreamFilter

type StreamInfo

type StreamInfo interface {
	GetRouteName() string
	FilterChainName() string
	// Protocol return the request's protocol.
	Protocol() (string, bool)
	// ResponseCode return the response code.
	ResponseCode() (uint32, bool)
	// ResponseCodeDetails return the response code details.
	ResponseCodeDetails() (string, bool)
	// AttemptCount return the number of times the request was attempted upstream.
	AttemptCount() uint32
	// Get the dynamic metadata of the request
	DynamicMetadata() DynamicMetadata
	// DownstreamLocalAddress return the downstream local address.
	DownstreamLocalAddress() string
	// DownstreamRemoteAddress return the downstream remote address.
	DownstreamRemoteAddress() string
	// UpstreamLocalAddress return the upstream local address.
	UpstreamLocalAddress() (string, bool)
	// UpstreamRemoteAddress return the upstream remote address.
	UpstreamRemoteAddress() (string, bool)
	// UpstreamClusterName return the upstream host cluster.
	UpstreamClusterName() (string, bool)
	// FilterState return the filter state interface.
	FilterState() FilterState
	// VirtualClusterName returns the name of the virtual cluster which got matched
	VirtualClusterName() (string, bool)
	// WorkerID returns the ID of the Envoy worker thread
	WorkerID() uint32
}

stream info refer https://github.com/envoyproxy/envoy/blob/main/envoy/stream_info/stream_info.h

type StreamSharing

type StreamSharing int
const (
	None                             StreamSharing = 0
	SharedWithUpstreamConnection     StreamSharing = 1
	SharedWithUpstreamConnectionOnce StreamSharing = 2
)

type UpstreamFilter

type UpstreamFilter interface {
	// Called when a connection is available to process a request/response.
	OnPoolReady(cb ConnectionCallback)
	// Called when a pool error occurred and no connection could be acquired for making the request.
	OnPoolFailure(poolFailureReason PoolFailureReason, transportFailureReason string)
	// Invoked when data is delivered from the upstream connection.
	OnData(buffer []byte, endOfStream bool)
	// Callback for connection events.
	OnEvent(event ConnectionEvent)
}

Jump to

Keyboard shortcuts

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