Documentation ¶
Index ¶
- Variables
- func ConnectionId(ctx context.Context) (id []byte)
- func LoadConnection(ctx context.Context) (conn *websocket.Conn, has bool)
- func New(options ...Option) (handler transports.MuxHandler)
- func ReleaseRequest(r *Request)
- func Send(ctx context.Context, id []byte, data any) (err error)
- func WithConnection(ctx context.Context, conn *websocket.Conn)
- type Config
- type Connection
- type Connections
- func (conns *Connections) Construct(_ services.Options) (err error)
- func (conns *Connections) Get(id []byte) (conn *websocket.Conn, has bool)
- func (conns *Connections) Name() (name string)
- func (conns *Connections) Remove(id []byte)
- func (conns *Connections) Set(conn *websocket.Conn)
- func (conns *Connections) Shutdown(_ context.Context)
- type MessageType
- type Option
- type Options
- type OriginCheckPolicyConfig
- type Registration
- type Request
- type Response
- type SendOption
- type SendOptions
- type SendParam
- type SubProtocolHandler
- type SubProtocolHandlerOptions
- type SubProtocolHandlerTask
- type WebsocketConnection
- func (conn *WebsocketConnection) DeviceId() string
- func (conn *WebsocketConnection) DeviceIp() string
- func (conn *WebsocketConnection) Header() transports.Header
- func (conn *WebsocketConnection) NextReader() (messageType MessageType, r io.Reader, err error)
- func (conn *WebsocketConnection) NextWriter(messageType MessageType) (w io.WriteCloser, err error)
- func (conn *WebsocketConnection) ReadMessage() (messageType MessageType, p []byte, err error)
- func (conn *WebsocketConnection) WriteControl(messageType MessageType, data []byte, deadline time.Time) error
- func (conn *WebsocketConnection) WriteMessage(messageType MessageType, data []byte) (err error)
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrRequestMessageIsTooLarge = fmt.Errorf("message is too large")
)
View Source
var (
ErrTooMayConnections = errors.New(http.StatusTooManyRequests, "***TOO MANY CONNECTIONS***", "fns: too may connections, try again later.")
)
Functions ¶
func ConnectionId ¶
func LoadConnection ¶ added in v1.2.1
func New ¶ added in v1.2.1
func New(options ...Option) (handler transports.MuxHandler)
func ReleaseRequest ¶ added in v1.2.1
func ReleaseRequest(r *Request)
Types ¶
type Config ¶
type Config struct { MaxConnections int `json:"maxConnections"` HandshakeTimeout string `json:"handshakeTimeout"` ReadTimeout string `json:"readTimeout"` ReadBufferSize string `json:"readBufferSize"` WriteTimeout string `json:"writeTimeout"` WriteBufferSize string `json:"writeBufferSize"` EnableCompression bool `json:"enableCompression"` MaxRequestMessageSize string `json:"maxRequestMessageSize"` OriginCheckPolicy OriginCheckPolicyConfig `json:"originCheckPolicy"` ConnectionTTL string `json:"connectionTTL"` EnableEcho bool `json:"enableEcho"` }
type Connection ¶
type Connection interface { ReadMessage() (messageType MessageType, p []byte, err error) WriteMessage(messageType MessageType, data []byte) (err error) WriteControl(messageType MessageType, data []byte, deadline time.Time) error NextWriter(messageType MessageType) (io.WriteCloser, error) SetWriteDeadline(t time.Time) error NextReader() (messageType MessageType, r io.Reader, err error) SetReadDeadline(t time.Time) error SetReadLimit(limit int64) CloseHandler() func(code int, text string) error SetCloseHandler(h func(code int, text string) error) PingHandler() func(appData []byte) error SetPingHandler(h func(appData []byte) error) PongHandler() func(appData []byte) error SetPongHandler(h func(appData []byte) error) EnableWriteCompression(enable bool) SetCompressionLevel(level int) error Subprotocol() (protocol string) Close() (err error) LocalAddr() net.Addr RemoteAddr() net.Addr }
type Connections ¶ added in v1.2.1
type Connections struct {
// contains filtered or unexported fields
}
func LoadConnections ¶ added in v1.2.1
func LoadConnections(ctx context.Context) (conns *Connections, has bool)
func (*Connections) Construct ¶ added in v1.2.1
func (conns *Connections) Construct(_ services.Options) (err error)
func (*Connections) Get ¶ added in v1.2.1
func (conns *Connections) Get(id []byte) (conn *websocket.Conn, has bool)
func (*Connections) Name ¶ added in v1.2.1
func (conns *Connections) Name() (name string)
func (*Connections) Remove ¶ added in v1.2.1
func (conns *Connections) Remove(id []byte)
func (*Connections) Set ¶ added in v1.2.1
func (conns *Connections) Set(conn *websocket.Conn)
func (*Connections) Shutdown ¶ added in v1.2.1
func (conns *Connections) Shutdown(_ context.Context)
type MessageType ¶
type MessageType int
type Option ¶ added in v1.2.1
type Option func(options *Options)
func WithRegistration ¶ added in v1.2.1
func WithRegistration(registration Registration) Option
func WithSubProtocolHandler ¶ added in v1.2.1
func WithSubProtocolHandler(handler ...SubProtocolHandler) Option
type OriginCheckPolicyConfig ¶ added in v1.2.1
type OriginCheckPolicyConfig struct { Mode string `json:"mode"` Options json.RawMessage `json:"options"` }
func (*OriginCheckPolicyConfig) Build ¶ added in v1.2.1
func (config *OriginCheckPolicyConfig) Build() (fn func(r transports.Request) bool, err error)
type Registration ¶ added in v1.2.1
type Request ¶
type Request struct { Endpoint string `json:"endpoint"` Fn string `json:"fn"` Header transports.Header `json:"header"` Payload json.RawMessage `json:"payload"` }
func AcquireRequest ¶ added in v1.2.1
func (*Request) Authorization ¶ added in v1.2.1
type SendOption ¶ added in v1.2.1
type SendOption func(options *SendOptions)
func WithEndpointId ¶ added in v1.2.1
func WithEndpointId(endpointId []byte) SendOption
type SendOptions ¶ added in v1.2.1
type SendOptions struct {
EndpointId []byte
}
type SubProtocolHandler ¶
type SubProtocolHandler interface { Name() (name string) Construct(options SubProtocolHandlerOptions) (err error) Handle(ctx context.Context, conn Connection) Close() (err error) }
type SubProtocolHandlerTask ¶
type SubProtocolHandlerTask struct {
// contains filtered or unexported fields
}
func (*SubProtocolHandlerTask) Execute ¶
func (t *SubProtocolHandlerTask) Execute(ctx context.Context)
type WebsocketConnection ¶
func (*WebsocketConnection) DeviceId ¶ added in v1.2.1
func (conn *WebsocketConnection) DeviceId() string
func (*WebsocketConnection) DeviceIp ¶ added in v1.2.1
func (conn *WebsocketConnection) DeviceIp() string
func (*WebsocketConnection) Header ¶ added in v1.2.1
func (conn *WebsocketConnection) Header() transports.Header
func (*WebsocketConnection) NextReader ¶
func (conn *WebsocketConnection) NextReader() (messageType MessageType, r io.Reader, err error)
func (*WebsocketConnection) NextWriter ¶
func (conn *WebsocketConnection) NextWriter(messageType MessageType) (w io.WriteCloser, err error)
func (*WebsocketConnection) ReadMessage ¶
func (conn *WebsocketConnection) ReadMessage() (messageType MessageType, p []byte, err error)
func (*WebsocketConnection) WriteControl ¶
func (conn *WebsocketConnection) WriteControl(messageType MessageType, data []byte, deadline time.Time) error
func (*WebsocketConnection) WriteMessage ¶
func (conn *WebsocketConnection) WriteMessage(messageType MessageType, data []byte) (err error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.