escalation

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveStep

type ActiveStep struct {
	StepID          string
	PolicyID        string
	AlertID         int
	LastEscalation  time.Time
	LoopCount       int
	ForceEscalation bool
	StepNumber      int
}

type ActiveStepReader

type ActiveStepReader interface {
	ActiveStep(ctx context.Context, alertID int, policyID string) (*ActiveStep, error)

	// FindOneStep will return a single escalation policy step.
	// Note: it does not currently fetch the Targets.
	FindOneStep(context.Context, string) (*Step, error)
	FindOneStepTx(context.Context, *sql.Tx, string) (*Step, error)
	FindOneStepForUpdateTx(context.Context, *sql.Tx, string) (*Step, error)

	// FindAllSteps will return escalation policy steps for the given policy ID.
	// Note: it does not currently fetch the Targets.
	FindAllSteps(context.Context, string) ([]Step, error)
	FindAllStepsTx(context.Context, *sql.Tx, string) ([]Step, error)
	FindAllOnCallStepsForUserTx(ctx context.Context, tx *sql.Tx, userID string) ([]Step, error)
}

type Config

type Config struct {
	NCStore         notificationchannel.Store
	LogStore        alertlog.Store
	SlackLookupFunc func(ctx context.Context, channelID string) (*slack.Channel, error)
}

type DB

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

func NewDB

func NewDB(ctx context.Context, db *sql.DB, cfg Config) (*DB, error)

func (*DB) ActiveStep

func (db *DB) ActiveStep(ctx context.Context, alertID int, policyID string) (*ActiveStep, error)

func (*DB) AddStepTarget

func (db *DB) AddStepTarget(ctx context.Context, stepID string, tgt assignment.Target) error

func (*DB) AddStepTargetTx

func (db *DB) AddStepTargetTx(ctx context.Context, tx *sql.Tx, stepID string, tgt assignment.Target) error

func (*DB) CreatePolicy

func (db *DB) CreatePolicy(ctx context.Context, p *Policy) (*Policy, error)

func (*DB) CreatePolicyTx

func (db *DB) CreatePolicyTx(ctx context.Context, tx *sql.Tx, p *Policy) (*Policy, error)

func (*DB) CreateStep

func (db *DB) CreateStep(ctx context.Context, s *Step) (*Step, error)

func (*DB) CreateStepTx

func (db *DB) CreateStepTx(ctx context.Context, tx *sql.Tx, s *Step) (*Step, error)

func (*DB) DeleteManyPoliciesTx

func (db *DB) DeleteManyPoliciesTx(ctx context.Context, tx *sql.Tx, ids []string) error

func (*DB) DeletePolicy

func (db *DB) DeletePolicy(ctx context.Context, id string) error

func (*DB) DeletePolicyTx

func (db *DB) DeletePolicyTx(ctx context.Context, tx *sql.Tx, id string) error

func (*DB) DeleteStep

func (db *DB) DeleteStep(ctx context.Context, id string) (string, error)

func (*DB) DeleteStepTarget

func (db *DB) DeleteStepTarget(ctx context.Context, stepID string, tgt assignment.Target) error

func (*DB) DeleteStepTargetTx

func (db *DB) DeleteStepTargetTx(ctx context.Context, tx *sql.Tx, stepID string, tgt assignment.Target) error

func (*DB) DeleteStepTx

func (db *DB) DeleteStepTx(ctx context.Context, tx *sql.Tx, id string) (string, error)

func (*DB) FindAllOnCallStepsForUserTx

func (db *DB) FindAllOnCallStepsForUserTx(ctx context.Context, tx *sql.Tx, userID string) ([]Step, error)

func (*DB) FindAllPolicies

func (db *DB) FindAllPolicies(ctx context.Context) ([]Policy, error)

func (*DB) FindAllPoliciesBySchedule

func (db *DB) FindAllPoliciesBySchedule(ctx context.Context, scheduleID string) ([]Policy, error)

func (*DB) FindAllStepTargets

func (db *DB) FindAllStepTargets(ctx context.Context, stepID string) ([]assignment.Target, error)

func (*DB) FindAllStepTargetsTx

func (db *DB) FindAllStepTargetsTx(ctx context.Context, tx *sql.Tx, stepID string) ([]assignment.Target, error)

func (*DB) FindAllSteps

func (db *DB) FindAllSteps(ctx context.Context, policyID string) ([]Step, error)

func (*DB) FindAllStepsTx

func (db *DB) FindAllStepsTx(ctx context.Context, tx *sql.Tx, policyID string) ([]Step, error)

func (*DB) FindManyPolicies

func (db *DB) FindManyPolicies(ctx context.Context, ids []string) ([]Policy, error)

func (*DB) FindOnePolicy

func (db *DB) FindOnePolicy(ctx context.Context, id string) (*Policy, error)

func (*DB) FindOnePolicyForUpdateTx

func (db *DB) FindOnePolicyForUpdateTx(ctx context.Context, tx *sql.Tx, id string) (*Policy, error)

func (*DB) FindOnePolicyTx

func (db *DB) FindOnePolicyTx(ctx context.Context, tx *sql.Tx, id string) (*Policy, error)

func (*DB) FindOneStep

func (db *DB) FindOneStep(ctx context.Context, id string) (*Step, error)

