Documentation
¶
Index ¶
- Constants
- Variables
- func Connect(engine *Engine, opts ...Option) gin.HandlerFunc
- func ValidateStructWithOutCtx(s interface{}) (err error)
- type Client
- type Engine
- func (e *Engine) Publish(channel string, message []byte) (err error)
- func (e *Engine) RegisterJsonRouter(command string, handler Handler[*JsonMessage])
- func (e *Engine) RegisterProtoRouter(command string, handler Handler[*ProtoMessage])
- func (e *Engine) Subscribe(id, channel string) error
- func (e *Engine) Unsubscribe(id, channel string) error
- type EngineOption
- type Func
- type Handler
- type JSONSerializer
- type JsonMessage
- type Memory
- type Message
- type Option
- type ProtoFuncWrapper
- type ProtoMessage
- func (*ProtoMessage) Descriptor() ([]byte, []int)deprecated
- func (x *ProtoMessage) GetCode() int32
- func (x *ProtoMessage) GetCommand() string
- func (x *ProtoMessage) GetData() []byte
- func (x *ProtoMessage) GetMessage() string
- func (x *ProtoMessage) GetRequestId() string
- func (x *ProtoMessage) GetSocketId() string
- func (*ProtoMessage) ProtoMessage()
- func (x *ProtoMessage) ProtoReflect() protoreflect.Message
- func (x *ProtoMessage) Reset()
- func (x *ProtoMessage) String() string
- type ProtocolSerializer
- type Router
- type Serializer
- type SystemMemory
Constants ¶
View Source
const ( SendLimit = 100 BreakTime = 600 // heartbeat breakTime in seconds Interval = 1000 // heartbeat interval in milliseconds Connected = "connected" Success = "success" )
View Source
const ( RateLimit = 100 ReadBufferSize = 1024 WriteBufferSize = 1024 )
Variables ¶
View Source
var File_pb_message_proto protoreflect.FileDescriptor
Functions ¶
func ValidateStructWithOutCtx ¶
func ValidateStructWithOutCtx(s interface{}) (err error)
ValidateStructWithOutCtx check struct
Types ¶
type Client ¶ 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.
type Engine ¶ added in v1.0.9
type Engine struct {
// contains filtered or unexported fields
}
func NewEngineWithOptions ¶ added in v1.0.9
func NewEngineWithOptions(opts ...EngineOption) *Engine
func (*Engine) RegisterJsonRouter ¶ added in v1.0.9
func (e *Engine) RegisterJsonRouter(command string, handler Handler[*JsonMessage])
RegisterJsonRouter register json route
func (*Engine) RegisterProtoRouter ¶ added in v1.0.9
func (e *Engine) RegisterProtoRouter(command string, handler Handler[*ProtoMessage])
RegisterProtoRouter register proto route
func (*Engine) Unsubscribe ¶ added in v1.0.9
Unsubscribe from channel
type EngineOption ¶ added in v1.0.9
type EngineOption interface {
// contains filtered or unexported methods
}
func WithLogger ¶ added in v1.0.9
func WithLogger(logger *logger.Logger) EngineOption
func WithMaxConn ¶ added in v1.0.3
func WithMaxConn(maxConn uint32) EngineOption
func WithPublishWorkPool ¶ added in v1.0.9
func WithPublishWorkPool(poolSize int) EngineOption
func WithReadBufferSize ¶ added in v1.0.3
func WithReadBufferSize(size int) EngineOption
func WithSubscribeEngine ¶ added in v1.0.9
func WithSubscribeEngine(storage Memory) EngineOption
func WithWriteBufferSize ¶ added in v1.0.3
func WithWriteBufferSize(size int) EngineOption
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 JsonMessage ¶ added in v1.0.9
type JsonMessage struct { RequestId string `json:"request_id" validate:"required"` SocketId string `json:"socket_id" validate:"required"` Command string `json:"command" validate:"required"` Code int32 `json:"code,omitempty"` Message string `json:"message,omitempty"` Data []byte `json:"data,omitempty"` }
type Message ¶
type Message interface { *JsonMessage | *ProtoMessage }
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 WithProtocol ¶ added in v1.0.9
func WithSendLimit ¶ added in v1.0.3
type ProtoFuncWrapper ¶ added in v1.0.9
type ProtoFuncWrapper struct {
*ProtoMessage
}
type ProtoMessage ¶ added in v1.0.9
type ProtoMessage struct { RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` SocketId string `protobuf:"bytes,2,opt,name=socket_id,json=socketId,proto3" json:"socket_id,omitempty"` Command string `protobuf:"bytes,3,opt,name=command,proto3" json:"command,omitempty"` Code int32 `protobuf:"varint,4,opt,name=code,proto3" json:"code,omitempty"` Message string `protobuf:"bytes,5,opt,name=message,proto3" json:"message,omitempty"` Data []byte `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
func (*ProtoMessage) Descriptor
deprecated
added in
v1.0.9
func (*ProtoMessage) Descriptor() ([]byte, []int)
Deprecated: Use ProtoMessage.ProtoReflect.Descriptor instead.
func (*ProtoMessage) GetCode ¶ added in v1.0.9
func (x *ProtoMessage) GetCode() int32
func (*ProtoMessage) GetCommand ¶ added in v1.0.9
func (x *ProtoMessage) GetCommand() string
func (*ProtoMessage) GetData ¶ added in v1.0.9
func (x *ProtoMessage) GetData() []byte
func (*ProtoMessage) GetMessage ¶ added in v1.0.9
func (x *ProtoMessage) GetMessage() string
func (*ProtoMessage) GetRequestId ¶ added in v1.0.9
func (x *ProtoMessage) GetRequestId() string
func (*ProtoMessage) GetSocketId ¶ added in v1.0.9
func (x *ProtoMessage) GetSocketId() string
func (*ProtoMessage) ProtoMessage ¶ added in v1.0.9
func (*ProtoMessage) ProtoMessage()
func (*ProtoMessage) ProtoReflect ¶ added in v1.0.9
func (x *ProtoMessage) ProtoReflect() protoreflect.Message
func (*ProtoMessage) Reset ¶ added in v1.0.9
func (x *ProtoMessage) Reset()
func (*ProtoMessage) String ¶ added in v1.0.9
func (x *ProtoMessage) String() string
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 ¶
type SystemMemory ¶ added in v1.0.5
type SystemMemory struct {
// contains filtered or unexported fields
}
func (*SystemMemory) Delete ¶ added in v1.0.5
func (s *SystemMemory) Delete(id, channel string) error
func (*SystemMemory) Get ¶ added in v1.0.5
func (s *SystemMemory) Get(channel string) (ids []string, err error)
func (*SystemMemory) Set ¶ added in v1.0.5
func (s *SystemMemory) Set(id, channel string) error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.