remoting

package
v1.5.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2022 License: Apache-2.0 Imports: 9 Imported by: 13

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

View Source
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 RegistryCodec(protocol string, codecTmp Codec)

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

func GetCodec added in v1.5.3

func GetCodec(protocol string) Codec

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 Event

type Event struct {
	Path    string
	Action  EventType
	Content string
}

Event defines common elements for service event

func (Event) String

func (e Event) String() string

nolint

type EventType

type EventType int

EventType means SourceObjectEventType

func (EventType) String

func (t EventType) String() string

nolint

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) Close added in v1.5.3

func (client *ExchangeClient) Close()

close client

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

type ExchangeServer struct {
	Server Server
	URL    *common.URL
}

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

func (*ExchangeServer) Start added in v1.5.3

func (server *ExchangeServer) Start()

start server

func (*ExchangeServer) Stop added in v1.5.3

func (server *ExchangeServer) Stop()

stop server

type Options added in v1.5.3

type Options struct {
	// connect timeout
	ConnectTimeout time.Duration
}

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

func NewRequest(version string) *Request

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

func NewResponse(id int64, version string) *Response

NewResponse create to a new Response.

func (*Response) Handle added in v1.5.5

func (response *Response) Handle()

func (*Response) IsHeartbeat added in v1.5.3

func (response *Response) IsHeartbeat() bool

the response is heartbeat

type SequenceType added in v1.5.3

type SequenceType int64

type Server added in v1.5.3

type Server interface {
	//invoke once for connection
	Start()
	//it is for destroy
	Stop()
}

It is interface of server for network communication. If you use getty as network communication, you should define GettyServer that implements this interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL