api

package
v1.35.3 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: Apache-2.0 Imports: 4 Imported by: 36

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")
	ErrInvalidIPAddress     = errors.New("invalid IP address")
)

*************** 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 Config added in v1.34.0

type Config interface {
	// Called when the current config is deleted due to an update or removal of plugin.
	// You can use this method is you store some resources in the config to be released later.
	Destroy()
}

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)
	// EnableHalfClose only for upstream connection
	EnableHalfClose(enabled bool)
}

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 DecoderFilterCallbacks added in v1.31.0

type DecoderFilterCallbacks interface {
	FilterProcessCallbacks
	// Sets an upstream address override for the request. When the overridden host exists in the host list of the routed cluster
	// and can be selected directly, the load balancer bypasses its algorithm and routes traffic directly to the specified host.
	//
	// Here are some cases:
	// 1. Set a valid host(no matter in or not in the cluster), will route to the specified host directly and return 200.
	// 2. Set a non-IP host, C++ side will return error and not route to cluster.
	// 3. Set a unavaiable host, and the host is not in the cluster, will req the valid host in the cluster and rerurn 200.
	// 4. Set a unavaiable host, and the host is in the cluster, but not available(can not connect to the host), will req the unavaiable hoat and rerurn 503.
	// 5. Set a unavaiable host, and the host is in the cluster, but not available(can not connect to the host), and with retry. when first request with unavaiable host failed 503, the second request will retry with the valid host, then the second request will succeed and finally return 200.
	// 6. Set a unavaiable host with strict mode, and the host is in the cluster, will req the unavaiable host and rerurn 503.
	// 7. Set a unavaiable host with strict mode, and the host is not in the cluster, will req the unavaiable host and rerurn 503.
	// 8. Set a unavaiable host with strict mode and retry. when first request with unavaiable host failed 503, the second request will retry with the valid host, then the second request will succeed and finally return 200.
	// 9. Set a unavaiable host with strict mode and retry, and the host is not in the cluster, will req the unavaiable host and rerurn 503.
	//
	// The function takes two arguments:
	//
	// host (string): The upstream host address to use for the request. This must be a valid IP address(with port); otherwise, the
	// C++ side will throw an error.
	//
	// strict (boolean): Determines whether the HTTP request must be strictly routed to the requested
	// host. When set to “true“, if the requested host is invalid, Envoy will return a 503 status code.
	// The default value is “false“, which allows Envoy to fall back to its load balancing mechanism. In this case, if the
	// requested host is invalid, the request will be routed according to the load balancing algorithm and choose other hosts.
	SetUpstreamOverrideHost(host string, strict bool) 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 EncoderFilterCallbacks added in v1.31.0

type EncoderFilterCallbacks interface {
	FilterProcessCallbacks
}

type EndStreamType added in v1.34.0

type EndStreamType int
const (
	NotEndStream EndStreamType = 0
	EndStream    EndStreamType = 1
)

func (EndStreamType) String added in v1.34.0

func (t EndStreamType) String() string

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 {
	StreamFilterCallbacks
	// DecoderFilterCallbacks could only be used in DecodeXXX phases.
	DecoderFilterCallbacks() DecoderFilterCallbacks
	// EncoderFilterCallbacks could only be used in EncodeXXX phases.
	EncoderFilterCallbacks() EncoderFilterCallbacks
}

type FilterProcessCallbacks added in v1.31.0

type FilterProcessCallbacks interface {
	// 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()
	// AddData add extra data when processing headers/trailers.
	// For example, turn a headers only request into a request with a body, add more body when processing trailers, and so on.
	// The second argument isStreaming supplies if this caller streams data or buffers the full body.
	AddData(data []byte, isStreaming bool)
	// InjectData inject the content of slice data via Envoy StreamXXFilterCallbacks's injectXXDataToFilterChaininjectData.
	InjectData(data []byte)
}

FilterProcessCallbacks is the interface for filter to process request/response in decode/encode phase.

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)

	// GetAllHeaders returns all the headers.
	GetAllHeaders() map[string][]string
}

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 {
	/* These APIs are related to the decode/encode phase, use the pointer of processState. */
	HttpContinue(s unsafe.Pointer, status uint64)
	HttpSendLocalReply(s unsafe.Pointer, responseCode int, bodyText string, headers map[string][]string, grpcStatus int64, details string)
	HttpAddData(s unsafe.Pointer, data []byte, isStreaming bool)
	HttpInjectData(s unsafe.Pointer, data []byte)

	// 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(s unsafe.Pointer, details string)
	// experience api, memory unsafe
	HttpGetHeader(s unsafe.Pointer, key string) string
	HttpCopyHeaders(s unsafe.Pointer, num uint64, bytes uint64) map[string][]string
	HttpSetHeader(s unsafe.Pointer, key string, value string, add bool)
	HttpRemoveHeader(s unsafe.Pointer, key string)

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

	HttpCopyTrailers(s unsafe.Pointer, num uint64, bytes uint64) map[string][]string
	HttpSetTrailer(s unsafe.Pointer, key string, value string, add bool)
	HttpRemoveTrailer(s unsafe.Pointer, key string)
	HttpSetUpstreamOverrideHost(s unsafe.Pointer, host string, strict bool) error

	/* These APIs have nothing to do with the decode/encode phase, use the pointer of httpRequest. */
	ClearRouteCache(r unsafe.Pointer, refresh bool)

	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{})

	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)

	HttpFinalize(r unsafe.Pointer, reason int)
	HttpGetStringSecret(c unsafe.Pointer, key string) (string, bool)

	/* These APIs are related to config, use the pointer of config. */
	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)
	HttpConfigFinalize(c unsafe.Pointer)

	/* These APIs have nothing to do with request */
	HttpLog(level LogType, message string)
	HttpLogLevel() LogType
}

type HttpTcpBridge added in v1.34.0

type HttpTcpBridge interface {

	// Invoked when header is delivered from the downstream.
	// Notice-1: when return HttpTcpBridgeContinue or HttpTcpBridgeStopAndBuffer, dataForSet is used to be sent to upstream; when return HttpTcpBridgeEndStream, dataForSet is useed to sent to downstream as response body.
	// Notice-2: headerMap and dataToUpstream cannot be invoked after the func return.
	EncodeHeaders(headerMap RequestHeaderMap, dataForSet BufferInstance, endOfStream bool) HttpTcpBridgeStatus

	// Streaming, Invoked when data is delivered from the downstream.
	// Notice: buffer cannot be invoked after the func return.
	EncodeData(buffer BufferInstance, endOfStream bool) HttpTcpBridgeStatus

	// Streaming, Called when data is read on from tcp upstream.
	// Notice-1: when return HttpTcpBridgeContinue, resp headers will be send to http all at once; from then on, you MUST NOT invoke responseHeaderForSet at any time(or you will get panic).
	// Notice-2: responseHeaderForSet and buffer cannot be invoked after the func return.
	OnUpstreamData(responseHeaderForSet ResponseHeaderMap, buffer BufferInstance, endOfStream bool) HttpTcpBridgeStatus

	// destroy filter
	OnDestroy()
}

type HttpTcpBridgeCallbackHandler added in v1.34.0

type HttpTcpBridgeCallbackHandler interface {
	// GetRouteName returns the name of the route which got matched
	GetRouteName() string
	// GetVirtualClusterName returns the name of the virtual cluster which got matched
	GetVirtualClusterName() string
	// SetSelfHalfCloseForUpstreamConn default is false
	SetSelfHalfCloseForUpstreamConn(enabled bool)
}

type HttpTcpBridgeConfigParser added in v1.34.0

type HttpTcpBridgeConfigParser interface {
	Parse(any *anypb.Any) (interface{}, error)
}

type HttpTcpBridgeFactory added in v1.34.0

type HttpTcpBridgeFactory func(config interface{}, callbacks HttpTcpBridgeCallbackHandler) HttpTcpBridge

type HttpTcpBridgeInfoType added in v1.34.0

type HttpTcpBridgeInfoType int

Info types called by http-tcp bridge that can get the corresponding info from c++ side.

const (
	HttpTcpBridgeInfoRouterName  HttpTcpBridgeInfoType = 0
	HttpTcpBridgeInfoClusterName HttpTcpBridgeInfoType = 1
)

func (HttpTcpBridgeInfoType) String added in v1.34.0

func (t HttpTcpBridgeInfoType) String() string

type HttpTcpBridgeStatus added in v1.34.0

type HttpTcpBridgeStatus int

Status codes returned by tcp upstream extension.

const (
	/**
	 *
	 * Used when you want to leave the current func area and continue further func. (when streaming,
	 * go side get each_data_piece, may be called multipled times)
	 *
	 * Here is the specific explanation in different funcs:
	 *
	 * encodeHeaders: will go to encodeData, go side in encodeData will streaming get each_data_piece.
	 *
	 * encodeData: streaming send data to upstream, go side get each_data_piece, may be called
	 * multipled times.
	 *
	 * onUpstreamData: go side in onUpstreamData will get each_data_piece, pass data
	 * and headers to downstream streaming.
	 */
	HttpTcpBridgeContinue HttpTcpBridgeStatus = 0

	/**
	*
	* Used when you want to buffer data.
	*
	* Here is the specific explanation in different funcs:
	*
	* encodeHeaders: will go to encodeData, encodeData will buffer whole data, go side in encodeData
	* get whole data one-off.
	*
	* encodeData: buffer further whole data, go side in encodeData get whole
	* data one-off. (Be careful: cannot be used when end_stream=true)
	*
	* onUpstreamData: every data
	* trigger will call go side, and go side get whloe buffered data ever since at every time.
	 */
	HttpTcpBridgeStopAndBuffer HttpTcpBridgeStatus = 1

	/**
	*
	* Used when you want to endStream for sending resp to downstream.
	*
	* Here is the specific explanation in different funcs:
	*
	* encodeHeaders, encodeData: endStream to upstream&downstream and send data to
	* downstream(if not blank), which means the whole resp to http has finished.
	*
	* onUpstreamData: endStream to downstream which means the whole resp to http has finished.
	 */
	HttpTcpBridgeEndStream HttpTcpBridgeStatus = 2
)

