Documentation
¶
Index ¶
- func BuildTLSConfig(certFile, keyFile string, caFiles []string, pkcs12File string) (*tls.Config, error)
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect() error
- func (c *Client) EnsureProvisioned() error
- func (c *Client) GetConfig() *Config
- func (c *Client) GetConfigFilePath() string
- func (c *Client) GetConfigVersion() int64
- func (c *Client) GetServerVersion() string
- func (c *Client) MetricsContext() context.Context
- func (c *Client) OnConnect(callback func() error)
- func (c *Client) OnTokenUpdate(callback func(token string))
- func (c *Client) RegisterHandler(messageType string, handler MessageHandler)
- func (c *Client) SendMessage(messageType string, data interface{}) error
- func (c *Client) SendMessageInterval(messageType string, data interface{}, interval time.Duration) (stop func())
- func (c *Client) SendMessageNoLog(messageType string, data interface{}) error
- func (c *Client) WasJustProvisioned() bool
- type ClientOption
- type Config
- type MessageHandler
- type ProvisioningResponse
- type TLSConfig
- type TokenResponse
- type WSMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildTLSConfig ¶ added in v1.13.0
func BuildTLSConfig(certFile, keyFile string, caFiles []string, pkcs12File string) (*tls.Config, error)
BuildTLSConfig creates a *tls.Config from the provided certificate files. Pass empty strings / nil slice for fields that are not used. Returns nil, nil when no TLS credentials are provided.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(clientType string, ID, secret string, endpoint string, pingInterval time.Duration, opts ...ClientOption) (*Client, error)
NewClient creates a new websocket client
func (*Client) EnsureProvisioned ¶ added in v1.14.0
EnsureProvisioned exchanges a provisioning key for permanent credentials synchronously, if one is configured and credentials aren't already present. Callers that need the resolved ID/Secret before Connect() runs (which only provisions lazily, in the background, on first connection attempt) should call this first.
func (*Client) GetConfigFilePath ¶ added in v1.13.0
GetConfigFilePath returns the resolved path to the config file used by this client.
func (*Client) GetConfigVersion ¶ added in v1.11.0
GetConfigVersion returns the latest config version received from server
func (*Client) GetServerVersion ¶ added in v1.8.0
func (*Client) MetricsContext ¶
MetricsContext exposes the context used for telemetry emission when a connection is active.
func (*Client) OnTokenUpdate ¶
func (*Client) RegisterHandler ¶
func (c *Client) RegisterHandler(messageType string, handler MessageHandler)
RegisterHandler registers a handler for a specific message type
func (*Client) SendMessage ¶
SendMessage sends a message through the WebSocket connection
func (*Client) SendMessageInterval ¶
func (*Client) SendMessageNoLog ¶ added in v1.8.0
SendMessage sends a message through the WebSocket connection
func (*Client) WasJustProvisioned ¶ added in v1.11.0
WasJustProvisioned reports whether the client exchanged a provisioning key for permanent credentials during the most recent connection attempt. It consumes the flag – subsequent calls return false until provisioning occurs again (which, in practice, never happens once credentials are persisted).
type ClientOption ¶
type ClientOption func(*Client)
func WithBaseURL ¶
func WithBaseURL(url string) ClientOption
WithBaseURL sets the base URL for the client
func WithConfigFile ¶ added in v1.11.0
func WithConfigFile(path string) ClientOption
WithTLSConfig sets the TLS configuration for the client
func WithTLSConfig ¶
func WithTLSConfig(config TLSConfig) ClientOption
type MessageHandler ¶
type MessageHandler func(message WSMessage)
type ProvisioningResponse ¶ added in v1.11.0
type TLSConfig ¶
type TLSConfig struct {
// New separate certificate support
ClientCertFile string
ClientKeyFile string
CAFiles []string
// Existing PKCS12 support (deprecated)
PKCS12File string
}
TLSConfig holds TLS configuration options