Documentation ¶
Index ¶
- Constants
- func SetClientConf(c ClientConfig)
- func SetServerConfig(s ServerConfig)
- type Client
- type ClientConfig
- type GettySessionParam
- type Options
- type RpcClientHandler
- func (h *RpcClientHandler) OnClose(session getty.Session)
- func (h *RpcClientHandler) OnCron(session getty.Session)
- func (h *RpcClientHandler) OnError(session getty.Session, err error)
- func (h *RpcClientHandler) OnMessage(session getty.Session, pkg interface{})
- func (h *RpcClientHandler) OnOpen(session getty.Session) error
- type RpcClientPackageHandler
- type RpcServerHandler
- func (h *RpcServerHandler) OnClose(session getty.Session)
- func (h *RpcServerHandler) OnCron(session getty.Session)
- func (h *RpcServerHandler) OnError(session getty.Session, err error)
- func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{})
- func (h *RpcServerHandler) OnOpen(session getty.Session) error
- type RpcServerPackageHandler
- type Server
- type ServerConfig
Constants ¶
const ( // WritePkg_Timeout the timeout of write pkg WritePkg_Timeout = 5 * time.Second )
todo: WritePkg_Timeout will entry *.yml
Variables ¶
This section is empty.
Functions ¶
func SetServerConfig ¶
func SetServerConfig(s ServerConfig)
SetServerConfig set dubbo server config.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client : some configuration for network communication.
func (*Client) IsAvailable ¶
isAvailable returns true if the connection is available, or it can be re-established.
func (*Client) Request ¶
func (c *Client) Request(request *remoting.Request, timeout time.Duration, response *remoting.PendingResponse) error
send request
func (*Client) SetExchangeClient ¶
func (c *Client) SetExchangeClient(client *remoting.ExchangeClient)
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:"60s" yaml:"heartbeat_period" json:"heartbeat_period,omitempty"` // heartbeat timeout HeartbeatTimeout string `default:"5s" yaml:"heartbeat_timeout" json:"heartbeat_timeout,omitempty"` // session SessionTimeout string `default:"60s" yaml:"session_timeout" json:"session_timeout,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 GetDefaultClientConfig ¶
func GetDefaultClientConfig() ClientConfig
GetDefaultClientConfig gets client default configuration
func (*ClientConfig) CheckValidity ¶
func (c *ClientConfig) CheckValidity() error
CheckValidity confirm client params.
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 ¶
type Options struct { // connect timeout // remove request timeout, it will be calculate for every request ConnectTimeout time.Duration // request timeout RequestTimeout time.Duration }
Options : param config
type RpcClientHandler ¶
type RpcClientHandler struct {
// contains filtered or unexported fields
}
nolint
func NewRpcClientHandler ¶
func NewRpcClientHandler(client *gettyRPCClient) *RpcClientHandler
nolint
func (*RpcClientHandler) OnClose ¶
func (h *RpcClientHandler) OnClose(session getty.Session)
OnClose close the session, remove it from the getty session list
func (*RpcClientHandler) OnCron ¶
func (h *RpcClientHandler) OnCron(session getty.Session)
OnCron check the session health periodic. if the session's sessionTimeout has reached, just close the session
func (*RpcClientHandler) OnError ¶
func (h *RpcClientHandler) OnError(session getty.Session, err error)
OnError the getty client session has errored, so remove the session from the getty client session list
func (*RpcClientHandler) OnMessage ¶
func (h *RpcClientHandler) OnMessage(session getty.Session, pkg interface{})
OnMessage get response from getty server, and update the session to the getty client session list
func (*RpcClientHandler) OnOpen ¶
func (h *RpcClientHandler) OnOpen(session getty.Session) error
OnOpen call the getty client session opened, add the session to getty client session list
type RpcClientPackageHandler ¶
type RpcClientPackageHandler struct {
// contains filtered or unexported fields
}
RpcClientPackageHandler Read data from server and Write data to server
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 data from server. if the package size from server is larger than 4096 byte, server will read 4096 byte and send to client each time. the Read can assemble it.
func (*RpcClientPackageHandler) Write ¶
func (p *RpcClientPackageHandler) Write(ss getty.Session, pkg interface{}) ([]byte, error)
Write send the data to server
type RpcServerHandler ¶
type RpcServerHandler struct {
// contains filtered or unexported fields
}
nolint
func NewRpcServerHandler ¶
func NewRpcServerHandler(maxSessionNum int, sessionTimeout time.Duration, serverP *Server) *RpcServerHandler
nolint
func (*RpcServerHandler) OnClose ¶
func (h *RpcServerHandler) OnClose(session getty.Session)
OnClose close the session, remove it from the getty server list
func (*RpcServerHandler) OnCron ¶
func (h *RpcServerHandler) OnCron(session getty.Session)
OnCron check the session health periodic. if the session's sessionTimeout has reached, just close the session
func (*RpcServerHandler) OnError ¶
func (h *RpcServerHandler) OnError(session getty.Session, err error)
OnError the getty server session has errored, so remove the session from the getty server session list
func (*RpcServerHandler) OnMessage ¶
func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{})
OnMessage get request from getty client, update the session reqNum and reply response to client
func (*RpcServerHandler) OnOpen ¶
func (h *RpcServerHandler) OnOpen(session getty.Session) error
OnOpen call server session opened, add the session to getty server session list. also onOpen will check the max getty server session number
type RpcServerPackageHandler ¶
type RpcServerPackageHandler struct {
// contains filtered or unexported fields
}
RpcServerPackageHandler Read data from client and Write data to client
func NewRpcServerPackageHandler ¶
func NewRpcServerPackageHandler(server *Server) *RpcServerPackageHandler
func (*RpcServerPackageHandler) Read ¶
func (p *RpcServerPackageHandler) Read(ss getty.Session, data []byte) (interface{}, int, error)
Read data from client. if the package size from client is larger than 4096 byte, client will read 4096 byte and send to client each time. the Read can assemble it.
func (*RpcServerPackageHandler) Write ¶
func (p *RpcServerPackageHandler) Write(ss getty.Session, pkg interface{}) ([]byte, error)
Write send the data to client
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server define getty server
func NewServer ¶
func NewServer(url *common.URL, handlers func(*invocation.RPCInvocation) protocol.RPCResult) *Server
NewServer create a new Server
type ServerConfig ¶
type ServerConfig struct { SSLEnabled bool // heartbeat HeartbeatPeriod string `default:"60s" yaml:"heartbeat_period" json:"heartbeat_period,omitempty"` // heartbeat timeout HeartbeatTimeout string `default:"5s" yaml:"heartbeat_timeout" json:"heartbeat_timeout,omitempty"` // 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 ¶
func GetDefaultServerConfig() ServerConfig
GetDefaultServerConfig gets server default configuration
func (*ServerConfig) CheckValidity ¶
func (c *ServerConfig) CheckValidity() error
CheckValidity confirm server params