Documentation
¶
Index ¶
- Constants
- func ConvertMapToString(v any) (string, error)
- func ConvertSliceToString(elem []string) string
- func ConvertValueIntoType[T any](v interface{}, checkPointer bool) (T, bool)
- func ExtractAnyMap(m map[string]interface{}, key string, coerce bool) (map[string]interface{}, bool, error)
- func ExtractAnySlice(m map[string]interface{}, key string, coerce bool) ([]interface{}, bool, error)
- func ExtractInt64Map(m map[string]interface{}, key string, coerce bool) (map[string]int64, bool, error)
- func ExtractInt64Slice(m map[string]interface{}, key string, coerce bool) ([]int64, bool, error)
- func ExtractMap[T any](m map[string]interface{}, key string, coerce bool, ...) (map[string]T, bool, error)
- func ExtractSlice[T any](m map[string]interface{}, key string, coerce bool, ...) ([]T, bool, error)
- func ExtractStringMap(m map[string]interface{}, key string, coerce bool) (map[string]string, bool, error)
- func ExtractStringSlice(m map[string]interface{}, key string, coerce bool) ([]string, bool, error)
- func ExtractUint64Map(m map[string]interface{}, key string, coerce bool) (map[string]uint64, bool, error)
- func ExtractUint64Slice(m map[string]interface{}, key string, coerce bool) ([]uint64, bool, error)
- func ExtractValue[T any](m map[string]interface{}, key string) (T, bool, error)
- func SplitMessageIntoMap(s string) (map[string]interface{}, error)
- type ConnectionManager
- type DefaultConnectionManagerImpl
- type LegacyCommand
- type Message
- type MissingFieldError
- type NewMessageFromMap
- type NewMessageFromMapFunc
- type WSConnection
- func (c *WSConnection) Close(code int, reason string) error
- func (c *WSConnection) DefaultCloseHandler(code int, reason string) error
- func (c *WSConnection) DefaultPongHandler(text string) error
- func (c *WSConnection) Dial(url string, headers http.Header) (*websocket.Conn, error)
- func (c *WSConnection) GetData(key string) interface{}
- func (c *WSConnection) GetStatus() string
- func (c *WSConnection) Lock(location string)
- func (c *WSConnection) SetStatus(status string)
- func (c *WSConnection) Unlock(location string)
- type WSConnectionMessageHandler
- type WSConnectionOption
- func WithEnableAutoReconnect() WSConnectionOption
- func WithMaxReconnectAttempts(maxReconnectAttempts int) WSConnectionOption
- func WithMessageHandler(handler WSConnectionMessageHandler) WSConnectionOption
- func WithScheme(scheme string) WSConnectionOption
- func WithStatusHandler(handler WSConnectionStatusHandler) WSConnectionOption
- func WithToken(token string) WSConnectionOption
- type WSConnectionStatusHandler
Constants ¶
View Source
const ( Disconnected = "Disconnected" Connecting = "Connecting" Connected = "Connected" Reconnecting = "Reconnecting" Closed = "Closed" )
Variables ¶
This section is empty.
Functions ¶
func ConvertMapToString ¶
func ConvertSliceToString ¶
func ConvertValueIntoType ¶
ConvertValueIntoType attempts to convert an interface{} to a value of type T.
Parameters: - v: the input value of any type. - checkPointer: if true, allows de-referencing if v is a *T.
func ExtractAnyMap ¶
func ExtractAnySlice ¶
func ExtractInt64Map ¶
func ExtractInt64Slice ¶
func ExtractMap ¶
func ExtractSlice ¶
func ExtractStringMap ¶
func ExtractStringSlice ¶
func ExtractUint64Map ¶
func ExtractUint64Slice ¶
func SplitMessageIntoMap ¶
Types ¶
type ConnectionManager ¶
type ConnectionManager interface { Close() error Get() *WSConnection Save(wsConnection *WSConnection) }
type DefaultConnectionManagerImpl ¶
type DefaultConnectionManagerImpl struct {
// contains filtered or unexported fields
}
func (*DefaultConnectionManagerImpl) Close ¶
func (m *DefaultConnectionManagerImpl) Close() error
func (*DefaultConnectionManagerImpl) Get ¶
func (m *DefaultConnectionManagerImpl) Get() *WSConnection
func (*DefaultConnectionManagerImpl) Save ¶
func (m *DefaultConnectionManagerImpl) Save(conn *WSConnection)
type LegacyCommand ¶
type MissingFieldError ¶
func NewMissingFieldError ¶
func NewMissingFieldError(goField, goType, jsonField, structName string) MissingFieldError
func (MissingFieldError) Error ¶
func (e MissingFieldError) Error() string
type NewMessageFromMap ¶
type NewMessageFromMap map[string]NewMessageFromMapFunc
type NewMessageFromMapFunc ¶
func WrapNewMessageFromMapFunc ¶
func WrapNewMessageFromMapFunc[T any](fn func(map[string]interface{}) (*T, error)) NewMessageFromMapFunc
type WSConnection ¶
type WSConnection struct { Conn *websocket.Conn Mu sync.RWMutex MuStatus sync.RWMutex Header http.Header Data map[string]interface{} Meta map[string]interface{} EnableAutoReconnect bool MaxReconnectAttempts int StatusHandler WSConnectionStatusHandler MessageHandler WSConnectionMessageHandler // contains filtered or unexported fields }
func NewWSConnection ¶
func NewWSConnection( configRepo repository.ConfigRepository, tokenRepo repository.TokenRepository, options ...WSConnectionOption, ) (*WSConnection, error)
func (*WSConnection) DefaultCloseHandler ¶
func (c *WSConnection) DefaultCloseHandler(code int, reason string) error
func (*WSConnection) DefaultPongHandler ¶
func (c *WSConnection) DefaultPongHandler(text string) error
func (*WSConnection) GetData ¶
func (c *WSConnection) GetData(key string) interface{}
func (*WSConnection) GetStatus ¶
func (c *WSConnection) GetStatus() string
func (*WSConnection) Lock ¶
func (c *WSConnection) Lock(location string)
func (*WSConnection) SetStatus ¶
func (c *WSConnection) SetStatus(status string)
func (*WSConnection) Unlock ¶
func (c *WSConnection) Unlock(location string)
type WSConnectionMessageHandler ¶
type WSConnectionMessageHandler func(msg []byte)
type WSConnectionOption ¶
type WSConnectionOption func(wsConn *WSConnection) error
func WithEnableAutoReconnect ¶
func WithEnableAutoReconnect() WSConnectionOption
func WithMaxReconnectAttempts ¶
func WithMaxReconnectAttempts(maxReconnectAttempts int) WSConnectionOption
func WithMessageHandler ¶
func WithMessageHandler(handler WSConnectionMessageHandler) WSConnectionOption
func WithScheme ¶
func WithScheme(scheme string) WSConnectionOption
func WithStatusHandler ¶
func WithStatusHandler(handler WSConnectionStatusHandler) WSConnectionOption
func WithToken ¶
func WithToken(token string) WSConnectionOption
type WSConnectionStatusHandler ¶
type WSConnectionStatusHandler func(status string)
Click to show internal directories.
Click to hide internal directories.