Documentation
¶
Index ¶
- Variables
- func DeleteStateByIncidentID(ctx context.Context, db *database.DB, incidentID int64) error
- func UpsertPlugins(ctx context.Context, channelPluginDir string, logger *logging.Logger, ...)
- func ValidateType(t string) error
- type Channel
- func (c *Channel) IncrementalInitAndValidate() error
- func (c *Channel) MarshalLogObject(encoder zapcore.ObjectEncoder) error
- func (c *Channel) Notify(ctx context.Context, contact *recipient.Contact, i *plugin.Incident, ...) (*plugin.DeliveryResult, error)
- func (c *Channel) Restart(logger *zap.SugaredLogger)
- func (c *Channel) Start(ctx context.Context, db *database.DB, logger *zap.SugaredLogger)
- func (c *Channel) Stop(chDeleted bool)
- type State
Constants ¶
This section is empty.
Variables ¶
var ( // ErrChannelDeleted is used as a cancellation cause when the channel is deleted, allowing the // plugin control loop to clean up its state in the database before exiting. ErrChannelDeleted = errors.New("channel deleted") )
Functions ¶
func DeleteStateByIncidentID ¶ added in v1.0.0
DeleteStateByIncidentID deletes all states associated with a specific incident ID from the database.
func UpsertPlugins ¶
func UpsertPlugins(ctx context.Context, channelPluginDir string, logger *logging.Logger, db *database.DB)
UpsertPlugins upsert the available_channel_type table with working plugins
func ValidateType ¶
ValidateType returns an error if non-allowed chars are detected, nil otherwise.
Types ¶
type Channel ¶
type Channel struct {
baseconf.IncrementalPkDbEntry[int64] `db:",inline"`
ExternalUUID types.UUID `db:"external_uuid"`
Name string `db:"name"`
Type string `db:"type"`
Config string `db:"config" json:"-"` // excluded from JSON config dump as this may contain sensitive information
ValidationResult types.String `db:"validation_result" json:"-"` // excluded from JSON dump for the same reason as Config.
Logger *zap.SugaredLogger `db:"-"`
// contains filtered or unexported fields
}
func (*Channel) IncrementalInitAndValidate ¶
IncrementalInitAndValidate implements the config.IncrementalConfigurableInitAndValidatable interface.
func (*Channel) MarshalLogObject ¶
func (c *Channel) MarshalLogObject(encoder zapcore.ObjectEncoder) error
MarshalLogObject implements the zapcore.ObjectMarshaler interface.
func (*Channel) Notify ¶
func (c *Channel) Notify( ctx context.Context, contact *recipient.Contact, i *plugin.Incident, o *object.Object, ev *event.Event, summary string, body string, incidentID int64, ) (*plugin.DeliveryResult, error)
Notify sends a notification about the given incident, object and event to the contact via this channel's plugin.
Only the contact's addresses matching the plugin type are passed to the plugin. If an incident is given and the contact has at least one such address, the channel state for this channel, incident and contact is looked up and included in the request, so the plugin can e.g. reply to a previously sent message.
If the plugin returns a valid state for a non-recovered incident, it is persisted for subsequent notifications. Failures in any of these state operations are logged but don't fail the notification, unless ctx or the plugin context has been canceled.
The provided ctx bounds the whole operation. Canceling it aborts any pending database operation and the RPC call.
It returns the plugin's delivery result (maybe nil) on success, or an error if the notification couldn't be sent.
func (*Channel) Restart ¶
func (c *Channel) Restart(logger *zap.SugaredLogger)
Restart signals to restart the channel plugin with the updated channel config.
func (*Channel) Start ¶
Start initializes the channel and starts the plugin control loop in a separate goroutine.
It should be called after the channel has been created and its properties have been set. The provided context is used to manage the lifecycle of the plugin control loop, and the logger is used for logging messages related to the channel and its plugin.
func (*Channel) Stop ¶
Stop cancels the plugin context, which will cause the plugin control loop to exit.
If chDeleted is true, the cancellation cause will be set to ErrChannelDeleted, which signals to the plugin control loop that the channel has been deleted, and it should clean up its state in the database before exiting.
type State ¶ added in v1.0.0
type State struct {
ChannelID int64 `db:"channel_id" json:"-"`
IncidentID int64 `db:"incident_id" json:"-"`
plugin.State `db:",inline"`
}
State represents a key-value pair associated with a channel, incident and contact in the database.
The plugin will only receive the Key and Value fields, while the other fields are fully managed by the plugin supervisor of that specific channel. Thus, the plugins won't be able to see or modify the ChannelID field, which prevents accidental or malicious tampering with the state of other channels.
func (*State) TableName ¶ added in v1.0.0
TableName implements the database.TableNamer interface.
func (*State) Upsert ¶ added in v1.0.0
Upsert implements the database.Upserter interface.