Documentation ¶
Overview ¶
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
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 AddPendingResponse ¶ added in v1.5.3
func AddPendingResponse(pr *PendingResponse)
store response into map
func RegistryCodec ¶ added in v1.5.3
func SequenceId ¶ added in v1.5.3
func SequenceId() int64
Types ¶
type AsyncCallbackResponse ¶ added in v1.5.3
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 ¶ added in v1.5.3
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 ¶ added in v1.5.3
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(eventType Event) bool //bool is return for interface implement is interesting
}
DataListener defines common data listener interface
type DecodeResult ¶ added in v1.5.3
type DecodeResult struct { IsRequest bool Result interface{} }
type ExchangeClient ¶ added in v1.5.3
type ExchangeClient struct { // connect server timeout ConnectTimeout time.Duration // contains filtered or unexported fields }
This is abstraction level. it is like facade.
func NewExchangeClient ¶ added in v1.5.3
func NewExchangeClient(url *common.URL, client Client, connectTimeout time.Duration, lazyInit bool) *ExchangeClient
create ExchangeClient
func (*ExchangeClient) AsyncRequest ¶ added in v1.5.3
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 ¶ added in v1.5.6
func (client *ExchangeClient) DecreaseActiveNumber() uint32
decrease number of service using client
func (*ExchangeClient) GetActiveNumber ¶ added in v1.5.6
func (client *ExchangeClient) GetActiveNumber() uint32
get number of service using client
func (*ExchangeClient) IncreaseActiveNumber ¶ added in v1.5.6
func (client *ExchangeClient) IncreaseActiveNumber() uint32
increase number of service using client
func (*ExchangeClient) IsAvailable ¶ added in v1.5.5
func (client *ExchangeClient) IsAvailable() bool
IsAvailable to check if the underlying network client is available yet.
func (*ExchangeClient) Request ¶ added in v1.5.3
func (client *ExchangeClient) Request(invocation *protocol.Invocation, url *common.URL, timeout time.Duration, result *protocol.RPCResult) error
two way request
func (*ExchangeClient) Send ¶ added in v1.5.3
func (client *ExchangeClient) Send(invocation *protocol.Invocation, url *common.URL, timeout time.Duration) error
oneway request
type ExchangeServer ¶ added in v1.5.3
This is abstraction level. it is like facade.
func NewExchangeServer ¶ added in v1.5.3
func NewExchangeServer(url *common.URL, server Server) *ExchangeServer
Create ExchangeServer
type PendingResponse ¶ added in v1.5.3
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 GetPendingResponse ¶ added in v1.5.3
func GetPendingResponse(seq SequenceType) *PendingResponse
get response
func NewPendingResponse ¶ added in v1.5.3
func NewPendingResponse(id int64) *PendingResponse
NewPendingResponse aims to create PendingResponse. Id is always from ID of Request
func (PendingResponse) GetCallResponse ¶ added in v1.5.3
func (r PendingResponse) GetCallResponse() common.CallbackResponse
GetCallResponse is used for callback of async. It is will return AsyncCallbackResponse.
func (*PendingResponse) SetResponse ¶ added in v1.5.3
func (r *PendingResponse) SetResponse(response *Response)
type Request ¶ added in v1.5.3
type Request struct { ID int64 // protocol version Version string // serial ID (ignore) SerialID byte // Data Data interface{} TwoWay bool Event bool Payload int }
this is request for transport layer
func NewRequest ¶ added in v1.5.3
NewRequest aims to create Request. The ID is auto increase.
type Response ¶ added in v1.5.3
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 ¶ added in v1.5.3
NewResponse create to a new Response.
func (*Response) IsHeartbeat ¶ added in v1.5.3
the response is heartbeat
type SequenceType ¶ added in v1.5.3
type SequenceType int64