dubbo

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: Apache-2.0 Imports: 27 Imported by: 142

Documentation

Index

Constants

View Source
const (
	// DUBBO is dubbo protocol name
	DUBBO = "dubbo"
)

dubbo protocol constant

Variables

View Source
var (
	// ErrNoReply
	ErrNoReply = perrors.New("request need @response")
	// ErrDestroyedInvoker
	ErrDestroyedInvoker = perrors.New("request Destroyed invoker")
)

Functions

func GetProtocol

func GetProtocol() protocol.Protocol

GetProtocol get a single dubbo protocol.

func SetClientConf

func SetClientConf(c ClientConfig)

SetClientConf set dubbo client config.

func SetServerConfig

func SetServerConfig(s ServerConfig)

SetServerConfig set dubbo server config.

Types

type AsyncCallbackResponse added in v1.3.0

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 CallType

type CallType int32

CallType call type

const (
	// CT_UNKNOWN unknown call type
	CT_UNKNOWN CallType = 0
	// CT_OneWay call one way
	CT_OneWay CallType = 1
	// CT_TwoWay call in request/response
	CT_TwoWay CallType = 2
)

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is dubbo protocol client.

func NewClient

func NewClient(opt Options) *Client

NewClient create a new Client.

func (*Client) AsyncCall

func (c *Client) AsyncCall(request *Request, callback common.AsyncCallback, response *Response) error

AsyncCall call remoting by async with callback.

func (*Client) Call

func (c *Client) Call(request *Request, response *Response) error

Call call remoting by two way or one way, if @response.reply is nil, the way of call is one way.

func (*Client) CallOneway

func (c *Client) CallOneway(request *Request) error

CallOneway call by one way

func (*Client) Close

func (c *Client) Close()

Close close the client pool.

type ClientConfig

type ClientConfig struct {
	ReconnectInterval int `default:"0" yaml:"reconnect_interval" json:"reconnect_interval,omitempty"`

	// session pool
	ConnectionNum int `default:"16" yaml:"connection_number" json:"connection_number,omitempty"`

	// heartbeat
	HeartbeatPeriod string `default:"15s" yaml:"heartbeat_period" json:"heartbeat_period,omitempty"`

	// session
	SessionTimeout string `default:"60s" yaml:"session_timeout" json:"session_timeout,omitempty"`

	// Connection Pool
	PoolSize int `default:"2" yaml:"pool_size" json:"pool_size,omitempty"`
	PoolTTL  int `default:"180" yaml:"pool_ttl" json:"pool_ttl,omitempty"`

	// grpool
	GrPoolSize  int `default:"0" yaml:"gr_pool_size" json:"gr_pool_size,omitempty"`
	QueueLen    int `default:"0" yaml:"queue_len" json:"queue_len,omitempty"`
	QueueNumber int `default:"0" yaml:"queue_number" json:"queue_number,omitempty"`

	// session tcp parameters
	GettySessionParam GettySessionParam `required:"true" yaml:"getty_session_param" json:"getty_session_param,omitempty"`
	// contains filtered or unexported fields
}

ClientConfig holds supported types by the multiconfig package

func GetClientConf

func GetClientConf() ClientConfig

GetClientConf get dubbo client config.

func GetDefaultClientConfig added in v1.2.0

func GetDefaultClientConfig() ClientConfig

GetDefaultClientConfig gets client default configuration.

func (*ClientConfig) CheckValidity

func (c *ClientConfig) CheckValidity() error

CheckValidity confirm client params.

type DubboExporter

type DubboExporter struct {
	protocol.BaseExporter
}

DubboExporter is dubbo service exporter.

func NewDubboExporter

func NewDubboExporter(key string, invoker protocol.Invoker, exporterMap *sync.Map) *DubboExporter

NewDubboExporter get a DubboExporter.

func (*DubboExporter) Unexport

func (de *DubboExporter) Unexport()

Unexport unexport dubbo service exporter.

type DubboInvoker

type DubboInvoker struct {
	protocol.BaseInvoker
	// contains filtered or unexported fields
}

DubboInvoker is dubbo client invoker.

func NewDubboInvoker

func NewDubboInvoker(url common.URL, client *Client) *DubboInvoker

NewDubboInvoker create dubbo client invoker.

func (*DubboInvoker) Destroy

func (di *DubboInvoker) Destroy()

Destroy destroy dubbo client invoker.

func (*DubboInvoker) Invoke

func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result

Invoke call remoting.

type DubboPackage

type DubboPackage struct {
	Header  hessian.DubboHeader
	Service hessian.Service
	Body    interface{}
	Err     error
}

