Documentation ¶
Index ¶
- Variables
- func NewBoltClient(config interface{}) types.MockClient
- func NewBoltServer(config interface{}) types.MockServer
- type BoltClientConfig
- type BoltConn
- type BoltServerConfig
- type Condition
- type ConnectionManager
- type MockBoltClient
- type MockBoltServer
- type RequestConfig
- type Response
- type ResponseBuilder
- type ResponseConfig
- type ResponseToWrite
- type VerifyConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrClosedConnection = errors.New("send request on closed connection") ErrRequestTimeout = errors.New("sync call timeout") )
View Source
var DefaultErrorBuilder = &ResponseBuilder{ StatusCode: int16(bolt.ResponseStatusError), }
View Source
var DefaultSucessBuilder = &ResponseBuilder{ StatusCode: int16(bolt.ResponseStatusSuccess), }
Functions ¶
func NewBoltClient ¶
func NewBoltClient(config interface{}) types.MockClient
func NewBoltServer ¶
func NewBoltServer(config interface{}) types.MockServer
TODO: make xprotocol server
Types ¶
type BoltClientConfig ¶
type BoltClientConfig struct { TargetAddr string `json:"target_address"` MaxConn uint32 `json:"max_connection"` Request *RequestConfig `json:"request_config"` Verify *VerifyConfig `json:"verify_config"` }
func NewBoltClientConfig ¶
func NewBoltClientConfig(config interface{}) (*BoltClientConfig, error)
type BoltConn ¶
type BoltConn struct {
// contains filtered or unexported fields
}
func (*BoltConn) AsyncSendRequest ¶
func (c *BoltConn) AsyncSendRequest(receiver *receiver, req *RequestConfig)
func (*BoltConn) OnEvent ¶
func (c *BoltConn) OnEvent(event api.ConnectionEvent)
func (*BoltConn) SyncSendRequest ¶
func (c *BoltConn) SyncSendRequest(req *RequestConfig) (*Response, error)
type BoltServerConfig ¶
type BoltServerConfig struct { Addr string `json:"address"` Mux map[string]*ResponseConfig `json:"mux_config"` }
func NewBoltServerConfig ¶
func NewBoltServerConfig(config interface{}) (*BoltServerConfig, error)
type Condition ¶
type Condition struct { // If a request contains the expected header, matched this condition. // A request must have the configured header key and value, and can have others headers // which will be ingored. ExpectedHeader map[string]string `json:"expected_header"` // If a request contains the unexpected header, matched failed. UnexpectedHeaderKey []string `json:"unexpected_header_key"` }
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
func (*ConnectionManager) Clean ¶
func (mgr *ConnectionManager) Clean()
func (*ConnectionManager) Delete ¶
func (mgr *ConnectionManager) Delete(id uint64)
type MockBoltClient ¶
type MockBoltClient struct {
// contains filtered or unexported fields
}
MockBoltClient use mosn xprotocol.bolt protocol and stream
func (*MockBoltClient) Close ¶
func (c *MockBoltClient) Close()
Close will close all the connections
func (*MockBoltClient) Stats ¶
func (c *MockBoltClient) Stats() types.ClientStatsReadOnly
func (*MockBoltClient) SyncCall ¶
func (c *MockBoltClient) SyncCall() bool
type MockBoltServer ¶
type MockBoltServer struct {
// contains filtered or unexported fields
}
func (*MockBoltServer) Start ¶
func (s *MockBoltServer) Start()
func (*MockBoltServer) Stats ¶
func (s *MockBoltServer) Stats() types.ServerStatsReadOnly
func (*MockBoltServer) Stop ¶
func (s *MockBoltServer) Stop()
type RequestConfig ¶
type RequestConfig struct { Header map[string]string `json:"header"` Body json.RawMessage `json:"body"` Timeout time.Duration `json:"timeout"` // request timeout }
RequestConfig decides what request to send
func (*RequestConfig) BuildRequest ¶
type Response ¶
func (*Response) GetResponseStatus ¶
type ResponseBuilder ¶
type ResponseBuilder struct { // The response status code StatusCode int16 `json:"status_code"` // The response header that not contains the protocol header part. Header map[string]string `json:"header"` // The repsonse body content Body json.RawMessage `json:"body"` }
ResponseBuilder builds a bolt response based on the bolt request
type ResponseConfig ¶
type ResponseConfig struct { Condition *Condition `json:"condition"` CommonBuilder *ResponseBuilder `json:"common_builder"` ErrorBuilder *ResponseBuilder `json:"error_buidler"` }
func (*ResponseConfig) HandleRequest ¶
func (c *ResponseConfig) HandleRequest(req *bolt.Request, engine api.XProtocol) (resp api.XRespFrame, status int16)
type ResponseToWrite ¶
type VerifyConfig ¶
type VerifyConfig struct { ExpectedStatusCode int16 // if ExepctedHeader is nil, means do not care about header // if ExepctedHeader is exists, means resposne header should contain all the ExpectedHeader // If response header contain keys not in ExpectedHeader, we ignore it. // TODO: support regex ExpectedHeader map[string]string // if ExpectedBody is nil, means do not care about body // TODO: support regex ExpectedBody []byte // if MaxExpectedRT is zero, means do not care about rt // if MaxExpectedRT is not zero, means response's rt should no more than it MaxExpectedRT time.Duration // if MinExpectedRT is zero means do not care about it // if MinExpectedRT is not zero, means response's rt should more than it MinExpectedRT time.Duration }
VerifyConfig describes what response want
func (*VerifyConfig) Verify ¶
func (c *VerifyConfig) Verify(resp *Response) bool
Click to show internal directories.
Click to hide internal directories.