Documentation ¶
Index ¶
- Variables
- func BuildBoltV1Request(id uint64, header map[string]string, body []byte) (types.HeaderMap, types.IoBuffer)
- type BoltV1ReponseConfig
- type BoltV1ResponseBuilder
- type BoltV1Serve
- type Client
- type ClientConfig
- type ClientStats
- type ConnClient
- type MakeRequestFunc
- type MockServer
- type Response
- type ResponseVerify
- type ServeFunc
- type ServerStats
- func (s *ServerStats) ActiveConnection()
- func (s *ServerStats) CloseConnection()
- func (s *ServerStats) ConnectionStats() (uint32, uint32, uint32)
- func (s *ServerStats) Request()
- func (s *ServerStats) RequestStats() uint32
- func (s *ServerStats) Response(status int16)
- func (s *ServerStats) ResponseStats() map[int16]uint32
- type VerifyConfig
- type WriteResponseData
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultBoltV1Serve = &BoltV1Serve{ Configs: []*BoltV1ReponseConfig{ { Builder: DefaultBuilder, }, }, }
View Source
var DefaultBuilder = &BoltV1ResponseBuilder{ Status: int16(bolt.ResponseStatusSuccess), Header: map[string]string{ "mosn-test-default": "boltv1", }, Content: buffer.NewIoBufferString("default-boltv1"), }
View Source
var DefaultVeirfy = &VerifyConfig{ ExpectedStatus: bolt.ResponseStatusSuccess, }
View Source
var ErrorBuilder = &BoltV1ResponseBuilder{ Status: int16(bolt.ResponseStatusError), Header: map[string]string{ "error-message": "no matched config", }, }
Functions ¶
Types ¶
type BoltV1ReponseConfig ¶
type BoltV1ReponseConfig struct { ExpectedHeader map[string]string UnexpectedHeaderKey []string Builder *BoltV1ResponseBuilder }
TODO: Support More
type BoltV1ResponseBuilder ¶
type BoltV1Serve ¶
type BoltV1Serve struct {
Configs []*BoltV1ReponseConfig
}
func (*BoltV1Serve) MakeResponse ¶
func (s *BoltV1Serve) MakeResponse(req *bolt.Request) *bolt.Response
func (*BoltV1Serve) Serve ¶
func (s *BoltV1Serve) Serve(reqdata types.IoBuffer) *WriteResponseData
type Client ¶
type Client struct { Cfg *ClientConfig // Stats Stats *ClientStats // contains filtered or unexported fields }
func NewClient ¶
func NewClient(cfg *ClientConfig, maxConnections uint32) *Client
type ClientConfig ¶
type ClientConfig struct { Addr string MakeRequest MakeRequestFunc RequestHeader map[string]string RequestBody []byte // request timeout is used for sync call // if zero, we set default request time, 5 second RequestTImeout time.Duration // if Verify is nil, just expected returns success Verify ResponseVerify }
func CreateSimpleConfig ¶
func CreateSimpleConfig(addr string) *ClientConfig
type ClientStats ¶
type ClientStats struct { *ServerStats // contains filtered or unexported fields }
func NewClientStats ¶
func NewClientStats() *ClientStats
func (*ClientStats) ExpectedResponse ¶
func (c *ClientStats) ExpectedResponse() (uint32, uint32)
func (*ClientStats) Response ¶
func (c *ClientStats) Response(expected bool)
type ConnClient ¶
type ConnClient struct { MakeRequest MakeRequestFunc SyncTimeout time.Duration // contains filtered or unexported fields }
func NewConnClient ¶
func NewConnClient(addr string, f MakeRequestFunc) (*ConnClient, error)
func (*ConnClient) Close ¶
func (c *ConnClient) Close()
func (*ConnClient) IsClosed ¶
func (c *ConnClient) IsClosed() bool
func (*ConnClient) OnEvent ¶
func (c *ConnClient) OnEvent(event api.ConnectionEvent)
type MakeRequestFunc ¶
type MockServer ¶
type MockServer struct { Addr string ServeFunc ServeFunc // stats ServerStats *ServerStats // contains filtered or unexported fields }
func NewMockServer ¶
func NewMockServer(addr string, f ServeFunc) *MockServer
func (*MockServer) Close ¶
func (srv *MockServer) Close()
func (*MockServer) SetConnectionIdleTimeout ¶
func (srv *MockServer) SetConnectionIdleTimeout(d time.Duration)
func (*MockServer) SetResponseDelay ¶
func (srv *MockServer) SetResponseDelay(d time.Duration)
func (*MockServer) Start ¶
func (srv *MockServer) Start()
type ResponseVerify ¶
type ServerStats ¶
type ServerStats struct {
// contains filtered or unexported fields
}
func NewServerStats ¶
func NewServerStats() *ServerStats
func (*ServerStats) ActiveConnection ¶
func (s *ServerStats) ActiveConnection()
func (*ServerStats) CloseConnection ¶
func (s *ServerStats) CloseConnection()
func (*ServerStats) ConnectionStats ¶
func (s *ServerStats) ConnectionStats() (uint32, uint32, uint32)
func (*ServerStats) Request ¶
func (s *ServerStats) Request()
func (*ServerStats) RequestStats ¶
func (s *ServerStats) RequestStats() uint32
func (*ServerStats) Response ¶
func (s *ServerStats) Response(status int16)
func (*ServerStats) ResponseStats ¶
func (s *ServerStats) ResponseStats() map[int16]uint32
type VerifyConfig ¶
type VerifyConfig struct { ExpectedStatus uint16 // if ExepctedHeader is nil, means do not care about header // if ExepctedHeader is exists, means resposne Header should contain all the ExpectedHeader // TODO : support regex ExpectedHeader map[string]string // if ExpectedBody is nil, means do not care about body // TODO: support regex ExpectedBody []byte // if ExpectedRT is zero, means do not care about rt // if ExpectedRT is not zero, means response's rt should no more than it ExpectedRT time.Duration // if MinRT is zero means do not care about it // if MinRT is not zero, means response's rt should more than it MinRT time.Duration }
func (*VerifyConfig) Verify ¶
func (cfg *VerifyConfig) Verify(resp *Response) bool
type WriteResponseData ¶
Click to show internal directories.
Click to hide internal directories.