Documentation
¶
Index ¶
- Constants
- Variables
- func Connect(opts ...Option) gin.HandlerFunc
- func NewManagerWithOptions(opts ...ManagerOption)
- func ValidateStructWithOutCtx(s interface{}) (err error)
- type Client
- func (c *Client) Close()
- func (c *Client) Deadline() (deadline time.Time, ok bool)
- func (c *Client) Done() <-chan struct{}
- func (c *Client) Err() error
- func (c *Client) Heartbeat()
- func (c *Client) Read()
- func (c *Client) SendMessage(message Send)
- func (c *Client) SetValue(key, value any)
- func (c *Client) Value(key any) any
- func (c *Client) Write()
- type CommandRouter
- func (r *CommandRouter) ProtoHandle(client *Client, send Send) (err error)
- func (r *CommandRouter) RegisterProto(command string, handler func(*m.Message))
- func (r *CommandRouter) RegisterText(command string, handler func(*Message))
- func (r *CommandRouter) TextHandle(client *Client, send Send) (err error)
- type JSONSerializer
- type Manager
- type ManagerOption
- type Message
- type Option
- type ProtoHandler
- type ProtocolSerializer
- type Send
- type Serializer
- type TextHandler
Constants ¶
View Source
const ( SendLimit = 100 BreakTime = 600 // Heartbeat breakTime in seconds Interval = 1000 // Heartbeat interval in milliseconds )
View Source
const ( RegisterLimit = 1000 ReadBufferSize = 4096 WriteBufferSize = 4096 MaxConnections = 100000 )
Variables ¶
View Source
var (
Once sync.Once
)
Functions ¶
func Connect ¶
func Connect(opts ...Option) gin.HandlerFunc
func NewManagerWithOptions ¶ added in v1.0.3
func NewManagerWithOptions(opts ...ManagerOption)
func ValidateStructWithOutCtx ¶
func ValidateStructWithOutCtx(s interface{}) (err error)
ValidateStructWithOutCtx check struct
Types ¶
type Client ¶ added in v1.0.3
func NewClientWithOptions ¶ added in v1.0.3
func (*Client) Done ¶ added in v1.0.3
func (c *Client) Done() <-chan struct{}
Done returns a channel that is closed when the context is done.
func (*Client) SendMessage ¶ added in v1.0.3
SendMessage Send message
func (*Client) SetValue ¶ added in v1.0.3
SetValue sets the value associated with key in the context.
type CommandRouter ¶
type CommandRouter struct {
// contains filtered or unexported fields
}
var Router *CommandRouter
func NewCommandRouter ¶
func NewCommandRouter() *CommandRouter
func (*CommandRouter) ProtoHandle ¶
func (r *CommandRouter) ProtoHandle(client *Client, send Send) (err error)
func (*CommandRouter) RegisterProto ¶
func (r *CommandRouter) RegisterProto(command string, handler func(*m.Message))
func (*CommandRouter) RegisterText ¶
func (r *CommandRouter) RegisterText(command string, handler func(*Message))
func (*CommandRouter) TextHandle ¶
func (r *CommandRouter) TextHandle(client *Client, send Send) (err error)
type JSONSerializer ¶
type JSONSerializer[T Message] struct { // contains filtered or unexported fields }
func NewJSONSerializer ¶
func NewJSONSerializer[T Message](data T) *JSONSerializer[T]
func (*JSONSerializer[T]) Data ¶
func (j *JSONSerializer[T]) Data() T
func (*JSONSerializer[T]) Deserialize ¶
func (j *JSONSerializer[T]) Deserialize(data []byte, v *T) error
func (*JSONSerializer[T]) Serialize ¶
func (j *JSONSerializer[T]) Serialize(data T) ([]byte, error)
type Manager ¶
type Manager struct { Register chan *Client Unset chan *Client MaxConn uint32 ReadBufferSize int WriteBufferSize int Errs chan error // contains filtered or unexported fields }
func (*Manager) GetAllClient ¶
GetAllClient Get all clients
func (*Manager) SendBroadcast ¶
SendBroadcast Send broadcast message
type ManagerOption ¶ added in v1.0.3
type ManagerOption interface {
// contains filtered or unexported methods
}
func WithMaxConn ¶ added in v1.0.3
func WithMaxConn(maxConn uint32) ManagerOption
func WithReadBufferSize ¶ added in v1.0.3
func WithReadBufferSize(size int) ManagerOption
func WithRegisterLimit ¶ added in v1.0.3
func WithRegisterLimit(registerLimit int) ManagerOption
func WithWriteBufferSize ¶ added in v1.0.3
func WithWriteBufferSize(size int) ManagerOption
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithBreakTime ¶ added in v1.0.3
func WithClientValues ¶ added in v1.0.3
func WithInterval ¶ added in v1.0.3
func WithSendLimit ¶ added in v1.0.3
type ProtocolSerializer ¶
func NewProtocolSerializer ¶
func NewProtocolSerializer[T proto.Message](data T) *ProtocolSerializer[T]
func (*ProtocolSerializer[T]) Data ¶
func (p *ProtocolSerializer[T]) Data() T
func (*ProtocolSerializer[T]) Deserialize ¶
func (p *ProtocolSerializer[T]) Deserialize(data []byte, v *T) error
func (*ProtocolSerializer[T]) Serialize ¶
func (p *ProtocolSerializer[T]) Serialize(data T) ([]byte, error)
type Serializer ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.