DubboPackage ...

func (*DubboPackage) Marshal

func (p *DubboPackage) Marshal() (*bytes.Buffer, error)

Marshal encode hessian package.

func (DubboPackage) String

func (p DubboPackage) String() string

String prints dubbo package detail include header、path、body etc.

func (*DubboPackage) Unmarshal

func (p *DubboPackage) Unmarshal(buf *bytes.Buffer, opts ...interface{}) error

Unmarshal dncode hessian package.

type DubboProtocol

type DubboProtocol struct {
	protocol.BaseProtocol
	// contains filtered or unexported fields
}

DubboProtocol is a dubbo protocol implement.

func NewDubboProtocol

func NewDubboProtocol() *DubboProtocol

NewDubboProtocol create a dubbo protocol.

func (*DubboProtocol) Destroy

func (dp *DubboProtocol) Destroy()

Destroy destroy dubbo service.

func (*DubboProtocol) Export

func (dp *DubboProtocol) Export(invoker protocol.Invoker) protocol.Exporter

Export export dubbo service.

func (*DubboProtocol) Refer

func (dp *DubboProtocol) Refer(url common.URL) protocol.Invoker

Refer create dubbo service reference.

type GettySessionParam

type GettySessionParam struct {
	CompressEncoding bool   `default:"false" yaml:"compress_encoding" json:"compress_encoding,omitempty"`
	TcpNoDelay       bool   `default:"true" yaml:"tcp_no_delay" json:"tcp_no_delay,omitempty"`
	TcpKeepAlive     bool   `default:"true" yaml:"tcp_keep_alive" json:"tcp_keep_alive,omitempty"`
	KeepAlivePeriod  string `default:"180s" yaml:"keep_alive_period" json:"keep_alive_period,omitempty"`

	TcpRBufSize    int    `default:"262144" yaml:"tcp_r_buf_size" json:"tcp_r_buf_size,omitempty"`
	TcpWBufSize    int    `default:"65536" yaml:"tcp_w_buf_size" json:"tcp_w_buf_size,omitempty"`
	PkgWQSize      int    `default:"1024" yaml:"pkg_wq_size" json:"pkg_wq_size,omitempty"`
	TcpReadTimeout string `default:"1s" yaml:"tcp_read_timeout" json:"tcp_read_timeout,omitempty"`

	TcpWriteTimeout string `default:"5s" yaml:"tcp_write_timeout" json:"tcp_write_timeout,omitempty"`

	WaitTimeout string `default:"7s" yaml:"wait_timeout" json:"wait_timeout,omitempty"`

	MaxMsgLen   int    `default:"1024" yaml:"max_msg_len" json:"max_msg_len,omitempty"`
	SessionName string `default:"rpc" yaml:"session_name" json:"session_name,omitempty"`
	// contains filtered or unexported fields
}

GettySessionParam is session configuration for getty.

func (*GettySessionParam) CheckValidity

func (c *GettySessionParam) CheckValidity() error

CheckValidity confirm getty sessian params.

type Options added in v1.2.0

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

Options is option for create dubbo client

type PendingResponse

type PendingResponse struct {
	// contains filtered or unexported fields
}

PendingResponse is a pending response.

func NewPendingResponse

func NewPendingResponse() *PendingResponse

NewPendingResponse create a PendingResponses.

func (PendingResponse) GetCallResponse

func (r PendingResponse) GetCallResponse() common.CallbackResponse

GetCallResponse get AsyncCallbackResponse.

type Request added in v1.2.0

type Request struct {
	// contains filtered or unexported fields
}

Request is dubbo protocol request.

func NewRequest added in v1.2.0

func NewRequest(addr string, svcUrl common.URL, method string, args interface{}, atta map[string]string) *Request

NewRequest create a new Request.

type Response added in v1.2.0

type Response struct {
	// contains filtered or unexported fields
}

Response is dubbo protocol response.

func NewResponse added in v1.2.0

func NewResponse(reply interface{}, atta map[string]string) *Response

NewResponse create a new Response.

type RpcClientHandler

type RpcClientHandler struct {
	// contains filtered or unexported fields
}

RpcClientHandler is handler of RPC Client

func NewRpcClientHandler

func NewRpcClientHandler(client *gettyRPCClient) *RpcClientHandler

NewRpcClientHandler creates RpcClientHandler with @gettyRPCClient

func (*RpcClientHandler) OnClose

func (h *RpcClientHandler) OnClose(session getty.Session)

OnOpen notified when RPC client session closed

func (*RpcClientHandler) OnCron

func (h *RpcClientHandler) OnCron(session getty.Session)

