quic

package
v0.0.0-...-1a2806f Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//PackageLengthSize package length size
	PackageLengthSize = 2
)

Variables

View Source
var ErrReadMessage = errors.New("read message failed")

ErrReadMessage read message failed

View Source
var ErrReadPackageLength = errors.New("read package length failed")

ErrReadPackageLength read package length failed

Functions

func NewConn

func NewConn(conn quic.Connection, stream quic.Stream, rwQueueSize int, maxMessageSize uint32, readDeadline time.Duration) network.IConn

NewConn create quic conn

func NewServer

func NewServer(conf config.IConfig, agentFunc network.AgentCreateFunc, agentCloseFunc network.AgentCloseFunc) network.IServer

NewServer create quic server

Types

type Client

type Client struct {
	sync.Mutex
	Conf       *ClientConfig
	NewAgent   network.AgentCreateFunc
	CloseAgent network.AgentCloseFunc
	// contains filtered or unexported fields
}

Client quic client

func NewClient

func NewClient(conf config.IConfig, agentFunc network.AgentCreateFunc, agentCloseFunc network.AgentCloseFunc) *Client

NewClient create quic client

func (*Client) Close

func (c *Client) Close()

Close client connections

func (*Client) Run

func (c *Client) Run()

Run client start run

type ClientConfig

type ClientConfig struct {
	Nodes            []common.NodeInfo `mapstructure:"nodes"`
	ConnNum          int               `mapstructure:"conn_num"`
	ConnectInterval  time.Duration     `mapstructure:"connect_interval"`
	SocketQueueSize  int               `mapstructure:"socket_queue_size"`
	MaxMessageSize   uint32            `mapstructure:"max_message_size"`
	HandshakeTimeout time.Duration     `mapstructure:"handshake_timeout"`
	AutoReconnect    bool              `mapstructure:"auto_reconnect"`
	Network          string            `mapstructure:"network"`
	Token            string            `mapstructure:"token"`
	UID              uint64            `mapstructure:"uid"`
	ReadBufferSize   int               `mapstructure:"read_buffer_size"`
	WriteBufferSize  int               `mapstructure:"write_buffer_size"`
	ReadDeadline     time.Duration     `mapstructure:"read_dead_line"`
	QueueSize        int               `mapstructure:"queue_size"`
}

ClientConfig grpc client config

func (*ClientConfig) GetQueueSize

func (c *ClientConfig) GetQueueSize() int

GetQueueSize get module queue size

type Config

type Config struct {
	Address         string
	Network         string
	MaxConnNum      int
	RWQueueSize     int
	MaxMessageSize  uint32
	ReadBufferSize  int
	WriteBufferSize int
	ReadDeadline    time.Duration
}

Config quic conn config

type Conn

type Conn struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Conn quic conn define

func (*Conn) Close

func (c *Conn) Close()

Close quic conn close

func (*Conn) Destroy

func (c *Conn) Destroy()

Destroy quic conn destory

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr get local addr

func (*Conn) ReadMessage

func (c *Conn) ReadMessage() (interface{}, error)

ReadMessage goroutine not safe

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr get remote addr

func (*Conn) WriteMessage

func (c *Conn) WriteMessage(args ...interface{}) error

WriteMessage args must not be modified by the others goroutines buffer must packet with 2B package length

type ConnSet

type ConnSet map[quic.Connection]struct{}

ConnSet quic conn set

type Server

type Server struct {
	Conf     *ServerConfig
	NewAgent network.AgentCreateFunc

	CloseAgent network.AgentCloseFunc
	// contains filtered or unexported fields
}

Server quic server define

func (*Server) Close

func (s *Server) Close()

Close quic server

func (*Server) ListenAndServe

func (s *Server) ListenAndServe()

ListenAndServe start serve

func (*Server) Transport

func (s *Server) Transport(sess quic.Connection, stream quic.Stream) error

Transport quic connection

type ServerConfig

type ServerConfig struct {
	Address         string        `mapstructure:"address"`
	MaxConnNum      int           `mapstructure:"max_conn_num"`
	SocketQueueSize int           `mapstructure:"socket_queue_size"`
	MaxMessageSize  uint32        `mapstructure:"max_message_size"`
	ReadBufferSize  int           `mapstructure:"read_buffer_size"`
	WriteBufferSize int           `mapstructure:"write_buffer_size"`
	ReadDeadline    time.Duration `mapstructure:"read_dead_line"`
	Network         string        `mapstructure:"network"`
	QueueSize       int           `mapstructure:"queue_size"`
}

ServerConfig grpc server config

func (*ServerConfig) GetQueueSize

func (s *ServerConfig) GetQueueSize() int

GetQueueSize get module queue size

Jump to

Keyboard shortcuts

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