engine

package
v0.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	AlertLogStore       *alertlog.Store
	AlertStore          *alert.Store
	ContactMethodStore  *contactmethod.Store
	NotificationManager *notification.Manager
	UserStore           *user.Store
	NotificationStore   *notification.Store
	NCStore             *notificationchannel.Store
	OnCallStore         *oncall.Store
	ScheduleStore       *schedule.Store
	AuthLinkStore       *authlink.Store
	SlackStore          *slack.ChannelSender

	ConfigSource config.Source

	Keys keyring.Keys

	MaxMessages int

	DisableCycle bool
	LogCycles    bool

	CycleTime time.Duration
}

Config contains parameters for controlling how the Engine operates.

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine handles automatic escalation of unacknowledged(triggered) alerts, as well as passing to-be-sent notifications to the notification.Sender.

Care is taken to ensure only one attempt is made per contact-method at a time, regardless of how many instances of the application may be running.

func NewEngine

func NewEngine(ctx context.Context, db *sql.DB, c *Config) (*Engine, error)

NewEngine will create a new Engine using the passed *sql.DB as a backend. Outgoing notifications will be passed to Sender.

Context is only used for preparing and initializing.

func (*Engine) AuthLinkURL added in v0.30.0

func (p *Engine) AuthLinkURL(ctx context.Context, providerID, subjectID string, meta authlink.Metadata) (url string, err error)

func (*Engine) IsKnownDest added in v0.28.0

func (n *Engine) IsKnownDest(ctx context.Context, destType notification.DestType, destValue string) (bool, error)

func (Engine) NextCycleID added in v0.30.0

func (c Engine) NextCycleID() uuid.UUID

NextCycleID returns the UUID of the next engine cycle.

func (*Engine) Pause

func (p *Engine) Pause(ctx context.Context) error

Pause will attempt to gracefully stop engine processing.

func (*Engine) Receive

func (p *Engine) Receive(ctx context.Context, callbackID string, result notification.Result) error

Receive will process a notification result.

func (*Engine) ReceiveSubject added in v0.29.0

func (p *Engine) ReceiveSubject(ctx context.Context, providerID, subjectID, callbackID string, result notification.Result) error

ReceiveSubject will process a notification result.

func (*Engine) Resume

func (p *Engine) Resume(ctx context.Context) error

Resume will allow the engine to resume processing.

func (*Engine) Run

func (p *Engine) Run(ctx context.Context) error

Run will being the engine loop.

func (*Engine) SetSendResult added in v0.28.0

func (p *Engine) SetSendResult(ctx context.Context, res *notification.SendResult) error

SetSendResult will update the status of a message.

func (*Engine) Shutdown

func (p *Engine) Shutdown(ctx context.Context) error

Shutdown will gracefully shutdown the processor, finishing any ongoing tasks.

func (*Engine) Start added in v0.25.0

func (p *Engine) Start(ctx context.Context, d notification.Dest) error

Start will enable all associated contact methods of `value` with type `t`. This should be invoked if a user, for example, responds with `START` via sms.

func (*Engine) Stop

func (p *Engine) Stop(ctx context.Context, d notification.Dest) error

Stop will disable all associated contact methods of `value` with type `t`. This should be invoked if a user, for example, responds with `STOP` via SMS.

func (*Engine) Trigger

func (p *Engine) Trigger()

Trigger will force notifications to be processed immediately.

func (Engine) WaitCycleID added in v0.30.0

func (c Engine) WaitCycleID(ctx context.Context, cycleID uuid.UUID) error

WaitCycleID waits for the engine cycle with the given UUID to finish.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL