Documentation
¶
Index ¶
- Constants
- Variables
- func SetLogger(log logger.Logger)
- type ActionType
- type ClientSubscription
- type ConnectionOptions
- type Hub
- type Message
- type Notification2Client
- func (c *Notification2Client) Close() error
- func (c *Notification2Client) Connect() error
- func (c *Notification2Client) Endpoint() string
- func (c *Notification2Client) IsConnected() bool
- func (c *Notification2Client) Register(pattern string, out chan<- Message)
- func (c *Notification2Client) SendMessageAck(messageIdentifier []byte) error
- func (c *Notification2Client) URL() string
- func (c *Notification2Client) Unsubscribe() error
- type Subscription
Constants ¶
View Source
const ( SourceWildcard = "*" ActionWildcard = "*" )
View Source
const ( // MaximumRetryInterval is the maximum interval (in seconds) between reconnection attempts MaximumRetryInterval int64 = 300 // MinimumRetryInterval is the minimum interval (in seconds) between reconnection attempts MinimumRetryInterval int64 = 5 // RetryBackoffFactor is the backoff factor applied to the retry interval for every unsuccessful reconnection attempt. // i.e. the next retry interval is calculated as follows // interval = MinimumRetryInterval // interval = Min(MaximumRetryInterval, interval * RetryBackoffFactor) RetryBackoffFactor float64 = 2 )
Variables ¶
View Source
var Logger logger.Logger
Functions ¶
Types ¶
type ActionType ¶
type ActionType string
var ActionTypeCreate ActionType = "CREATE"
var ActionTypeDelete ActionType = "DELETE"
var ActionTypeUpdate ActionType = "UPDATE"
type ClientSubscription ¶
type ConnectionOptions ¶
type ConnectionOptions struct { // Send pings to client with this interval. Must be less than pongWait. PingInterval time.Duration PongWait time.Duration WriteWait time.Duration Insecure bool }
func (*ConnectionOptions) GetPingDuration ¶
func (o *ConnectionOptions) GetPingDuration() time.Duration
func (*ConnectionOptions) GetPongDuration ¶
func (o *ConnectionOptions) GetPongDuration() time.Duration
func (*ConnectionOptions) GetWriteDuration ¶
func (o *ConnectionOptions) GetWriteDuration() time.Duration
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub maintains the set of active subscriptions and broadcasts messages to the clients.
type Message ¶
type Message struct { Identifier []byte `json:"identifier"` Description []byte `json:"description"` Action []byte `json:"action"` Payload []byte `json:"data,omitempty"` }
Message is the type delivered to subscribers.
type Notification2Client ¶
type Notification2Client struct { Subscription Subscription ConnectionOptions ConnectionOptions // contains filtered or unexported fields }
Notification2Client is a client used for the notification2 interface
func NewNotification2Client ¶
func NewNotification2Client(host string, wsDialer *websocket.Dialer, subscription Subscription, options ConnectionOptions) *Notification2Client
NewNotification2Client initializes a new notification2 client used to subscribe to realtime notifications from Cumulocity
func (*Notification2Client) Close ¶
func (c *Notification2Client) Close() error
Close the connection
func (*Notification2Client) Connect ¶
func (c *Notification2Client) Connect() error
Connect performs a handshake with the server and will repeatedly initiate a websocket connection until `Close` is called on the client.
func (*Notification2Client) Endpoint ¶
func (c *Notification2Client) Endpoint() string
func (*Notification2Client) IsConnected ¶
func (c *Notification2Client) IsConnected() bool
IsConnected returns true if the websocket is connected
func (*Notification2Client) Register ¶
func (c *Notification2Client) Register(pattern string, out chan<- Message)
func (*Notification2Client) SendMessageAck ¶
func (c *Notification2Client) SendMessageAck(messageIdentifier []byte) error
func (*Notification2Client) URL ¶
func (c *Notification2Client) URL() string
func (*Notification2Client) Unsubscribe ¶
func (c *Notification2Client) Unsubscribe() error
Unsubscribe unsubscribe to a given pattern
Click to show internal directories.
Click to hide internal directories.