dbgen

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BumpRouteOrderParams

type BumpRouteOrderParams struct {
	OrgID    int64
	Expected pgtype.Int8
}

type BumpRoutesOfDestinationParams

type BumpRoutesOfDestinationParams struct {
	Now           time.Time
	OrgID         int64
	DestinationID int64
}

type BumpRoutesOfDestinationRow

type BumpRoutesOfDestinationRow struct {
	ID       int64
	PublicID string
}

type CountOpenAlertGroupsParams

type CountOpenAlertGroupsParams struct {
	OrgID   int64
	RouteID int64
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DeleteDestinationTeamsParams

type DeleteDestinationTeamsParams struct {
	OrgID         int64
	DestinationID int64
}

type DeleteRouteChainsExceptParams

type DeleteRouteChainsExceptParams struct {
	OrgID   int64
	RouteID int64
	KeepIds []int64
}

type DeleteRouteDestinationsParams

type DeleteRouteDestinationsParams struct {
	OrgID          int64
	RouteID        int64
	DestinationIds []int64
}

type DeleteRouteMatchersParams

type DeleteRouteMatchersParams struct {
	OrgID   int64
	RouteID int64
}

type DeleteRouteParams

type DeleteRouteParams struct {
	Now   pgtype.Timestamptz
	OrgID int64
	ID    int64
}

type DismissRouteSuggestionParams

type DismissRouteSuggestionParams struct {
	UserID      int64
	Suggestion  string
	OrgID       int64
	DismissedAt time.Time
}

type DropDeletedRouteDestinationsParams

type DropDeletedRouteDestinationsParams struct {
	OrgID   int64
	RouteID int64
}

type EnsureDefaultRouteParams

type EnsureDefaultRouteParams struct {
	OrgID                          int64
	PublicID                       string
	Name                           string
	Description                    string
	MinimumSeverity                string
	GroupKey                       []string
	ReopenWindowSeconds            int64
	GracePeriodSeconds             int64
	UrgentRiseRemovesAck           bool
	SnoozeDurationsSeconds         []int64
	ThreadBatchingWindowSeconds    int64
	StormThreshold                 int64
	Language                       string
	AckTimeoutEnabled              bool
	AckTimeoutFirstIntervalSeconds int64
	RemindersEnabled               bool
	RemindersFirstIntervalSeconds  int64
	RemindersCapSeconds            int64
	AutoUnacknowledge              bool
	Now                            time.Time
}

type GetRouteParams

type GetRouteParams struct {
	OrgID    int64
	PublicID string
}

type GetRouteRow

type GetRouteRow struct {
	ID                             int64
	PublicID                       string
	Name                           string
	Description                    string
	Position                       int64
	IsDefault                      bool
	MinimumSeverity                string
	GroupKey                       []string
	ReopenWindowSeconds            int64
	GracePeriodSeconds             int64
	UrgentRiseRemovesAck           bool
	SnoozeDurationsSeconds         []int64
	ThreadBatchingWindowSeconds    int64
	StormThreshold                 int64
	Language                       string
	TemplateRootMessage            pgtype.Text
	TemplateLine                   pgtype.Text
	TemplateAckTimeoutNotice       pgtype.Text
	AckTimeoutEnabled              bool
	AckTimeoutFirstIntervalSeconds int64
	RemindersEnabled               bool
	RemindersFirstIntervalSeconds  int64
	RemindersCapSeconds            int64
	AutoUnacknowledge              bool
	CreatedAt                      time.Time
	Version                        int64
	TemplateErrorSince             pgtype.Timestamptz
	TemplateError                  pgtype.Text
	Place                          int64
	StormSince                     pgtype.Timestamptz
	StormAlertGroupCount           pgtype.Int8
	OwningTeamID                   pgtype.Int8
	OwningTeamPublicID             pgtype.Text
	OwningTeamName                 pgtype.Text
	OwningTeamSlug                 pgtype.Text
	OwningTeamDeleted              bool
	MessageLabels                  []string
	SeverityLabel                  string
	TeamLabel                      string
	DeliverToTeams                 bool
	RunTeamChains                  bool
	ManagedBy                      pgtype.Text
}

type GetRoutingStampRow

type GetRoutingStampRow struct {
	RouteOrderVersion int64
	RouteVersions     int64
	SeverityLabel     string
	SeverityMapping   []byte
	TeamLabel         string
	TeamsVersion      int64
}

type HasOpenAlertGroupsParams

type HasOpenAlertGroupsParams struct {
	OrgID   int64
	RouteID int64
}

type InsertAlertTeamsParams

type InsertAlertTeamsParams struct {
	OrgID    int64
	AlertIds []int64
	TeamIds  []int64
	Rules    []string
	Matchers []string
}

type InsertOpenGroupUpdateParams

type InsertOpenGroupUpdateParams struct {
	OrgID       int64
	Kind        string
	RouteID     pgtype.Int8
	RequestedAt time.Time
}

type InsertRouteDestinationsParams

type InsertRouteDestinationsParams struct {
	RouteID        int64
	OrgID          int64
	Now            time.Time
	DestinationIds []int64
	Conditions     []string
}

type InsertRouteMatcherParams

type InsertRouteMatcherParams struct {
	RouteID  int64
	OrgID    int64
	Position int64
	Label    string
	Op       string
	Value    string
}

type InsertRouteParams

type InsertRouteParams struct {
	OrgID                          int64
	PublicID                       string
	Name                           string
	Description                    string
	First                          bool
	MinimumSeverity                string
	GroupKey                       []string
	ReopenWindowSeconds            int64
	GracePeriodSeconds             int64
	UrgentRiseRemovesAck           bool
	SnoozeDurationsSeconds         []int64
	ThreadBatchingWindowSeconds    int64
	StormThreshold                 int64
	Language                       string
	TemplateRootMessage            pgtype.Text
	TemplateLine                   pgtype.Text
	TemplateAckTimeoutNotice       pgtype.Text
	AckTimeoutEnabled              bool
	AckTimeoutFirstIntervalSeconds int64
	RemindersEnabled               bool
	RemindersFirstIntervalSeconds  int64
	RemindersCapSeconds            int64
	AutoUnacknowledge              bool
	OwningTeamID                   pgtype.Int8
	MessageLabels                  []string
	DeliverToTeams                 bool
	RunTeamChains                  bool
	ManagedBy                      pgtype.Text
	Now                            time.Time
}

type ListAlertLabelsParams

type ListAlertLabelsParams struct {
	OrgID     int64
	Ids       []int64
	ListedIds []int64
}

type ListAlertLabelsRow

type ListAlertLabelsRow struct {
	ID     int64
	Labels []byte
}

type ListAlertingDestinationsRow

type ListAlertingDestinationsRow struct {
	PublicID string
	Name     string
}

type ListAlertingGatewaysRow

type ListAlertingGatewaysRow struct {
	PublicID string
	Name     string
}

type ListAlertingIntegrationsRow

type ListAlertingIntegrationsRow struct {
	PublicID     string
	Name         string
	StaticLabels []byte
}

type ListAlertingSchedulesRow

type ListAlertingSchedulesRow struct {
	PublicID     string
	Name         string
	TeamPublicID string
	TeamName     string
	TeamSlug     string
	TeamLabel    string
}

type ListHeartbeatIntegrationsRow

type ListHeartbeatIntegrationsRow struct {
	PublicID     string
	Name         string
	StaticLabels []byte
}

type ListOpenAlertGroupCountsRow

type ListOpenAlertGroupCountsRow struct {
	RouteID int64
	Count   int64
}

type ListPreviewDestinationsParams

type ListPreviewDestinationsParams struct {
	OrgID int64
	Ids   []int64
}

type ListPreviewDestinationsRow

type ListPreviewDestinationsRow struct {
	ID           int64
	PublicID     string
	Name         string
	Type         string
	Health       string
	BrokenSince  pgtype.Timestamptz
	BrokenReason pgtype.Text
}

type ListPreviewTeamEntriesParams

type ListPreviewTeamEntriesParams struct {
	OrgID   int64
	TeamIds []int64
}

type ListPreviewTeamEntriesRow

type ListPreviewTeamEntriesRow struct {
	TeamID            int64
	DestinationID     int64
	SeverityCondition string
}

type ListPreviewTeamsParams

type ListPreviewTeamsParams struct {
	OrgID   int64
	TeamIds []int64
}

type ListPreviewTeamsRow

type ListPreviewTeamsRow struct {
	ID       int64
	PublicID string
	Name     string
	Slug     string
}

type ListRouteChainsParams

type ListRouteChainsParams struct {
	OrgID    int64
	RouteIds []int64
}

type ListRouteChainsRow

type ListRouteChainsRow struct {
	RouteID           int64
	SeverityCondition string
	PublicID          string
	Name              string
	OwnerPublicID     pgtype.Text
	OwnerName         pgtype.Text
	OwnerSlug         pgtype.Text
	OwnerDeleted      bool
}

type ListRouteDestinationIDsParams

type ListRouteDestinationIDsParams struct {
	OrgID    int64
	RouteIds []int64
}

type ListRouteDestinationIDsRow

type ListRouteDestinationIDsRow struct {
	RouteID           int64
	DestinationID     int64
	PublicID          string
	SeverityCondition string
}

type ListRouteInfoRow

type ListRouteInfoRow struct {
	PublicID string
	Name     string
}

type ListRouteLabelSuggestionsParams

type ListRouteLabelSuggestionsParams struct {
	OrgID    int64
	Lim      int32
	RouteID  int64
	Since    time.Time
	GroupLim int32
	AlertLim int32
}

type ListRouteLabelSuggestionsRow

type ListRouteLabelSuggestionsRow struct {
	Label           string
	ExampleValue    string
	AlertGroupCount int64
}

type ListRouteMatchersParams

type ListRouteMatchersParams struct {
	OrgID    int64
	RouteIds []int64
}

type ListRouteMatchersRow

type ListRouteMatchersRow struct {
	RouteID int64
	Label   string
	Op      string
	Value   string
}

type ListRouteSuggestionDismissalsParams

type ListRouteSuggestionDismissalsParams struct {
	OrgID  int64
	UserID int64
}

type ListRoutesRow

type ListRoutesRow struct {
	ID                             int64
	PublicID                       string
	Name                           string
	Description                    string
	Position                       int64
	IsDefault                      bool
	MinimumSeverity                string
	GroupKey                       []string
	ReopenWindowSeconds            int64
	GracePeriodSeconds             int64
	UrgentRiseRemovesAck           bool
	SnoozeDurationsSeconds         []int64
	ThreadBatchingWindowSeconds    int64
	StormThreshold                 int64
	Language                       string
	TemplateRootMessage            pgtype.Text
	TemplateLine                   pgtype.Text
	TemplateAckTimeoutNotice       pgtype.Text
	AckTimeoutEnabled              bool
	AckTimeoutFirstIntervalSeconds int64
	RemindersEnabled               bool
	RemindersFirstIntervalSeconds  int64
	RemindersCapSeconds            int64
	AutoUnacknowledge              bool
	CreatedAt                      time.Time
	Version                        int64
	TemplateErrorSince             pgtype.Timestamptz
	TemplateError                  pgtype.Text
	StormSince                     pgtype.Timestamptz
	StormAlertGroupCount           pgtype.Int8
	OwningTeamID                   pgtype.Int8
	OwningTeamPublicID             pgtype.Text
	OwningTeamName                 pgtype.Text
	OwningTeamSlug                 pgtype.Text
	OwningTeamDeleted              bool
	MessageLabels                  []string
	SeverityLabel                  string
	TeamLabel                      string
	DeliverToTeams                 bool
	RunTeamChains                  bool
	ManagedBy                      pgtype.Text
}

type ListTeamsOfDestinationParams

type ListTeamsOfDestinationParams struct {
	OrgID         int64
	DestinationID int64
}

type ListUserTeamsParams

type ListUserTeamsParams struct {
	OrgID  int64
	UserID int64
}

type LockOwningTeamParams

type LockOwningTeamParams struct {
	OrgID    int64
	PublicID string
}

type LockOwningTeamRow

type LockOwningTeamRow struct {
	ID       int64
	PublicID string
	Name     string
	Slug     string
}

type LockRouteMembershipParams

type LockRouteMembershipParams struct {
	LockClass int32
	RouteID   int64
}

type LockRouteParams

type LockRouteParams struct {
	OrgID    int64
	PublicID string
}

type LockTeamMembershipParams

type LockTeamMembershipParams struct {
	LockClass int32
	TeamID    int64
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) BumpRouteOrder

func (q *Queries) BumpRouteOrder(ctx context.Context, arg BumpRouteOrderParams) (int64, error)

BumpRouteOrder bumps the version of the Route list, the list ETag, and returns the new one; with @expected it returns no row unless the version is still that one. The row lock serializes the changes of the list.

func (*Queries) BumpRoutesOfDestination

func (q *Queries) BumpRoutesOfDestination(ctx context.Context, arg BumpRoutesOfDestinationParams) ([]BumpRoutesOfDestinationRow, error)

BumpRoutesOfDestination gives each Route that is not deleted of a Destination about to leave them a new version, locking them in id order, and returns them in that order.

func (*Queries) CountOpenAlertGroups

func (q *Queries) CountOpenAlertGroups(ctx context.Context, arg CountOpenAlertGroupsParams) (int64, error)

CountOpenAlertGroups counts the open Alert Groups of a Route, read-only (only groups writes alert_groups); a deletion counts them after LockRoute, so that a Snapshot grouping on the Route either committed before or waits.

func (*Queries) DeleteDestinationTeams

func (q *Queries) DeleteDestinationTeams(ctx context.Context, arg DeleteDestinationTeamsParams) error

DeleteDestinationTeams removes a deleted Destination from every Team.

func (*Queries) DeleteRoute

func (q *Queries) DeleteRoute(ctx context.Context, arg DeleteRouteParams) error

DeleteRoute soft-deletes a Route: it leaves every list and the evaluation order at once.

func (*Queries) DeleteRouteChainsExcept

func (q *Queries) DeleteRouteChainsExcept(ctx context.Context, arg DeleteRouteChainsExceptParams) error

DeleteRouteChainsExcept removes the Escalation chains of a Route other than those it keeps.

func (*Queries) DeleteRouteDestinations

func (q *Queries) DeleteRouteDestinations(ctx context.Context, arg DeleteRouteDestinationsParams) error

DeleteRouteDestinations removes Destinations from a Route.

func (*Queries) DeleteRouteMatchers

func (q *Queries) DeleteRouteMatchers(ctx context.Context, arg DeleteRouteMatchersParams) error

DeleteRouteMatchers removes the Matchers of a Route before they are written again.

func (*Queries) DismissRouteSuggestion

func (q *Queries) DismissRouteSuggestion(ctx context.Context, arg DismissRouteSuggestionParams) error

DismissRouteSuggestion records that a User dismissed a Route suggestion; a second dismissal changes nothing.

func (*Queries) DropDeletedRouteDestinations

func (q *Queries) DropDeletedRouteDestinations(ctx context.Context, arg DropDeletedRouteDestinationsParams) error

DropDeletedRouteDestinations removes from a Route the entries of Destinations that are deleted: one a save wrote while the Destination's deletion committed, which no read returns.

func (*Queries) EnsureDefaultRoute

func (q *Queries) EnsureDefaultRoute(ctx context.Context, arg EnsureDefaultRouteParams) (string, error)

EnsureDefaultRoute creates the Default route of the Organization when it has none, and returns its public_id only when it created it.

func (*Queries) GetRoute

func (q *Queries) GetRoute(ctx context.Context, arg GetRouteParams) (GetRouteRow, error)

GetRoute reads a Route that is not deleted with its place in evaluation order, zero-based, its template error, its active Storm and the Organization's severity and Team labels, as ListRoutes does.

func (*Queries) GetRouteOrderVersion

func (q *Queries) GetRouteOrderVersion(ctx context.Context, orgID int64) (int64, error)

GetRouteOrderVersion reads the version of the Route list.

func (*Queries) GetRoutingStamp

func (q *Queries) GetRoutingStamp(ctx context.Context, orgID int64) (GetRoutingStampRow, error)

GetRoutingStamp reads what decides whether the cached evaluation order is current — the version of the Route list, which creation, deletion and reordering bump, with the sum of the versions of the Routes, which every edit bumps — and the Severity level settings of the Organization.

func (*Queries) HasOpenAlertGroups

func (q *Queries) HasOpenAlertGroups(ctx context.Context, arg HasOpenAlertGroupsParams) (bool, error)

HasOpenAlertGroups reports whether a Route has open Alert Groups, read-only (only groups writes alert_groups), those moved to it included: a changed Minimum severity reaches them through open_group_updates.

func (*Queries) InsertAlertTeams

func (q *Queries) InsertAlertTeams(ctx context.Context, arg InsertAlertTeamsParams) error

InsertAlertTeams records the Teams of Alerts that start firing with the rule that decided each, and the Team matcher of the rule matcher; an empty matcher is null.

func (*Queries) InsertOpenGroupUpdate

func (q *Queries) InsertOpenGroupUpdate(ctx context.Context, arg InsertOpenGroupUpdateParams) error

InsertOpenGroupUpdate requests that a change of configuration of the Route @route_id reach its open Alert Groups (C-26.FR-9): the worker of any replica claims the row. A row of the Route that no worker has claimed yet already covers the save when it is of the same kind, or when both kinds re-render the Root messages (route_message_labels and route_message_settings, which share their run): its run reads the Route as it is then. It is locked, so that no worker claims it before this transaction commits, and no second one is inserted.

func (*Queries) InsertRoute

func (q *Queries) InsertRoute(ctx context.Context, arg InsertRouteParams) (int64, error)

InsertRoute creates a Route at the last position before the Default route, or with @first at the top of the list. urgent is written as minimum_severity = 'critical', which a 0.1 replica of a rolling update still reads (C-26.FR-10).

func (*Queries) InsertRouteDestinations

func (q *Queries) InsertRouteDestinations(ctx context.Context, arg InsertRouteDestinationsParams) error

InsertRouteDestinations adds Destinations to a Route with their Severity conditions, one each, added now.

func (*Queries) InsertRouteMatcher

func (q *Queries) InsertRouteMatcher(ctx context.Context, arg InsertRouteMatcherParams) error

InsertRouteMatcher writes one Matcher of a Route at its position.

func (*Queries) ListAlertLabels

func (q *Queries) ListAlertLabels(ctx context.Context, arg ListAlertLabelsParams) ([]ListAlertLabelsRow, error)

ListAlertLabels reads the labels of Alerts, with their Static labels applied: the Alerts ids, and the Alerts listed_ids that fire without a Route.

func (*Queries) ListAlertingDestinations

func (q *Queries) ListAlertingDestinations(ctx context.Context, orgID int64) ([]ListAlertingDestinationsRow, error)

ListAlertingDestinations lists the Destinations that are not deleted, of every type, with what the Internal alerts about a Destination carry of them: the public_id and the name.

func (*Queries) ListAlertingGateways

func (q *Queries) ListAlertingGateways(ctx context.Context, orgID int64) ([]ListAlertingGatewaysRow, error)

ListAlertingGateways lists the Notification gateways — the Bridge Connections that are not deleted whose stored info declares the role gateway — with what MusterNotificationGatewayBroken carries of them: the public_id and the name.

func (*Queries) ListAlertingIntegrations

func (q *Queries) ListAlertingIntegrations(ctx context.Context, orgID int64) ([]ListAlertingIntegrationsRow, error)

ListAlertingIntegrations lists the Integrations that are not deleted, the built-in one aside, with what the Internal alerts about an Integration carry of them: the public_id, the name and the Static labels.

func (*Queries) ListAlertingSchedules

func (q *Queries) ListAlertingSchedules(ctx context.Context, orgID int64) ([]ListAlertingSchedulesRow, error)

ListAlertingSchedules lists the Schedules with what MusterScheduleGap carries of them: the public_id and the name, the public_id, the name and the slug of their Team, and the Organization's Team label, under which the slug goes.

func (*Queries) ListHeartbeatIntegrations

func (q *Queries) ListHeartbeatIntegrations(ctx context.Context, orgID int64) ([]ListHeartbeatIntegrationsRow, error)

ListHeartbeatIntegrations lists the Integrations that are not deleted and have their Heartbeat on, with what MusterHeartbeatLost carries of them: the public_id, the name and the Static labels.

func (*Queries) ListOpenAlertGroupCounts

func (q *Queries) ListOpenAlertGroupCounts(ctx context.Context, orgID int64) ([]ListOpenAlertGroupCountsRow, error)

ListOpenAlertGroupCounts counts the open Alert Groups of each Route that has any (Route.open_alert_group_count).

func (*Queries) ListPreviewDestinations

func (q *Queries) ListPreviewDestinations(ctx context.Context, arg ListPreviewDestinationsParams) ([]ListPreviewDestinationsRow, error)

ListPreviewDestinations reads the Destinations that are not deleted among the ids with their names, types and health, for the preview "Where alerts go".

func (*Queries) ListPreviewTeamEntries

func (q *Queries) ListPreviewTeamEntries(ctx context.Context, arg ListPreviewTeamEntriesParams) ([]ListPreviewTeamEntriesRow, error)

ListPreviewTeamEntries lists the Destination entries of the Teams whose Destinations are not deleted, as delivery reads them, for the preview "Where alerts go".

func (*Queries) ListPreviewTeams

func (q *Queries) ListPreviewTeams(ctx context.Context, arg ListPreviewTeamsParams) ([]ListPreviewTeamsRow, error)

ListPreviewTeams reads the Teams that are not deleted among the ids with their names and slugs, for the Teams the preview "Where alerts go" names.

func (*Queries) ListRouteChains

func (q *Queries) ListRouteChains(ctx context.Context, arg ListRouteChainsParams) ([]ListRouteChainsRow, error)

ListRouteChains lists the Escalation chains of the Routes with their Severity conditions and their owning Teams, by Route, then by public_id.

func (*Queries) ListRouteDestinationIDs

func (q *Queries) ListRouteDestinationIDs(ctx context.Context, arg ListRouteDestinationIDsParams) ([]ListRouteDestinationIDsRow, error)

ListRouteDestinationIDs lists the Destinations that are not deleted of the Routes with their Severity conditions, by public_id.

func (*Queries) ListRouteInfo

func (q *Queries) ListRouteInfo(ctx context.Context, orgID int64) ([]ListRouteInfoRow, error)

ListRouteInfo lists the Routes that are not deleted for muster_route_info.

func (*Queries) ListRouteLabelSuggestions

func (q *Queries) ListRouteLabelSuggestions(ctx context.Context, arg ListRouteLabelSuggestionsParams) ([]ListRouteLabelSuggestionsRow, error)

ListRouteLabelSuggestions lists the labels of the Alerts of the Route's Alert Groups created since @since, each with its most frequent value, the smallest of equally frequent ones, and the number of those Alert Groups whose Alerts carry it, most frequent first, at most @lim, for "Labels in the message" (C-29.FR-2). What it reads is bounded before any label is expanded: the @group_lim most recent of those Alert Groups, through alert_groups_route_idx, then the memberships of one Alert Group after another, the most recent Alert Group and the newest membership first, through alert_group_alerts_group_idx, until @alert_lim of them are taken; the subquery r keeps the order of the Alert Groups known to the planner, so that the outer LIMIT stops the nested loop instead of sorting every membership. An Alert that fired again in an Alert Group, one membership per Episode, counts once there.

func (*Queries) ListRouteMatchers

func (q *Queries) ListRouteMatchers(ctx context.Context, arg ListRouteMatchersParams) ([]ListRouteMatchersRow, error)

ListRouteMatchers lists the Matchers of the Routes, in their order.

func (*Queries) ListRouteSuggestionDismissals

func (q *Queries) ListRouteSuggestionDismissals(ctx context.Context, arg ListRouteSuggestionDismissalsParams) ([]string, error)

ListRouteSuggestionDismissals lists the Route suggestions a User dismissed.

func (*Queries) ListRoutes

func (q *Queries) ListRoutes(ctx context.Context, orgID int64) ([]ListRoutesRow, error)

SPDX-License-Identifier: AGPL-3.0-only Copyright The Muster Authors ListRoutes lists the Routes that are not deleted in evaluation order, the Default route last, with their template error and their active Storm, and the Organization's severity and Team labels, from which a Route's "Labels in the message" are computed while it has no list of its own.

func (*Queries) ListTeamsOfDestination

func (q *Queries) ListTeamsOfDestination(ctx context.Context, arg ListTeamsOfDestinationParams) ([]int64, error)

ListTeamsOfDestination lists, in id order, the Teams whose Destination entries name a Destination about to be deleted.

func (*Queries) ListUserTeams

func (q *Queries) ListUserTeams(ctx context.Context, arg ListUserTeamsParams) ([]string, error)

ListUserTeams lists the public_ids of the Teams that are not deleted and that the User is in: "My Teams".

func (*Queries) LockOwningTeam

func (q *Queries) LockOwningTeam(ctx context.Context, arg LockOwningTeamParams) (LockOwningTeamRow, error)

LockOwningTeam reads the Team that is not deleted that a Route is to name as its owner, in share mode, so that the Team's deletion, which locks it for update, either waits for the save or is seen by it.

func (*Queries) LockRoute

func (q *Queries) LockRoute(ctx context.Context, arg LockRouteParams) (int64, error)

LockRoute locks a Route that is not deleted for a change; the lock leaves the key alone, so that routing, whose foreign key check on alerts.route_id takes a key share lock, never waits for it.

func (*Queries) LockRouteMembership

func (q *Queries) LockRouteMembership(ctx context.Context, arg LockRouteMembershipParams) error

LockRouteMembership takes, until the transaction ends, the membership lock of a Route exclusively before its Destinations change: delivery's Enqueue takes it shared (ShareRouteMembership, class db.RouteMembershipLockClass), so that a change of the Destinations and an Enqueue on the Route serialize.

func (*Queries) LockTeamMembership

func (q *Queries) LockTeamMembership(ctx context.Context, arg LockTeamMembershipParams) error

LockTeamMembership takes, until the transaction ends, the membership lock of a Team exclusively (class db.TeamMembershipLockClass) before the Team's Destination entries change: whatever reads them for an Alert Group takes it shared, so that the change and an Enqueue that reaches the Team's Destinations serialize.

func (*Queries) NotifyOpenGroupUpdates

func (q *Queries) NotifyOpenGroupUpdates(ctx context.Context, channel string) error

NotifyOpenGroupUpdates wakes the open Alert Group update workers of every replica once the transaction commits.

func (*Queries) ResetAlertTeams

func (q *Queries) ResetAlertTeams(ctx context.Context, arg ResetAlertTeamsParams) error

ResetAlertTeams forgets the Teams of Alerts that start firing, which InsertAlertTeams then records anew, and records the value of the Team label that names no Team, empty for none; an Alert whose value stays the same is not written.

func (*Queries) ResolveDestinations

func (q *Queries) ResolveDestinations(ctx context.Context, arg ResolveDestinationsParams) ([]ResolveDestinationsRow, error)

ResolveDestinations reads the Destinations that are not deleted among the public_ids, for the Destinations of a Route.

func (*Queries) ResolveRouteChains

func (q *Queries) ResolveRouteChains(ctx context.Context, arg ResolveRouteChainsParams) ([]ResolveRouteChainsRow, error)

ResolveRouteChains reads the Escalation chains among the public_ids FOR KEY SHARE, for the chains of a Route: the deletion of a chain locks it FOR UPDATE and then reads the entries that name it, so it either sees this save's entry or this save waits and then finds the chain gone.

func (*Queries) RestampAlertRoutes

func (q *Queries) RestampAlertRoutes(ctx context.Context, arg RestampAlertRoutesParams) error

RestampAlertRoutes records another Route for the current firing of Alerts: the Default route, for Alerts whose Route was deleted while their Snapshot waited for it.

func (*Queries) SetAlertRoutes

func (q *Queries) SetAlertRoutes(ctx context.Context, arg SetAlertRoutesParams) error

SetAlertRoutes records the Route and the Severity level of the current firing of each Alert; a route id of 0 and an empty raw value are null.

func (*Queries) SetRouteDestinationConditions

func (q *Queries) SetRouteDestinationConditions(ctx context.Context, arg SetRouteDestinationConditionsParams) error

SetRouteDestinationConditions changes the Severity conditions of Destinations a Route keeps, one each.

func (*Queries) SetRoutePositions

func (q *Queries) SetRoutePositions(ctx context.Context, arg SetRoutePositionsParams) error

SetRoutePositions rewrites the positions of the Routes.

func (*Queries) ShareTeamEvaluation

func (q *Queries) ShareTeamEvaluation(ctx context.Context, arg ShareTeamEvaluationParams) error

ShareTeamEvaluation takes the transaction advisory lock of the evaluation of the Teams (db.TeamEvaluationLockClass, keyed by the Organization) shared, before the Snapshot reads the stamp of the classification: the evaluation of a save takes it exclusively, so it waits for a Snapshot that classified with the Teams before the save.

func (*Queries) UpdateRoute

func (q *Queries) UpdateRoute(ctx context.Context, arg UpdateRouteParams) error

UpdateRoute replaces the configured fields of a Route and bumps its version; urgent is written as minimum_severity = 'critical', which a 0.1 replica of a rolling update still reads (C-26.FR-10).

func (*Queries) UpsertRouteChains

func (q *Queries) UpsertRouteChains(ctx context.Context, arg UpsertRouteChainsParams) error

UpsertRouteChains adds Escalation chains to a Route now with their Severity conditions, and changes the condition of those it has, which keep the time they were added.

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type ResetAlertTeamsParams

type ResetAlertTeamsParams struct {
	OrgID         int64
	Ids           []int64
	UnknownValues []string
}

type ResolveDestinationsParams

type ResolveDestinationsParams struct {
	OrgID     int64
	PublicIds []string
}

type ResolveDestinationsRow

type ResolveDestinationsRow struct {
	ID       int64
	PublicID string
}

type ResolveRouteChainsParams

type ResolveRouteChainsParams struct {
	OrgID     int64
	PublicIds []string
}

type ResolveRouteChainsRow

type ResolveRouteChainsRow struct {
	ID       int64
	PublicID string
}

type RestampAlertRoutesParams

type RestampAlertRoutesParams struct {
	RouteID pgtype.Int8
	OrgID   int64
	Ids     []int64
}

type SetAlertRoutesParams

type SetAlertRoutesParams struct {
	OrgID          int64
	Ids            []int64
	RouteIds       []int64
	SeverityLevels []string
	SeverityRaws   []string
}

type SetRouteDestinationConditionsParams

type SetRouteDestinationConditionsParams struct {
	OrgID          int64
	RouteID        int64
	DestinationIds []int64
	Conditions     []string
}

type SetRoutePositionsParams

type SetRoutePositionsParams struct {
	OrgID     int64
	Ids       []int64
	Positions []int64
}

type ShareTeamEvaluationParams

type ShareTeamEvaluationParams struct {
	LockClass int32
	OrgID     int64
}

type UpdateRouteParams

type UpdateRouteParams struct {
	Name                           string
	Description                    string
	MinimumSeverity                string
	GroupKey                       []string
	ReopenWindowSeconds            int64
	GracePeriodSeconds             int64
	UrgentRiseRemovesAck           bool
	SnoozeDurationsSeconds         []int64
	ThreadBatchingWindowSeconds    int64
	StormThreshold                 int64
	Language                       string
	TemplateRootMessage            pgtype.Text
	TemplateLine                   pgtype.Text
	TemplateAckTimeoutNotice       pgtype.Text
	AckTimeoutEnabled              bool
	AckTimeoutFirstIntervalSeconds int64
	RemindersEnabled               bool
	RemindersFirstIntervalSeconds  int64
	RemindersCapSeconds            int64
	AutoUnacknowledge              bool
	OwningTeamID                   pgtype.Int8
	MessageLabels                  []string
	DeliverToTeams                 bool
	RunTeamChains                  bool
	ManagedBy                      pgtype.Text
	Now                            time.Time
	OrgID                          int64
	ID                             int64
}

type UpsertRouteChainsParams

type UpsertRouteChainsParams struct {
	OrgID      int64
	RouteID    int64
	Now        time.Time
	ChainIds   []int64
	Conditions []string
}

Jump to

Keyboard shortcuts

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