getty

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CronPeriod = 20e9
)
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

This section is empty.

Types

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 RpcServerHandler

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

func NewRpcServerHandler

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

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(handlers func(*invocation.RPCInvocation) protocol.RPCResult, serverOption ...ServerOption) *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 (*ServerConfig) CheckValidity

func (c *ServerConfig) CheckValidity() error

CheckValidity confirm server params

type ServerOption

type ServerOption func(*Server)

func WithAddrServer

func WithAddrServer(addr string) ServerOption

func WithConfigServer

func WithConfigServer(conf ServerConfig) ServerOption

func WithListenerServer

func WithListenerServer(listener net.Listener) ServerOption

Jump to

Keyboard shortcuts

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