Documentation
¶
Index ¶
Constants ¶
View Source
const ( PingTopic = "snapp/ping" DisconnectTimeout = 250 )
View Source
const ( Namespace = "mqtt_blackbox_exporter" Subsystem = "client" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Client mqtt.Client Logger *zap.Logger Tracer trace.Tracer Metrics Metrics Cache *cache.Cache QoS int Retained bool IsSubscribe bool }
Client wraps mqtt client for handling publishing and subscribing.
func New ¶
func New(ctx context.Context, cfg Config, logger *zap.Logger, tracer trace.Tracer, cache *cache.Cache, isSubscribe bool, ) *Client
New creates a new mqtt client with given configuration. isSubscribe for ping message. nolint: funlen
func (*Client) Disconnect ¶
func (c *Client) Disconnect()
func (*Client) OnConnectHandler ¶
func (*Client) OnConnectionLostHandler ¶
type Config ¶
type Config struct { URL string `json:"url,omitempty" koanf:"url"` ClientID string `json:"client_id,omitempty" koanf:"clientid"` Username string `json:"username,omitempty" koanf:"username"` Password string `json:"password,omitempty" koanf:"password"` KeepAlive time.Duration `json:"keep_alive,omitempty" koanf:"keepalive"` PingTimeout time.Duration `json:"ping_timeout,omitempty" koanf:"ping_timeout"` AutoReconnect bool `json:"auto_reconnect,omitempty" koanf:"auto_reconnect"` QoS int `json:"qo_s,omitempty" koanf:"qos"` Retained bool `json:"retained,omitempty" koanf:"retained"` }
type Metrics ¶
type Metrics struct { ConnectionErrors prometheus.Counter PublishErrors prometheus.Counter Pings prometheus.Counter Pongs prometheus.Counter PingDuration prometheus.Histogram }
Metrics has all the client metrics.
func NewMetrics ¶
func NewMetrics() Metrics
Click to show internal directories.
Click to hide internal directories.