Documentation ¶
Index ¶
- Constants
- func AddPendingResponse(pr *PendingResponse)
- func RegistryCodec(protocol string, codecTmp Codec)
- func SequenceID() int64
- type AsyncCallbackResponse
- type Client
- type Codec
- type DataListener
- type DecodeResult
- type Event
- type EventType
- type ExchangeClient
- func (client *ExchangeClient) AsyncRequest(invocation *protocol.Invocation, url *common.URL, timeout time.Duration, ...) error
- func (client *ExchangeClient) Close()
- func (client *ExchangeClient) DecreaseActiveNumber() uint32
- func (client *ExchangeClient) GetActiveNumber() uint32
- func (client *ExchangeClient) IncreaseActiveNumber() uint32
- func (client *ExchangeClient) IsAvailable() bool
- func (client *ExchangeClient) Request(invocation *protocol.Invocation, url *common.URL, timeout time.Duration, ...) error
- func (client *ExchangeClient) Send(invocation *protocol.Invocation, url *common.URL, timeout time.Duration) error
- type ExchangeServer
- type Options
- type PendingResponse
- type Request
- type Response
- type SequenceType
- type Server
Constants ¶
const ( // EventTypeAdd means add event EventTypeAdd = iota // EventTypeDel means del event EventTypeDel // EventTypeUpdate means update event EventTypeUpdate )
Variables ¶
This section is empty.
Functions ¶
func RegistryCodec ¶
func SequenceID ¶
func SequenceID() int64
Types ¶
type AsyncCallbackResponse ¶
type AsyncCallbackResponse struct { common.CallbackResponse Opts Options Cause error Start time.Time // invoke(call) start time == write start time ReadStart time.Time // read start time, write duration = ReadStart - Start Reply interface{} }
AsyncCallbackResponse async response for dubbo
type Client ¶
type Client interface { SetExchangeClient(client *ExchangeClient) // connect url Connect(url *common.URL) error // close Close() // send request to server. Request(request *Request, timeout time.Duration, response *PendingResponse) error // check if the client is still available IsAvailable() bool }
It is interface of client for network communication. If you use getty as network communication, you should define GettyClient that implements this interface.
type Codec ¶
type Codec interface { EncodeRequest(request *Request) (*bytes.Buffer, error) EncodeResponse(response *Response) (*bytes.Buffer, error) Decode(data []byte) (DecodeResult, int, error) }
codec for exchangeClient
type DataListener ¶
type DataListener interface {
DataChange(event Event) bool // bool is return for interface implement is interesting
}
DataListener defines common data listener interface
type DecodeResult ¶
type DecodeResult struct { // IsRequest indicates whether the current request is a heartbeat request IsRequest bool Result interface{} }
type ExchangeClient ¶
type ExchangeClient struct { // connect server timeout ConnectTimeout time.Duration // contains filtered or unexported fields }
This is abstraction level. it is like facade.
func NewExchangeClient ¶
func NewExchangeClient(url *common.URL, client Client, connectTimeout time.Duration, lazyInit bool) *ExchangeClient
create ExchangeClient
func (*ExchangeClient) AsyncRequest ¶
func (client *ExchangeClient) AsyncRequest(invocation *protocol.Invocation, url *common.URL, timeout time.Duration, callback common.AsyncCallback, result *protocol.RPCResult) error
async two way request
func (*ExchangeClient) DecreaseActiveNumber ¶
func (client *ExchangeClient) DecreaseActiveNumber() uint32
decrease number of service using client
func (*ExchangeClient) GetActiveNumber ¶
func (client *ExchangeClient) GetActiveNumber() uint32
get number of service using client
func (*ExchangeClient) IncreaseActiveNumber ¶
func (client *ExchangeClient) IncreaseActiveNumber() uint32
increase number of service using client
func (*ExchangeClient) IsAvailable ¶
func (client *ExchangeClient) IsAvailable() bool
IsAvailable to check if the underlying network client is available yet.
func (*ExchangeClient) Request ¶
func (client *ExchangeClient) Request(invocation *protocol.Invocation, url *common.URL, timeout time.Duration, result *protocol.RPCResult) error
two way request
func (*ExchangeClient) Send ¶
func (client *ExchangeClient) Send(invocation *protocol.Invocation, url *common.URL, timeout time.Duration) error
oneway request
type ExchangeServer ¶
This is abstraction level. it is like facade.
func NewExchangeServer ¶
func NewExchangeServer(url *common.URL, server Server) *ExchangeServer
Create ExchangeServer
type PendingResponse ¶
type PendingResponse struct { Err error ReadStart time.Time Callback common.AsyncCallback Reply interface{} Done chan struct{} // contains filtered or unexported fields }
the client sends request to server, there is one pendingResponse at client side to wait the response from server
func NewPendingResponse ¶
func NewPendingResponse(id int64) *PendingResponse
NewPendingResponse aims to create PendingResponse. ID is always from ID of Request
func (PendingResponse) GetCallResponse ¶
func (r PendingResponse) GetCallResponse() common.CallbackResponse
GetCallResponse is used for callback of async. It is will return AsyncCallbackResponse.
func (*PendingResponse) SetResponse ¶
func (r *PendingResponse) SetResponse(response *Response)
type Request ¶
type Request struct { ID int64 // protocol version Version string // serial ID (ignore) SerialID byte // Data Data interface{} TwoWay bool Event bool }
this is request for transport layer
func NewRequest ¶
NewRequest aims to create Request. The ID is auto increase.
type Response ¶
type Response struct { ID int64 Version string SerialID byte Status uint8 Event bool Error error Result interface{} }
this is response for transport layer
func NewResponse ¶
NewResponse create to a new Response.
func (*Response) IsHeartbeat ¶
the response is heartbeat
type SequenceType ¶
type SequenceType int64