Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateID() uint64
- func GenerateIDString() string
- func GetNewPoolFactory(protocol api.ProtocolName) (types.NewConnPool, bool)
- func GetProtocolStreamFactory(name api.ProtocolName) (types.ProtocolStreamFactory, bool)
- func HandleConfig(prot api.ProtocolName, v interface{}) interface{}
- func MappingHeaderStatusCode(ctx context.Context, p api.ProtocolName, headers api.HeaderMap) (int, error)
- func ProtocolRegistered(name api.ProtocolName) bool
- func RangeAllRegisteredProtocol(f func(name api.ProtocolName))
- func RegisterProtocol(name api.ProtocolName, newPool types.NewConnPool, ...) error
- func RegisterProtocolConfigHandler(prot api.ProtocolName, h ProtocolConfigHandler)
- func RequestIDConv(streamID string) uint64
- func SelectStreamFactoryProtocol(ctx context.Context, prot string, peek []byte, scopes []api.ProtocolName) (api.ProtocolName, error)
- func StreamIDConv(streamID uint64) string
- type CommonHeader
- func (h CommonHeader) Add(key string, value string)
- func (h CommonHeader) ByteSize() uint64
- func (h CommonHeader) Clone() api.HeaderMap
- func (h CommonHeader) Del(key string)
- func (h CommonHeader) Get(key string) (value string, ok bool)
- func (h CommonHeader) Range(f func(key, value string) bool)
- func (h CommonHeader) Set(key string, value string)
- type GetStatusCodeMapping
- type IDGenerator
- type ProtocolConfigHandler
Constants ¶
const ( Auto api.ProtocolName = "Auto" HTTP1 api.ProtocolName = "Http1" // TODO: move it to protocol/HTTP HTTP2 api.ProtocolName = "Http2" // TODO: move it to protocol/HTTP2 )
ProtocolName type definition
const ( Request = "Request" Response = "Response" )
header direction definition
Variables ¶
var ( ErrNoMapping = errors.New("no mapping function found") ErrInvalidParameters = errors.New("new connection pool or protocol stream factory cannot be nil") ErrDuplicateProtocol = errors.New("duplicated protocol registered") )
The api for get the registered info
var ( FAILED = errors.New("FAILED") EAGAIN = errors.New("AGAIN") )
var ErrNoStatusCode = errors.New("headers have no status code")
Functions ¶
func GenerateIDString ¶
func GenerateIDString() string
GenerateIDString get id string by default global generator
func GetNewPoolFactory ¶ added in v0.26.0
func GetNewPoolFactory(protocol api.ProtocolName) (types.NewConnPool, bool)
func GetProtocolStreamFactory ¶ added in v0.26.0
func GetProtocolStreamFactory(name api.ProtocolName) (types.ProtocolStreamFactory, bool)
func HandleConfig ¶ added in v0.23.0
func HandleConfig(prot api.ProtocolName, v interface{}) interface{}
func MappingHeaderStatusCode ¶
func ProtocolRegistered ¶ added in v0.26.0
func ProtocolRegistered(name api.ProtocolName) bool
func RangeAllRegisteredProtocol ¶ added in v0.26.0
func RangeAllRegisteredProtocol(f func(name api.ProtocolName))
func RegisterProtocol ¶ added in v0.26.0
func RegisterProtocol(name api.ProtocolName, newPool types.NewConnPool, streamFactory types.ProtocolStreamFactory, mapping api.HTTPMapping) error
A MOSN Protocol contains three parts: 1. A Factory to create connection pool defined by types.ConnectionPool 2. An interface to match protocol and create protocol stream for each request. 3. A status code mapping handler to translate protocol status code to HTTP status code, which is used as standard status code in MOSN.
func RegisterProtocolConfigHandler ¶ added in v0.23.0
func RegisterProtocolConfigHandler(prot api.ProtocolName, h ProtocolConfigHandler)
func RequestIDConv ¶
RequestIDConv convert streamID from string to uint64
func SelectStreamFactoryProtocol ¶ added in v0.26.0
func SelectStreamFactoryProtocol(ctx context.Context, prot string, peek []byte, scopes []api.ProtocolName) (api.ProtocolName, error)
SelectStreamFactoryProtocol match the protocol. if scopes is nil, match all the registered protocols if scopes is not nil, match the protocol in the scopes
func StreamIDConv ¶
StreamIDConv convert streamID from uint64 to string
Types ¶
type CommonHeader ¶
TODO: use pkg.CommonHeader, why not? CommonHeader wrapper for map[string]string
func (CommonHeader) Add ¶
func (h CommonHeader) Add(key string, 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.
func (CommonHeader) ByteSize ¶
func (h CommonHeader) ByteSize() uint64
func (CommonHeader) Clone ¶
func (h CommonHeader) Clone() api.HeaderMap
Clone used to deep copy header's map
func (CommonHeader) Get ¶
func (h CommonHeader) Get(key string) (value string, ok bool)
Get value of key
func (CommonHeader) Range ¶
func (h CommonHeader) Range(f func(key, value string) bool)
Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.
func (CommonHeader) Set ¶
func (h CommonHeader) Set(key string, value string)
Set key-value pair in header map, the previous pair will be replaced if exists
type GetStatusCodeMapping ¶ added in v0.26.0
type GetStatusCodeMapping struct{}
GetStatusCodeMapping is a default http mapping implementation, which get status code from variable without any translation.
func (GetStatusCodeMapping) MappingHeaderStatusCode ¶ added in v0.26.0
type IDGenerator ¶
type IDGenerator struct {
// contains filtered or unexported fields
}
IDGenerator utility to generate auto-increment ids
func (*IDGenerator) GetString ¶
func (g *IDGenerator) GetString() string
Get get id in string format
type ProtocolConfigHandler ¶ added in v0.23.0
type ProtocolConfigHandler func(v interface{}) interface{}
ProtocolConfigHandler translate general config into protocol configs