OnCron notified when RPC client session got any message in cron job

func (*RpcClientHandler) OnError

func (h *RpcClientHandler) OnError(session getty.Session, err error)

OnError notified when RPC client session got any error

func (*RpcClientHandler) OnMessage

func (h *RpcClientHandler) OnMessage(session getty.Session, pkg interface{})

OnMessage notified when RPC client session got any message in connection

func (*RpcClientHandler) OnOpen

func (h *RpcClientHandler) OnOpen(session getty.Session) error

OnOpen notified when RPC client session opened

type RpcClientPackageHandler

type RpcClientPackageHandler struct {
	// contains filtered or unexported fields
}

RpcClientPackageHandler handle package for client in getty.

func NewRpcClientPackageHandler

func NewRpcClientPackageHandler(client *Client) *RpcClientPackageHandler

NewRpcClientPackageHandler create a RpcClientPackageHandler.

func (*RpcClientPackageHandler) Read

func (p *RpcClientPackageHandler) Read(ss getty.Session, data []byte) (interface{}, int, error)

Read decode @data to DubboPackage.

func (*RpcClientPackageHandler) Write

func (p *RpcClientPackageHandler) Write(ss getty.Session, pkg interface{}) ([]byte, error)

Write encode @pkg.

type RpcServerHandler

type RpcServerHandler struct {
	// contains filtered or unexported fields
}

RpcServerHandler is handler of RPC Server

func NewRpcServerHandler

func NewRpcServerHandler(maxSessionNum int, sessionTimeout time.Duration) *RpcServerHandler

NewRpcServerHandler creates RpcServerHandler with @maxSessionNum and @sessionTimeout

func (*RpcServerHandler) OnClose

func (h *RpcServerHandler) OnClose(session getty.Session)

OnOpen notified when RPC server session closed

func (*RpcServerHandler) OnCron

func (h *RpcServerHandler) OnCron(session getty.Session)

OnCron notified when RPC server session got any message in cron job

func (*RpcServerHandler) OnError

func (h *RpcServerHandler) OnError(session getty.Session, err error)

OnError notified when RPC server session got any error

func (*RpcServerHandler) OnMessage

func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{})

OnMessage notified when RPC server session got any message in connection

func (*RpcServerHandler) OnOpen

func (h *RpcServerHandler) OnOpen(session getty.Session) error

OnOpen notified when RPC server session opened

type RpcServerPackageHandler

type RpcServerPackageHandler struct{}

RpcServerPackageHandler handle package for server in getty.

func (*RpcServerPackageHandler) Read

func (p *RpcServerPackageHandler) Read(ss getty.Session, data []byte) (interface{}, int, error)

Read decode @data to DubboPackage.

func (*RpcServerPackageHandler) Write

func (p *RpcServerPackageHandler) Write(ss getty.Session, pkg interface{}) ([]byte, error)

Write encode @pkg.

type SequenceType

type SequenceType int64

SequenceType ...

type SerialID

type SerialID byte

SerialID serial ID

const (
	// S_Dubbo dubbo serial id
	S_Dubbo SerialID = 2
)

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is dubbo protocol server.

func NewServer

func NewServer() *Server

NewServer create a new Server.

func (*Server) Start

func (s *Server) Start(url common.URL)

Start start dubbo server.

func (*Server) Stop

func (s *Server) Stop()

Stop stop dubbo server.

type ServerConfig

type ServerConfig struct {
	// session
	SessionTimeout string `default:"60s" yaml:"session_timeout" json:"session_timeout,omitempty"`

	SessionNumber int `default:"1000" yaml:"session_number" json:"session_number,omitempty"`

	// grpool
	GrPoolSize  int `default:"0" yaml:"gr_pool_size" json:"gr_pool_size,omitempty"`
	QueueLen    int `default:"0" yaml:"queue_len" json:"queue_len,omitempty"`
	QueueNumber int `default:"0" yaml:"queue_number" json:"queue_number,omitempty"`

	// session tcp parameters
	GettySessionParam GettySessionParam `required:"true" yaml:"getty_session_param" json:"getty_session_param,omitempty"`
	// contains filtered or unexported fields
}

ServerConfig holds supported types by the multiconfig package

func GetDefaultServerConfig added in v1.2.0

func GetDefaultServerConfig() ServerConfig

GetDefaultServerConfig gets server default configuration.

func GetServerConfig

func GetServerConfig() ServerConfig

GetServerConfig get dubbo server config.

func (*ServerConfig) CheckValidity

func (c *ServerConfig) CheckValidity() error

CheckValidity confirm server params.

Jump to

Keyboard shortcuts

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