Documentation ¶
Index ¶
- Constants
- type BufferAction
- type BufferInstance
- type DataBufferBase
- type DestroyReason
- type EnvoyRequestPhase
- type FilterCallbackHandler
- type FilterCallbacks
- type HeaderMap
- type HttpCAPI
- type LogType
- type MetadataMap
- type RequestHeaderMap
- type RequestTrailerMap
- type ResponseHeaderMap
- type ResponseTrailerMap
- type StatusType
- type StreamDecoderFilter
- type StreamEncoderFilter
- type StreamFilter
- type StreamFilterCallbacks
- type StreamFilterConfigFactory
- type StreamFilterConfigParser
- type StreamFilterFactory
- type StreamInfo
Constants ¶
View Source
const ( NormalFinalize int = 0 // normal, finalize on destroy GCFinalize int = 1 // finalize in GC sweep )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 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 // Peek returns n bytes from buffer, without draining any buffered data. // If n > readable buffer, nil will be returned. // It can be used in codec to check first-n-bytes magic bytes // Note: do not change content in return bytes, use write instead Peek(n int) []byte // 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 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 // 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 writes message to the http logger during request processes. // we are also consider adding global api MiscLog to write the misc logger // during non-request processes in the future. Log(level LogType, msg string) }
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. 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. 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. 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) // ByteSize return size of HeaderMap ByteSize() uint64 }
refer https://github.com/envoyproxy/envoy/blob/main/envoy/http/header_map.h
type HttpCAPI ¶
type HttpCAPI interface { HttpContinue(r unsafe.Pointer, status uint64) HttpSendLocalReply(r unsafe.Pointer, responseCode int, bodyText string, headers map[string]string, grpcStatus int64, details string) // experience api, memory unsafe HttpGetHeader(r unsafe.Pointer, key *string, value *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, value *string, length uint64) HttpSetBufferHelper(r unsafe.Pointer, bufferPtr uint64, value string, action BufferAction) HttpCopyTrailers(r unsafe.Pointer, num uint64, bytes uint64) map[string][]string HttpSetTrailer(r unsafe.Pointer, key *string, value *string) HttpGetStringValue(r unsafe.Pointer, id int) (string, bool) HttpGetIntegerValue(r unsafe.Pointer, id int) (uint64, bool) // HttpLog writes message to the registered logger during request processes. // we are also consider adding MiscLog to write the misc logger during non-request // processes in the future. HttpLog(r unsafe.Pointer, level LogType, message string) HttpFinalize(r unsafe.Pointer, reason int) }
type MetadataMap ¶
type MetadataMap interface { }
type RequestHeaderMap ¶
type RequestTrailerMap ¶
type RequestTrailerMap interface { HeaderMap }
type ResponseHeaderMap ¶
type ResponseTrailerMap ¶
type ResponseTrailerMap interface { HeaderMap }
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 // destroy filter OnDestroy(DestroyReason) }
type StreamFilterCallbacks ¶
type StreamFilterCallbacks interface {
StreamInfo() StreamInfo
}
type StreamFilterConfigFactory ¶
type StreamFilterConfigFactory func(config interface{}) StreamFilterFactory
type StreamFilterConfigParser ¶
type StreamFilterConfigParser interface { Parse(any *anypb.Any) interface{} Merge(parentConfig interface{}, childConfig interface{}) interface{} }
TODO merge it to StreamFilterConfigFactory
type StreamFilterFactory ¶
type StreamFilterFactory func(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 }
stream info refer https://github.com/envoyproxy/envoy/blob/main/envoy/stream_info/stream_info.h
Click to show internal directories.
Click to hide internal directories.