dubbo

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const DUBBO = "dubbo"
View Source
const WritePkg_Timeout = 5 * time.Second

todo: WritePkg_Timeout will entry *.yml

Variables

View Source
var Err_No_Reply = perrors.New("request need @reply")

Functions

func GenerateEndpointAddr

func GenerateEndpointAddr(protocol, addr string) string

func GetProtocol

func GetProtocol() protocol.Protocol

func SetClientConf

func SetClientConf(c ClientConfig)

func SetServerConfig

func SetServerConfig(s ServerConfig)

Types

type AsyncCallback

type AsyncCallback func(response CallResponse)

type CallOption

type CallOption func(*CallOptions)

type CallOptions

type CallOptions struct {
	// request timeout
	RequestTimeout time.Duration
	// response timeout
	ResponseTimeout time.Duration
	// serial ID
	SerialID SerialID
	Meta     map[interface{}]interface{}
}

type CallResponse

type CallResponse struct {
	Opts      CallOptions
	Cause     error
	Start     time.Time // invoke(call) start time == write start time
	ReadStart time.Time // read start time, write duration = ReadStart - Start
	Reply     interface{}
}

type CallType

type CallType int32

call type

const (
	CT_UNKOWN CallType = 0
	CT_OneWay CallType = 1
	CT_TwoWay CallType = 2
)

type Client

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

func NewClient

func NewClient() *Client

func (*Client) AsyncCall

func (c *Client) AsyncCall(addr string, svcUrl common.URL, method string, args interface{},
	callback AsyncCallback, reply interface{}, opts ...CallOption) error

func (*Client) Call

func (c *Client) Call(addr string, svcUrl common.URL, method string, args, reply interface{}, opts ...CallOption) error

if @reply is nil, the transport layer will get the response without notify the invoker.

func (*Client) CallOneway

func (c *Client) CallOneway(addr string, svcUrl common.URL, method string, args interface{}, opts ...CallOption) error

call one way

func (*Client) Close

func (c *Client) Close()

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"`

	// app
	FailFastTimeout string `default:"5s" yaml:"fail_fast_timeout" json:"fail_fast_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"`

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

Config holds supported types by the multiconfig package

func GetClientConf

func GetClientConf() ClientConfig

func (*ClientConfig) CheckValidity

func (c *ClientConfig) CheckValidity() error

type DubboExporter

type DubboExporter struct {
	protocol.BaseExporter
}

func NewDubboExporter

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

func (*DubboExporter) Unexport

func (de *DubboExporter) Unexport()

type DubboInvoker

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

func NewDubboInvoker

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

func (*DubboInvoker) Destroy

func (di *DubboInvoker) Destroy()

func (*DubboInvoker) Invoke

func (di *DubboInvoker) Invoke(invocation protocol.Invocation) protocol.Result

type DubboPackage

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

func (*DubboPackage) Marshal

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

func (DubboPackage) String

func (p DubboPackage) String() string

func (*DubboPackage) Unmarshal

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

type DubboProtocol

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

func NewDubboProtocol

func NewDubboProtocol() *DubboProtocol

func (*DubboProtocol) Destroy

func (dp *DubboProtocol) Destroy()

func (*DubboProtocol) Export

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

func (*DubboProtocol) Refer

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

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"`
	PkgRQSize      int    `default:"1024" yaml:"pkg_rq_size" json:"pkg_rq_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
}

func (*GettySessionParam) CheckValidity

func (c *GettySessionParam) CheckValidity() error

type PendingResponse

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

func NewPendingResponse

func NewPendingResponse() *PendingResponse

func (PendingResponse) GetCallResponse

func (r PendingResponse) GetCallResponse() CallResponse

type RpcClientHandler

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

func NewRpcClientHandler

func NewRpcClientHandler(client *gettyRPCClient) *RpcClientHandler

func (*RpcClientHandler) OnClose

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

func (*RpcClientHandler) OnCron

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

func (*RpcClientHandler) OnError

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

func (*RpcClientHandler) OnMessage

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

func (*RpcClientHandler) OnOpen

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

type RpcClientPackageHandler

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

func NewRpcClientPackageHandler

func NewRpcClientPackageHandler(client *Client) *RpcClientPackageHandler

func (*RpcClientPackageHandler) Read

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

func (*RpcClientPackageHandler) Write

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

type RpcServerHandler

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

func NewRpcServerHandler

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

func (*RpcServerHandler) OnClose

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

func (*RpcServerHandler) OnCron

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

func (*RpcServerHandler) OnError

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

func (*RpcServerHandler) OnMessage

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

func (*RpcServerHandler) OnOpen

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

type RpcServerPackageHandler

type RpcServerPackageHandler struct {
}

func NewRpcServerPackageHandler

func NewRpcServerPackageHandler() *RpcServerPackageHandler

func (*RpcServerPackageHandler) Read

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

func (*RpcServerPackageHandler) Write

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

type SequenceType

type SequenceType int64

type SerialID

type SerialID byte

serial ID

const (
	S_Dubbo SerialID = 2
)

type Server

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

func NewServer

func NewServer(exporter protocol.Exporter) *Server

func (*Server) Start

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

func (*Server) Stop

func (s *Server) Stop()

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"`

	// app
	FailFastTimeout string `default:"5s" yaml:"fail_fast_timeout" json:"fail_fast_timeout,omitempty"`

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

Config holds supported types by the multiconfig package

func GetServerConfig

func GetServerConfig() ServerConfig

func (*ServerConfig) CheckValidity

func (c *ServerConfig) CheckValidity() error

Jump to

Keyboard shortcuts

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