func (*DB) FindOneStepForUpdateTx

func (db *DB) FindOneStepForUpdateTx(ctx context.Context, tx *sql.Tx, id string) (*Step, error)

func (*DB) FindOneStepTx

func (db *DB) FindOneStepTx(ctx context.Context, tx *sql.Tx, id string) (*Step, error)

func (*DB) MoveStep

func (db *DB) MoveStep(ctx context.Context, id string, newPos int) error

func (*DB) Search

func (db *DB) Search(ctx context.Context, opts *SearchOptions) ([]Policy, error)

func (*DB) UpdatePolicy

func (db *DB) UpdatePolicy(ctx context.Context, p *Policy) error

func (*DB) UpdatePolicyTx

func (db *DB) UpdatePolicyTx(ctx context.Context, tx *sql.Tx, p *Policy) error

func (*DB) UpdateStep

func (db *DB) UpdateStep(ctx context.Context, s *Step) error

func (*DB) UpdateStepDelayTx

func (db *DB) UpdateStepDelayTx(ctx context.Context, tx *sql.Tx, stepID string, stepDelay int) error

func (*DB) UpdateStepNumberTx

func (db *DB) UpdateStepNumberTx(ctx context.Context, tx *sql.Tx, stepID string, stepNumber int) error

type Manager

type Manager interface {
	ActiveStepReader

	FindOnePolicy(context.Context, string) (*Policy, error)
}

type Policy

type Policy struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Repeat      int    `json:"repeat"`
}

func (Policy) Normalize

func (p Policy) Normalize() (*Policy, error)

type PolicyStore

type PolicyStore interface {
	FindOnePolicy(context.Context, string) (*Policy, error)
	FindOnePolicyTx(context.Context, *sql.Tx, string) (*Policy, error)
	FindOnePolicyForUpdateTx(context.Context, *sql.Tx, string) (*Policy, error)
	FindAllPolicies(context.Context) ([]Policy, error)
	CreatePolicy(context.Context, *Policy) (*Policy, error)
	CreatePolicyTx(context.Context, *sql.Tx, *Policy) (*Policy, error)
	UpdatePolicy(context.Context, *Policy) error
	UpdatePolicyTx(context.Context, *sql.Tx, *Policy) error
	DeletePolicy(ctx context.Context, id string) error
	DeletePolicyTx(ctx context.Context, tx *sql.Tx, id string) error
	FindAllStepTargets(ctx context.Context, stepID string) ([]assignment.Target, error)
	FindAllStepTargetsTx(ctx context.Context, tx *sql.Tx, stepID string) ([]assignment.Target, error)
	AddStepTarget(ctx context.Context, stepID string, tgt assignment.Target) error
	AddStepTargetTx(ctx context.Context, tx *sql.Tx, stepID string, tgt assignment.Target) error
	DeleteStepTarget(ctx context.Context, stepID string, tgt assignment.Target) error
	DeleteStepTargetTx(ctx context.Context, tx *sql.Tx, stepID string, tgt assignment.Target) error
	FindAllPoliciesBySchedule(ctx context.Context, scheduleID string) ([]Policy, error)
	FindManyPolicies(ctx context.Context, ids []string) ([]Policy, error)
	DeleteManyPoliciesTx(ctx context.Context, tx *sql.Tx, ids []string) error

	Search(context.Context, *SearchOptions) ([]Policy, error)
}

type SearchCursor

type SearchCursor struct {
	Name string `json:"n,omitempty"`
}

SearchCursor is used to indicate a position in a paginated list.

type SearchOptions

type SearchOptions struct {
	Search string       `json:"s,omitempty"`
	After  SearchCursor `json:"a,omitempty"`

	// Omit specifies a list of policy IDs to exclude from the results.
	Omit []string `json:"o,omitempty"`

	Limit int `json:"-"`
}

SearchOptions allow filtering and paginating the list of escalation policies.

type Step

type Step struct {
	ID           string `json:"id"`
	PolicyID     string `json:"escalation_policy_id"`
	DelayMinutes int    `json:"delay_minutes"`
	StepNumber   int    `json:"step_number"`

	Targets []assignment.Target
}

func (Step) Delay

func (s Step) Delay() time.Duration

func (Step) Normalize

func (s Step) Normalize() (*Step, error)

type StepStore

type StepStore interface {
	// CreateStep is replaced by CreateStepTx.
	CreateStep(context.Context, *Step) (*Step, error)

	// CreateStepTx will create an escalation policy step within the given transaction.
	// Note: Targets are not assigned during creation.
	CreateStepTx(context.Context, *sql.Tx, *Step) (*Step, error)
	UpdateStepNumberTx(context.Context, *sql.Tx, string, int) error

	// Update step allows updating a steps delay
	// Note: it does not update the Targets.
	UpdateStep(context.Context, *Step) error
	UpdateStepDelayTx(context.Context, *sql.Tx, string, int) error
	DeleteStep(context.Context, string) (string, error)
	DeleteStepTx(context.Context, *sql.Tx, string) (string, error)
	MoveStep(context.Context, string, int) error
}

type Store

type Store interface {
	PolicyStore
	StepStore
	ActiveStepReader
}

Jump to

Keyboard shortcuts

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