func (HttpTcpBridgeStatus) String added in v1.34.0

func (s HttpTcpBridgeStatus) String() string

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
	// UpstreamConnEnableHalfClose upstream conn EnableHalfClose
	UpstreamConnEnableHalfClose(f unsafe.Pointer, enableHalfClose int)
	// 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 PassThroughHttpTcpBridge added in v1.34.0

type PassThroughHttpTcpBridge struct{}

PassThroughHttpTcpBridge provides the no-op implementation of the HttpTcpBridge interface

func (*PassThroughHttpTcpBridge) EncodeData added in v1.34.0

func (*PassThroughHttpTcpBridge) EncodeData(buffer BufferInstance, endOfStream bool) HttpTcpBridgeStatus

func (*PassThroughHttpTcpBridge) EncodeHeaders added in v1.34.0

func (*PassThroughHttpTcpBridge) EncodeHeaders(headerMap RequestHeaderMap, dataForSet BufferInstance, endOfStream bool) HttpTcpBridgeStatus

func (*PassThroughHttpTcpBridge) OnDestroy added in v1.34.0

func (*PassThroughHttpTcpBridge) OnDestroy()

func (*PassThroughHttpTcpBridge) OnUpstreamData added in v1.34.0

func (*PassThroughHttpTcpBridge) OnUpstreamData(responseHeaderForSet ResponseHeaderMap, buffer BufferInstance, endOfStream bool) HttpTcpBridgeStatus

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) OnLogDownstreamPeriodic added in v1.28.0

func (*PassThroughStreamFilter) OnLogDownstreamStart added in v1.28.0

func (*PassThroughStreamFilter) OnLogDownstreamStart(RequestHeaderMap)

func (*PassThroughStreamFilter) OnStreamComplete added in v1.32.0

func (*PassThroughStreamFilter) OnStreamComplete()

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 SecretManager added in v1.34.0

type SecretManager interface {
	// Get generic secret from secret manager.
	// bool is false on missing secret
	GetGenericSecret(name string) (string, bool)
}

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(RequestHeaderMap, RequestTrailerMap, ResponseHeaderMap, ResponseTrailerMap)
	OnLogDownstreamStart(RequestHeaderMap)
	OnLogDownstreamPeriodic(RequestHeaderMap, RequestTrailerMap, ResponseHeaderMap, ResponseTrailerMap)

	// destroy filter
	OnDestroy(DestroyReason)
	OnStreamComplete()
}

type StreamFilterCallbacks

type StreamFilterCallbacks interface {
	StreamInfo() StreamInfo

	// 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()
	// RefreshRouteCache works like ClearRouteCache, but it will re-fetch the route immediately.
	RefreshRouteCache()
	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)

	// Get secret manager.
	// Secrets should be defined in the plugin configuration.
	// It is safe to use this secret manager from any goroutine.
	SecretManager() SecretManager
}

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.
	// You can return a config implementing the Config interface if you need fine control over its lifecycle.
	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.
	// You can return a config implementing the Config interface if you need fine control over its lifecycle.
	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 TcpUpstreamCAPI added in v1.34.0

type TcpUpstreamCAPI interface {
	// Header related
	CopyHeaders(s unsafe.Pointer, num uint64, bytes uint64) map[string][]string
	SetRespHeader(s unsafe.Pointer, key string, value string, add bool)
	RemoveRespHeader(s unsafe.Pointer, key string)
	// Buffer related
	GetBuffer(s unsafe.Pointer, bufferPtr uint64, length uint64) []byte
	DrainBuffer(s unsafe.Pointer, bufferPtr uint64, length uint64)
	SetBufferHelper(s unsafe.Pointer, bufferPtr uint64, value string, action BufferAction)
	SetBytesBufferHelper(s unsafe.Pointer, bufferPtr uint64, value []byte, action BufferAction)
	// Get the specified value by key
	GetStringValue(r unsafe.Pointer, id int) (string, bool)

	SetSelfHalfCloseForUpstreamConn(r unsafe.Pointer, enabled int)
}

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