Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Consumer ¶
type Consumer struct {
Handlers map[types.ObjectType]ResourceNotificationHandler
}
Consumer allows consuming notifications by picking the correct handler to process it
type Message ¶
type Message struct { // Notification is the notification that needs to be applied on the platform Notification *types.Notification // Resync indicates that full resync is needed // In this case Notification is nil // Resync messages are written in the channel: // - The first message in the channel, so we always start with a resync // - When notifications are lost (indicated by status 410 returned by SM) // - On regular interval based on configuration Resync bool }
Message is the payload sent by the producer
type Producer ¶
type Producer struct {
// contains filtered or unexported fields
}
Producer reads notifications coming from the websocket connection and regularly triggers full resync
func NewProducer ¶
func NewProducer(producerSettings *ProducerSettings, smSettings *sm.Settings) (*Producer, error)
NewProducer returns a configured producer for the given settings
type ProducerSettings ¶
type ProducerSettings struct { // MinPingPeriod is the minimum allowed ping period MinPingPeriod time.Duration `mapstructure:"min_ping_period"` // Reconnect delay is the time between reconnects ReconnectDelay time.Duration `mapstructure:"reconnect_delay"` // PongTimeout is the maximum time to wait between a ping and a pong PongTimeout time.Duration `mapstructure:"pong_timeout"` // PingPeriodPercentage is the percentage of actual ping period compared to the max_ping_period returned by SM PingPeriodPercentage int64 `mapstructure:"ping_period_percentage"` // MessagesQueueSize is the size of the messages queue MessagesQueueSize int `mapstructure:"messages_queue_size"` // ResyncPeriod is the time between two resyncs ResyncPeriod time.Duration `mapstructure:"resync_period"` }
ProducerSettings are the settings for the producer
func DefaultProducerSettings ¶
func DefaultProducerSettings() *ProducerSettings
DefaultProducerSettings are the default settings for the producer
func (ProducerSettings) Validate ¶
func (p ProducerSettings) Validate() error
Validate validates the producer settings
type ResourceNotificationHandler ¶
type ResourceNotificationHandler interface { // OnCreate is called when a notification for creating a resource arrives OnCreate(ctx context.Context, payload json.RawMessage) // OnUpdate is called when a notification for modifying a resource arrives OnUpdate(ctx context.Context, payload json.RawMessage) // OnDelete is called when a notification for deleting a resource arrives OnDelete(ctx context.Context, payload json.RawMessage) }
ResourceNotificationHandler can handle notifications by processing the Payload
Click to show internal directories.
Click to hide internal directories.