getty

package
v1.0.0-rc303rc1reinit2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TCPReadWriteTimeoutMinValue = time.Second * 1
)
View Source
const (
	WritePkg_Timeout = 5 * time.Second // TODO: WritePkg_Timeout will entry *.yml
)

Variables

This section is empty.

Functions

func SetClientConf

func SetClientConf(c ClientConfig)

SetClientConf ClientConf

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 NewClient

func NewClient(opt Options) *Client

NewClient create client

func (*Client) Close

func (c *Client) Close()

Close close network connection

func (*Client) Connect

func (c *Client) Connect(url *common.URL) error

Connect init client and try to connection.

func (*Client) IsAvailable

func (c *Client) IsAvailable() bool

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

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

	// gr pool
	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 multi config 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"`
	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 session params

type Options

type Options struct {
	ConnectTimeout time.Duration
	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

func (*Server) Start

func (s *Server) Start()

Start dubbo server.

func (*Server) Stop

func (s *Server) Stop()

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

	// gr pool
	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 GetServerConfig

func GetServerConfig() ServerConfig

GetServerConfig get getty 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