Documentation
¶
Index ¶
- Constants
- Variables
- func AppendHooks(ms *usmqtt.Server, hooks ...mqtt.Hook) error
- func AppendListeners(ms *usmqtt.Server, listeners ...listeners.Listener) error
- func BindJSON[T any](ctx Ctx) (T, error)
- func ConnectedContext(ctx context.Context) (context.Context, bool)
- func Module(opts ...di.Node) di.Node
- func SetupTopicMiddlewares(in setupTopicMiddlewaresIn)
- func SetupTopicSubscribers(in setupTopicSubscribersIn) error
- func UseAllowHook() di.Node
- func UseTCPListener() di.Node
- func UseWebsocketListener(opts ...Option) di.Node
- func WithClaims(ctx context.Context, claims Claims) context.Context
- func WithClientIdentity(ctx context.Context, identity ClientIdentity) context.Context
- func WithConnectedContext(ctx context.Context, connected context.Context) context.Context
- type Authorizer
- type Claims
- type ClientConnectContextHook
- type ClientConnectContextStore
- type ClientIdentity
- type ClientIdentityHook
- type ClientIdentityStore
- type Config
- type ConnectContextFactory
- type Ctx
- type ManagedPubSub
- type MockAuthorizer
- type MockAuthorizer_Authorize_Call
- type MockAuthorizer_Expecter
- type MockBroker
- func (_m *MockBroker) EXPECT() *MockBroker_Expecter
- func (_mock *MockBroker) Publish(topic string, payload []byte, retain bool, qos byte) error
- func (_mock *MockBroker) PublishJSON(topic string, payload any, retain bool, qos byte) error
- func (_mock *MockBroker) PublishString(topic string, payload string, retain bool, qos byte) error
- func (_mock *MockBroker) Subscribe(filter string, subscriptionId int, handler mqtt.InlineSubFn) error
- func (_mock *MockBroker) Unsubscribe(filter string, subscriptionId int) error
- type MockBroker_Expecter
- func (_e *MockBroker_Expecter) Publish(topic interface{}, payload interface{}, retain interface{}, qos interface{}) *MockBroker_Publish_Call
- func (_e *MockBroker_Expecter) PublishJSON(topic interface{}, payload interface{}, retain interface{}, qos interface{}) *MockBroker_PublishJSON_Call
- func (_e *MockBroker_Expecter) PublishString(topic interface{}, payload interface{}, retain interface{}, qos interface{}) *MockBroker_PublishString_Call
- func (_e *MockBroker_Expecter) Subscribe(filter interface{}, subscriptionId interface{}, handler interface{}) *MockBroker_Subscribe_Call
- func (_e *MockBroker_Expecter) Unsubscribe(filter interface{}, subscriptionId interface{}) *MockBroker_Unsubscribe_Call
- type MockBroker_PublishJSON_Call
- func (_c *MockBroker_PublishJSON_Call) Return(err error) *MockBroker_PublishJSON_Call
- func (_c *MockBroker_PublishJSON_Call) Run(run func(topic string, payload any, retain bool, qos byte)) *MockBroker_PublishJSON_Call
- func (_c *MockBroker_PublishJSON_Call) RunAndReturn(run func(topic string, payload any, retain bool, qos byte) error) *MockBroker_PublishJSON_Call
- type MockBroker_PublishString_Call
- func (_c *MockBroker_PublishString_Call) Return(err error) *MockBroker_PublishString_Call
- func (_c *MockBroker_PublishString_Call) Run(run func(topic string, payload string, retain bool, qos byte)) *MockBroker_PublishString_Call
- func (_c *MockBroker_PublishString_Call) RunAndReturn(run func(topic string, payload string, retain bool, qos byte) error) *MockBroker_PublishString_Call
- type MockBroker_Publish_Call
- func (_c *MockBroker_Publish_Call) Return(err error) *MockBroker_Publish_Call
- func (_c *MockBroker_Publish_Call) Run(run func(topic string, payload []byte, retain bool, qos byte)) *MockBroker_Publish_Call
- func (_c *MockBroker_Publish_Call) RunAndReturn(run func(topic string, payload []byte, retain bool, qos byte) error) *MockBroker_Publish_Call
- type MockBroker_Subscribe_Call
- func (_c *MockBroker_Subscribe_Call) Return(err error) *MockBroker_Subscribe_Call
- func (_c *MockBroker_Subscribe_Call) Run(run func(filter string, subscriptionId int, handler mqtt.InlineSubFn)) *MockBroker_Subscribe_Call
- func (_c *MockBroker_Subscribe_Call) RunAndReturn(run func(filter string, subscriptionId int, handler mqtt.InlineSubFn) error) *MockBroker_Subscribe_Call
- type MockBroker_Unsubscribe_Call
- func (_c *MockBroker_Unsubscribe_Call) Return(err error) *MockBroker_Unsubscribe_Call
- func (_c *MockBroker_Unsubscribe_Call) Run(run func(filter string, subscriptionId int)) *MockBroker_Unsubscribe_Call
- func (_c *MockBroker_Unsubscribe_Call) RunAndReturn(run func(filter string, subscriptionId int) error) *MockBroker_Unsubscribe_Call
- type MockPublisher
- func (_m *MockPublisher) EXPECT() *MockPublisher_Expecter
- func (_mock *MockPublisher) Publish(topic string, payload []byte, retain bool, qos byte) error
- func (_mock *MockPublisher) PublishJSON(topic string, payload any, retain bool, qos byte) error
- func (_mock *MockPublisher) PublishString(topic string, payload string, retain bool, qos byte) error
- type MockPublisher_Expecter
- func (_e *MockPublisher_Expecter) Publish(topic interface{}, payload interface{}, retain interface{}, qos interface{}) *MockPublisher_Publish_Call
- func (_e *MockPublisher_Expecter) PublishJSON(topic interface{}, payload interface{}, retain interface{}, qos interface{}) *MockPublisher_PublishJSON_Call
- func (_e *MockPublisher_Expecter) PublishString(topic interface{}, payload interface{}, retain interface{}, qos interface{}) *MockPublisher_PublishString_Call
- type MockPublisher_PublishJSON_Call
- func (_c *MockPublisher_PublishJSON_Call) Return(err error) *MockPublisher_PublishJSON_Call
- func (_c *MockPublisher_PublishJSON_Call) Run(run func(topic string, payload any, retain bool, qos byte)) *MockPublisher_PublishJSON_Call
- func (_c *MockPublisher_PublishJSON_Call) RunAndReturn(run func(topic string, payload any, retain bool, qos byte) error) *MockPublisher_PublishJSON_Call
- type MockPublisher_PublishString_Call
- func (_c *MockPublisher_PublishString_Call) Return(err error) *MockPublisher_PublishString_Call
- func (_c *MockPublisher_PublishString_Call) Run(run func(topic string, payload string, retain bool, qos byte)) *MockPublisher_PublishString_Call
- func (_c *MockPublisher_PublishString_Call) RunAndReturn(run func(topic string, payload string, retain bool, qos byte) error) *MockPublisher_PublishString_Call
- type MockPublisher_Publish_Call
- func (_c *MockPublisher_Publish_Call) Return(err error) *MockPublisher_Publish_Call
- func (_c *MockPublisher_Publish_Call) Run(run func(topic string, payload []byte, retain bool, qos byte)) *MockPublisher_Publish_Call
- func (_c *MockPublisher_Publish_Call) RunAndReturn(run func(topic string, payload []byte, retain bool, qos byte) error) *MockPublisher_Publish_Call
- type MockSubscriber
- type MockSubscriber_Expecter
- type MockSubscriber_Subscribe_Call
- func (_c *MockSubscriber_Subscribe_Call) Return(err error) *MockSubscriber_Subscribe_Call
- func (_c *MockSubscriber_Subscribe_Call) Run(run func(filter string, subscriptionId int, handler mqtt.InlineSubFn)) *MockSubscriber_Subscribe_Call
- func (_c *MockSubscriber_Subscribe_Call) RunAndReturn(run func(filter string, subscriptionId int, handler mqtt.InlineSubFn) error) *MockSubscriber_Subscribe_Call
- type MockSubscriber_Unsubscribe_Call
- func (_c *MockSubscriber_Unsubscribe_Call) Return(err error) *MockSubscriber_Unsubscribe_Call
- func (_c *MockSubscriber_Unsubscribe_Call) Run(run func(filter string, subscriptionId int)) *MockSubscriber_Unsubscribe_Call
- func (_c *MockSubscriber_Unsubscribe_Call) RunAndReturn(run func(filter string, subscriptionId int) error) *MockSubscriber_Unsubscribe_Call
- type Option
- type TCPListenerConfig
- type TimeoutTopicMiddlewareOption
- type TopicACLConfig
- type TopicHandler
- type TopicMiddleware
- func RecoverTopicMiddleware(log *zap.Logger) TopicMiddleware
- func TimeoutTopicMiddleware(timeout time.Duration, opts ...TimeoutTopicMiddlewareOption) TopicMiddleware
- func UseClientIdentityContext(store *ClientIdentityStore) TopicMiddleware
- func UseConnectedContext(store *ClientConnectContextStore) TopicMiddleware
- type TopicRegistrar
- type Websocket
- func (l *Websocket) Address() string
- func (l *Websocket) Close(closeClients listeners.CloseFn)
- func (l *Websocket) Handle(r fiber.Router)
- func (l *Websocket) Handler(w http.ResponseWriter, r *http.Request)
- func (l *Websocket) ID() string
- func (l *Websocket) Init(log *slog.Logger) error
- func (l *Websocket) Protocol() string
- func (l *Websocket) Serve(establish listeners.EstablishFn)
- type WebsocketListenerConfig
Constants ¶
const TypeWS = "ws"
Variables ¶
var ( // ErrInvalidMessage indicates that a message payload was not valid. ErrInvalidMessage = errors.New("message type not binary") )
var ErrInvalidTopicRegistrationArgs = errors.New("realtime: invalid topic registration args")
var ErrTopicClientDisconnectedByHandler = errors.New("realtime: client disconnected by topic handler")
var ErrTopicClientRejectedByHandler = errors.New("realtime: client rejected by topic handler")
var ErrTopicCtxNoClient = errors.New("realtime: topic context has no client")
var ErrTopicCtxNoPublisher = errors.New("realtime: topic context has no publisher")
var ErrTopicHandlerPanic = errors.New("realtime: panic in topic handler")
var ErrTopicHandlerTimeout = errors.New("realtime: topic handler timed out")
var ErrTopicNotAllowed = errors.New("realtime: topic is not allowed by acl")
var ErrTopicRegistrarStopped = errors.New("realtime: topic registrar is stopped")
var HooksGroupName = "mqtt_hooks"
var ListenersGroupName = "mqtt_listeners"
var SubscribersGroupName = "mqtt_subscribers"
var TopicMiddlewaresGroupName = "mqtt_topic_middlewares"
Functions ¶
func AppendListeners ¶
func ConnectedContext ¶ added in v1.9.0
func SetupTopicMiddlewares ¶ added in v1.9.0
func SetupTopicMiddlewares(in setupTopicMiddlewaresIn)
func SetupTopicSubscribers ¶ added in v1.9.0
func SetupTopicSubscribers(in setupTopicSubscribersIn) error
func UseAllowHook ¶ added in v1.4.0
func UseTCPListener ¶ added in v1.8.0
func UseWebsocketListener ¶ added in v1.4.0
func WithClaims ¶ added in v1.9.0
func WithClientIdentity ¶ added in v1.9.0
func WithClientIdentity(ctx context.Context, identity ClientIdentity) context.Context
Types ¶
type Authorizer ¶
func NewAuthorizer ¶
func NewAuthorizer(logger *zap.Logger) Authorizer
type ClientConnectContextHook ¶ added in v1.9.0
func NewClientConnectContextHook ¶ added in v1.9.0
func NewClientConnectContextHook(in newClientConnectContextHookIn) *ClientConnectContextHook
func (*ClientConnectContextHook) ID ¶ added in v1.9.0
func (h *ClientConnectContextHook) ID() string
func (*ClientConnectContextHook) OnDisconnect ¶ added in v1.9.0
func (h *ClientConnectContextHook) OnDisconnect(cl *mqtt.Client, _ error, _ bool)
func (*ClientConnectContextHook) Provides ¶ added in v1.9.0
func (h *ClientConnectContextHook) Provides(b byte) bool
type ClientConnectContextStore ¶ added in v1.9.0
type ClientConnectContextStore struct {
// contains filtered or unexported fields
}
func NewClientConnectContextStore ¶ added in v1.9.0
func NewClientConnectContextStore() *ClientConnectContextStore
func (*ClientConnectContextStore) Delete ¶ added in v1.9.0
func (s *ClientConnectContextStore) Delete(clientID string)
type ClientIdentity ¶ added in v1.9.0
func IdentityFromContext ¶ added in v1.9.0
func IdentityFromContext(ctx context.Context) (ClientIdentity, bool)
type ClientIdentityHook ¶ added in v1.9.0
func NewClientIdentityHook ¶ added in v1.9.0
func NewClientIdentityHook(store *ClientIdentityStore) *ClientIdentityHook
func (*ClientIdentityHook) ID ¶ added in v1.9.0
func (h *ClientIdentityHook) ID() string
func (*ClientIdentityHook) OnDisconnect ¶ added in v1.9.0
func (h *ClientIdentityHook) OnDisconnect(cl *mqtt.Client, _ error, _ bool)
func (*ClientIdentityHook) Provides ¶ added in v1.9.0
func (h *ClientIdentityHook) Provides(b byte) bool
type ClientIdentityStore ¶ added in v1.9.0
type ClientIdentityStore struct {
// contains filtered or unexported fields
}
func NewClientIdentityStore ¶ added in v1.9.0
func NewClientIdentityStore() *ClientIdentityStore
func (*ClientIdentityStore) Delete ¶ added in v1.9.0
func (s *ClientIdentityStore) Delete(clientID string)
func (*ClientIdentityStore) Get ¶ added in v1.9.0
func (s *ClientIdentityStore) Get(clientID string) (ClientIdentity, bool)
func (*ClientIdentityStore) Set ¶ added in v1.9.0
func (s *ClientIdentityStore) Set(clientID string, identity ClientIdentity)
type Config ¶ added in v1.8.0
type Config struct {
TCPListener TCPListenerConfig `mapstructure:"tcp_listener"`
WebsocketListener WebsocketListenerConfig `mapstructure:"websocket_listener"`
TopicACL TopicACLConfig `mapstructure:"topic_acl"`
}
type ConnectContextFactory ¶ added in v1.9.0
type Ctx ¶ added in v1.9.0
type Ctx interface {
context.Context
Client() *mqtt.Client
ClientID() string
Username() string
Subscription() packets.Subscription
Packet() packets.Packet
Filter() string
Topic() string
Payload() []byte
DecodeJSON(v any) error
BindJSON(v any) error
Publish(topic string, payload []byte, retain bool, qos byte) error
PublishJSON(topic string, payload any, retain bool, qos byte) error
PublishString(topic string, payload string, retain bool, qos byte) error
Context() context.Context
SetContext(ctx context.Context)
Identity() (ClientIdentity, bool)
Disconnect() error
Reject(reason string) error
}
type ManagedPubSub ¶ added in v1.9.0
type ManagedPubSub struct {
// contains filtered or unexported fields
}
func NewManagedPubSub ¶ added in v1.9.0
func NewManagedPubSub(in newManagedPubSubIn) *ManagedPubSub
func (*ManagedPubSub) Topic ¶ added in v1.9.0
func (m *ManagedPubSub) Topic(filter string, args ...any) error
func (*ManagedPubSub) Use ¶ added in v1.9.0
func (m *ManagedPubSub) Use(middlewares ...TopicMiddleware)
type MockAuthorizer ¶ added in v1.2.0
MockAuthorizer is an autogenerated mock type for the Authorizer type
func NewMockAuthorizer ¶ added in v1.2.0
func NewMockAuthorizer(t interface {
mock.TestingT
Cleanup(func())
}) *MockAuthorizer
NewMockAuthorizer creates a new instance of MockAuthorizer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockAuthorizer) Authorize ¶ added in v1.2.0
func (_mock *MockAuthorizer) Authorize() fiber.Handler
Authorize provides a mock function for the type MockAuthorizer
func (*MockAuthorizer) EXPECT ¶ added in v1.2.0
func (_m *MockAuthorizer) EXPECT() *MockAuthorizer_Expecter
type MockAuthorizer_Authorize_Call ¶ added in v1.2.0
MockAuthorizer_Authorize_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Authorize'
func (*MockAuthorizer_Authorize_Call) Return ¶ added in v1.2.0
func (_c *MockAuthorizer_Authorize_Call) Return(v fiber.Handler) *MockAuthorizer_Authorize_Call
func (*MockAuthorizer_Authorize_Call) Run ¶ added in v1.2.0
func (_c *MockAuthorizer_Authorize_Call) Run(run func()) *MockAuthorizer_Authorize_Call
func (*MockAuthorizer_Authorize_Call) RunAndReturn ¶ added in v1.2.0
func (_c *MockAuthorizer_Authorize_Call) RunAndReturn(run func() fiber.Handler) *MockAuthorizer_Authorize_Call
type MockAuthorizer_Expecter ¶ added in v1.2.0
type MockAuthorizer_Expecter struct {
// contains filtered or unexported fields
}
func (*MockAuthorizer_Expecter) Authorize ¶ added in v1.2.0
func (_e *MockAuthorizer_Expecter) Authorize() *MockAuthorizer_Authorize_Call
Authorize is a helper method to define mock.On call
type MockBroker ¶ added in v1.2.0
MockBroker is an autogenerated mock type for the Broker type
func NewMockBroker ¶ added in v1.2.0
func NewMockBroker(t interface {
mock.TestingT
Cleanup(func())
}) *MockBroker
NewMockBroker creates a new instance of MockBroker. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockBroker) EXPECT ¶ added in v1.2.0
func (_m *MockBroker) EXPECT() *MockBroker_Expecter
func (*MockBroker) Publish ¶ added in v1.2.0
Publish provides a mock function for the type MockBroker
func (*MockBroker) PublishJSON ¶ added in v1.9.0
PublishJSON provides a mock function for the type MockBroker
func (*MockBroker) PublishString ¶ added in v1.9.0
PublishString provides a mock function for the type MockBroker
func (*MockBroker) Subscribe ¶ added in v1.2.0
func (_mock *MockBroker) Subscribe(filter string, subscriptionId int, handler mqtt.InlineSubFn) error
Subscribe provides a mock function for the type MockBroker
func (*MockBroker) Unsubscribe ¶ added in v1.2.0
func (_mock *MockBroker) Unsubscribe(filter string, subscriptionId int) error
Unsubscribe provides a mock function for the type MockBroker
type MockBroker_Expecter ¶ added in v1.2.0
type MockBroker_Expecter struct {
// contains filtered or unexported fields
}
func (*MockBroker_Expecter) Publish ¶ added in v1.2.0
func (_e *MockBroker_Expecter) Publish(topic interface{}, payload interface{}, retain interface{}, qos interface{}) *MockBroker_Publish_Call
Publish is a helper method to define mock.On call
- topic string
- payload []byte
- retain bool
- qos byte
func (*MockBroker_Expecter) PublishJSON ¶ added in v1.9.0
func (_e *MockBroker_Expecter) PublishJSON(topic interface{}, payload interface{}, retain interface{}, qos interface{}) *MockBroker_PublishJSON_Call
PublishJSON is a helper method to define mock.On call
- topic string
- payload any
- retain bool
- qos byte
func (*MockBroker_Expecter) PublishString ¶ added in v1.9.0
func (_e *MockBroker_Expecter) PublishString(topic interface{}, payload interface{}, retain interface{}, qos interface{}) *MockBroker_PublishString_Call
PublishString is a helper method to define mock.On call
- topic string
- payload string
- retain bool
- qos byte
func (*MockBroker_Expecter) Subscribe ¶ added in v1.2.0
func (_e *MockBroker_Expecter) Subscribe(filter interface{}, subscriptionId interface{}, handler interface{}) *MockBroker_Subscribe_Call
Subscribe is a helper method to define mock.On call
- filter string
- subscriptionId int
- handler mqtt.InlineSubFn
func (*MockBroker_Expecter) Unsubscribe ¶ added in v1.2.0
func (_e *MockBroker_Expecter) Unsubscribe(filter interface{}, subscriptionId interface{}) *MockBroker_Unsubscribe_Call
Unsubscribe is a helper method to define mock.On call
- filter string
- subscriptionId int
type MockBroker_PublishJSON_Call ¶ added in v1.9.0
MockBroker_PublishJSON_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishJSON'
func (*MockBroker_PublishJSON_Call) Return ¶ added in v1.9.0
func (_c *MockBroker_PublishJSON_Call) Return(err error) *MockBroker_PublishJSON_Call
func (*MockBroker_PublishJSON_Call) Run ¶ added in v1.9.0
func (_c *MockBroker_PublishJSON_Call) Run(run func(topic string, payload any, retain bool, qos byte)) *MockBroker_PublishJSON_Call
func (*MockBroker_PublishJSON_Call) RunAndReturn ¶ added in v1.9.0
func (_c *MockBroker_PublishJSON_Call) RunAndReturn(run func(topic string, payload any, retain bool, qos byte) error) *MockBroker_PublishJSON_Call
type MockBroker_PublishString_Call ¶ added in v1.9.0
MockBroker_PublishString_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishString'
func (*MockBroker_PublishString_Call) Return ¶ added in v1.9.0
func (_c *MockBroker_PublishString_Call) Return(err error) *MockBroker_PublishString_Call
func (*MockBroker_PublishString_Call) Run ¶ added in v1.9.0
func (_c *MockBroker_PublishString_Call) Run(run func(topic string, payload string, retain bool, qos byte)) *MockBroker_PublishString_Call
func (*MockBroker_PublishString_Call) RunAndReturn ¶ added in v1.9.0
func (_c *MockBroker_PublishString_Call) RunAndReturn(run func(topic string, payload string, retain bool, qos byte) error) *MockBroker_PublishString_Call
type MockBroker_Publish_Call ¶ added in v1.2.0
MockBroker_Publish_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Publish'
func (*MockBroker_Publish_Call) Return ¶ added in v1.2.0
func (_c *MockBroker_Publish_Call) Return(err error) *MockBroker_Publish_Call
func (*MockBroker_Publish_Call) Run ¶ added in v1.2.0
func (_c *MockBroker_Publish_Call) Run(run func(topic string, payload []byte, retain bool, qos byte)) *MockBroker_Publish_Call
func (*MockBroker_Publish_Call) RunAndReturn ¶ added in v1.2.0
func (_c *MockBroker_Publish_Call) RunAndReturn(run func(topic string, payload []byte, retain bool, qos byte) error) *MockBroker_Publish_Call
type MockBroker_Subscribe_Call ¶ added in v1.2.0
MockBroker_Subscribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Subscribe'
func (*MockBroker_Subscribe_Call) Return ¶ added in v1.2.0
func (_c *MockBroker_Subscribe_Call) Return(err error) *MockBroker_Subscribe_Call
func (*MockBroker_Subscribe_Call) Run ¶ added in v1.2.0
func (_c *MockBroker_Subscribe_Call) Run(run func(filter string, subscriptionId int, handler mqtt.InlineSubFn)) *MockBroker_Subscribe_Call
func (*MockBroker_Subscribe_Call) RunAndReturn ¶ added in v1.2.0
func (_c *MockBroker_Subscribe_Call) RunAndReturn(run func(filter string, subscriptionId int, handler mqtt.InlineSubFn) error) *MockBroker_Subscribe_Call
type MockBroker_Unsubscribe_Call ¶ added in v1.2.0
MockBroker_Unsubscribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Unsubscribe'
func (*MockBroker_Unsubscribe_Call) Return ¶ added in v1.2.0
func (_c *MockBroker_Unsubscribe_Call) Return(err error) *MockBroker_Unsubscribe_Call
func (*MockBroker_Unsubscribe_Call) Run ¶ added in v1.2.0
func (_c *MockBroker_Unsubscribe_Call) Run(run func(filter string, subscriptionId int)) *MockBroker_Unsubscribe_Call
func (*MockBroker_Unsubscribe_Call) RunAndReturn ¶ added in v1.2.0
func (_c *MockBroker_Unsubscribe_Call) RunAndReturn(run func(filter string, subscriptionId int) error) *MockBroker_Unsubscribe_Call
type MockPublisher ¶ added in v1.2.0
MockPublisher is an autogenerated mock type for the Publisher type
func NewMockPublisher ¶ added in v1.2.0
func NewMockPublisher(t interface {
mock.TestingT
Cleanup(func())
}) *MockPublisher
NewMockPublisher creates a new instance of MockPublisher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockPublisher) EXPECT ¶ added in v1.2.0
func (_m *MockPublisher) EXPECT() *MockPublisher_Expecter
func (*MockPublisher) Publish ¶ added in v1.2.0
Publish provides a mock function for the type MockPublisher
func (*MockPublisher) PublishJSON ¶ added in v1.9.0
PublishJSON provides a mock function for the type MockPublisher
func (*MockPublisher) PublishString ¶ added in v1.9.0
func (_mock *MockPublisher) PublishString(topic string, payload string, retain bool, qos byte) error
PublishString provides a mock function for the type MockPublisher
type MockPublisher_Expecter ¶ added in v1.2.0
type MockPublisher_Expecter struct {
// contains filtered or unexported fields
}
func (*MockPublisher_Expecter) Publish ¶ added in v1.2.0
func (_e *MockPublisher_Expecter) Publish(topic interface{}, payload interface{}, retain interface{}, qos interface{}) *MockPublisher_Publish_Call
Publish is a helper method to define mock.On call
- topic string
- payload []byte
- retain bool
- qos byte
func (*MockPublisher_Expecter) PublishJSON ¶ added in v1.9.0
func (_e *MockPublisher_Expecter) PublishJSON(topic interface{}, payload interface{}, retain interface{}, qos interface{}) *MockPublisher_PublishJSON_Call
PublishJSON is a helper method to define mock.On call
- topic string
- payload any
- retain bool
- qos byte
func (*MockPublisher_Expecter) PublishString ¶ added in v1.9.0
func (_e *MockPublisher_Expecter) PublishString(topic interface{}, payload interface{}, retain interface{}, qos interface{}) *MockPublisher_PublishString_Call
PublishString is a helper method to define mock.On call
- topic string
- payload string
- retain bool
- qos byte
type MockPublisher_PublishJSON_Call ¶ added in v1.9.0
MockPublisher_PublishJSON_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishJSON'
func (*MockPublisher_PublishJSON_Call) Return ¶ added in v1.9.0
func (_c *MockPublisher_PublishJSON_Call) Return(err error) *MockPublisher_PublishJSON_Call
func (*MockPublisher_PublishJSON_Call) Run ¶ added in v1.9.0
func (_c *MockPublisher_PublishJSON_Call) Run(run func(topic string, payload any, retain bool, qos byte)) *MockPublisher_PublishJSON_Call
func (*MockPublisher_PublishJSON_Call) RunAndReturn ¶ added in v1.9.0
func (_c *MockPublisher_PublishJSON_Call) RunAndReturn(run func(topic string, payload any, retain bool, qos byte) error) *MockPublisher_PublishJSON_Call
type MockPublisher_PublishString_Call ¶ added in v1.9.0
MockPublisher_PublishString_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishString'
func (*MockPublisher_PublishString_Call) Return ¶ added in v1.9.0
func (_c *MockPublisher_PublishString_Call) Return(err error) *MockPublisher_PublishString_Call
func (*MockPublisher_PublishString_Call) Run ¶ added in v1.9.0
func (_c *MockPublisher_PublishString_Call) Run(run func(topic string, payload string, retain bool, qos byte)) *MockPublisher_PublishString_Call
func (*MockPublisher_PublishString_Call) RunAndReturn ¶ added in v1.9.0
func (_c *MockPublisher_PublishString_Call) RunAndReturn(run func(topic string, payload string, retain bool, qos byte) error) *MockPublisher_PublishString_Call
type MockPublisher_Publish_Call ¶ added in v1.2.0
MockPublisher_Publish_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Publish'
func (*MockPublisher_Publish_Call) Return ¶ added in v1.2.0
func (_c *MockPublisher_Publish_Call) Return(err error) *MockPublisher_Publish_Call
func (*MockPublisher_Publish_Call) Run ¶ added in v1.2.0
func (_c *MockPublisher_Publish_Call) Run(run func(topic string, payload []byte, retain bool, qos byte)) *MockPublisher_Publish_Call
func (*MockPublisher_Publish_Call) RunAndReturn ¶ added in v1.2.0
func (_c *MockPublisher_Publish_Call) RunAndReturn(run func(topic string, payload []byte, retain bool, qos byte) error) *MockPublisher_Publish_Call
type MockSubscriber ¶ added in v1.2.0
MockSubscriber is an autogenerated mock type for the Subscriber type
func NewMockSubscriber ¶ added in v1.2.0
func NewMockSubscriber(t interface {
mock.TestingT
Cleanup(func())
}) *MockSubscriber
NewMockSubscriber creates a new instance of MockSubscriber. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockSubscriber) EXPECT ¶ added in v1.2.0
func (_m *MockSubscriber) EXPECT() *MockSubscriber_Expecter
func (*MockSubscriber) Subscribe ¶ added in v1.2.0
func (_mock *MockSubscriber) Subscribe(filter string, subscriptionId int, handler mqtt.InlineSubFn) error
Subscribe provides a mock function for the type MockSubscriber
func (*MockSubscriber) Unsubscribe ¶ added in v1.2.0
func (_mock *MockSubscriber) Unsubscribe(filter string, subscriptionId int) error
Unsubscribe provides a mock function for the type MockSubscriber
type MockSubscriber_Expecter ¶ added in v1.2.0
type MockSubscriber_Expecter struct {
// contains filtered or unexported fields
}
func (*MockSubscriber_Expecter) Subscribe ¶ added in v1.2.0
func (_e *MockSubscriber_Expecter) Subscribe(filter interface{}, subscriptionId interface{}, handler interface{}) *MockSubscriber_Subscribe_Call
Subscribe is a helper method to define mock.On call
- filter string
- subscriptionId int
- handler mqtt.InlineSubFn
func (*MockSubscriber_Expecter) Unsubscribe ¶ added in v1.2.0
func (_e *MockSubscriber_Expecter) Unsubscribe(filter interface{}, subscriptionId interface{}) *MockSubscriber_Unsubscribe_Call
Unsubscribe is a helper method to define mock.On call
- filter string
- subscriptionId int
type MockSubscriber_Subscribe_Call ¶ added in v1.2.0
MockSubscriber_Subscribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Subscribe'
func (*MockSubscriber_Subscribe_Call) Return ¶ added in v1.2.0
func (_c *MockSubscriber_Subscribe_Call) Return(err error) *MockSubscriber_Subscribe_Call
func (*MockSubscriber_Subscribe_Call) Run ¶ added in v1.2.0
func (_c *MockSubscriber_Subscribe_Call) Run(run func(filter string, subscriptionId int, handler mqtt.InlineSubFn)) *MockSubscriber_Subscribe_Call
func (*MockSubscriber_Subscribe_Call) RunAndReturn ¶ added in v1.2.0
func (_c *MockSubscriber_Subscribe_Call) RunAndReturn(run func(filter string, subscriptionId int, handler mqtt.InlineSubFn) error) *MockSubscriber_Subscribe_Call
type MockSubscriber_Unsubscribe_Call ¶ added in v1.2.0
MockSubscriber_Unsubscribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Unsubscribe'
func (*MockSubscriber_Unsubscribe_Call) Return ¶ added in v1.2.0
func (_c *MockSubscriber_Unsubscribe_Call) Return(err error) *MockSubscriber_Unsubscribe_Call
func (*MockSubscriber_Unsubscribe_Call) Run ¶ added in v1.2.0
func (_c *MockSubscriber_Unsubscribe_Call) Run(run func(filter string, subscriptionId int)) *MockSubscriber_Unsubscribe_Call
func (*MockSubscriber_Unsubscribe_Call) RunAndReturn ¶ added in v1.2.0
func (_c *MockSubscriber_Unsubscribe_Call) RunAndReturn(run func(filter string, subscriptionId int) error) *MockSubscriber_Unsubscribe_Call
type Option ¶ added in v1.2.0
type Option func(*Websocket)
Option customizes a Websocket instance.
func WithAuthorizer ¶ added in v1.2.0
func WithAuthorizer(authorizer Authorizer) Option
WithAuthorizer sets the authorizer for the websocket handler.
func WithUpgrader ¶ added in v1.2.0
WithUpgrader sets the websocket upgrader.
type TCPListenerConfig ¶ added in v1.8.0
type TimeoutTopicMiddlewareOption ¶ added in v1.9.0
type TimeoutTopicMiddlewareOption func(*timeoutTopicMiddlewareConfig)
func WithTimeoutDisconnect ¶ added in v1.9.0
func WithTimeoutDisconnect() TimeoutTopicMiddlewareOption
type TopicACLConfig ¶ added in v1.9.0
type TopicHandler ¶ added in v1.9.0
type TopicMiddleware ¶ added in v1.9.0
type TopicMiddleware func(next TopicHandler) TopicHandler
func RecoverTopicMiddleware ¶ added in v1.9.0
func RecoverTopicMiddleware(log *zap.Logger) TopicMiddleware
func TimeoutTopicMiddleware ¶ added in v1.9.0
func TimeoutTopicMiddleware(timeout time.Duration, opts ...TimeoutTopicMiddlewareOption) TopicMiddleware
func UseClientIdentityContext ¶ added in v1.9.0
func UseClientIdentityContext(store *ClientIdentityStore) TopicMiddleware
func UseConnectedContext ¶ added in v1.9.0
func UseConnectedContext(store *ClientConnectContextStore) TopicMiddleware
type TopicRegistrar ¶ added in v1.9.0
type TopicRegistrar interface {
Use(middlewares ...TopicMiddleware)
Topic(filter string, args ...any) error
}
type Websocket ¶
type Websocket struct {
sync.RWMutex
Id string // the internal id of the listener
App fiber.Router // the fiber router to register the websocket handler on
Authorizer Authorizer
Path string
Log *slog.Logger // server logging
EstablishFn listeners.EstablishFn // the server's establish connection handler
Upgrader *websocket.Upgrader // upgrade the incoming http/tcp connection to a websocket compliant connection.
}
Websocket is a listener for establishing websocket connections.
func NewWebsocket ¶
func NewWebsocket(app fiber.Router, authorizer Authorizer) *Websocket
NewWebsocket initializes and returns a new Websocket listener, listening on an address.
func NewWebsocketWithOptions ¶ added in v1.2.0
NewWebsocketWithOptions initializes a Websocket with defaults and applies options.
func (*Websocket) Handler ¶ added in v1.2.0
func (l *Websocket) Handler(w http.ResponseWriter, r *http.Request)
Handler upgrades and handles an incoming websocket connection.
func (*Websocket) Serve ¶
func (l *Websocket) Serve(establish listeners.EstablishFn)
Serve starts waiting for new Websocket connections, and calls the connection establishment callback for any received.