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 CountGenerationRunsParams

type CountGenerationRunsParams struct {
	OrgID        int64
	AlertGroupID int64
	Generation   int64
}

type CountGenerationRunsRow

type CountGenerationRunsRow struct {
	Total   int64
	RanOut  int64
	Stopped 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 DeleteChainParams

type DeleteChainParams struct {
	OrgID int64
	ID    int64
}

type DeleteRunTimersParams

type DeleteRunTimersParams struct {
	OrgID  int64
	RunIds []int64
}

type DeleteStepsParams

type DeleteStepsParams struct {
	OrgID   int64
	ChainID int64
}

type GetChainIDParams

type GetChainIDParams struct {
	OrgID    int64
	PublicID string
}

type GetChainParams

type GetChainParams struct {
	OrgID    int64
	PublicID string
}

type GetChainRow

type GetChainRow struct {
	ID           int64
	PublicID     string
	Name         string
	Description  string
	CreatedAt    time.Time
	Version      int64
	ManagedBy    pgtype.Text
	OwningTeamID pgtype.Int8
	TeamPublicID pgtype.Text
	TeamName     pgtype.Text
	TeamSlug     pgtype.Text
	TeamDeleted  bool
}

type GetOrganizationWorkingHoursRow

type GetOrganizationWorkingHoursRow struct {
	WorkingDays  []string
	WorkdayStart string
	WorkdayEnd   string
	TimeZone     string
}

type GetRunGroupParams

type GetRunGroupParams struct {
	OrgID int64
	ID    int64
}

type GetStepDestinationParams

type GetStepDestinationParams struct {
	OrgID int64
	ID    int64
}

type GetStepDestinationRow

type GetStepDestinationRow struct {
	ID          int64
	PublicID    string
	Name        string
	Type        string
	WebhookMode pgtype.Text
	Deleted     bool
}

type GetTeamIDParams

type GetTeamIDParams struct {
	OrgID    int64
	PublicID string
}

type GetTeamWorkingHoursParams

type GetTeamWorkingHoursParams struct {
	OrgID int64
	ID    int64
}

type GetTeamWorkingHoursRow

type GetTeamWorkingHoursRow struct {
	OwnWorkingHours bool
	WorkingDays     []string
	WorkingStart    pgtype.Text
	WorkingEnd      pgtype.Text
	WorkingTimeZone pgtype.Text
}

type InsertChainParams

type InsertChainParams struct {
	OrgID        int64
	PublicID     string
	Name         string
	Description  string
	OwningTeamID pgtype.Int8
	ManagedBy    pgtype.Text
	Now          time.Time
}

type InsertRunParams

type InsertRunParams struct {
	OrgID        int64
	PublicID     string
	AlertGroupID int64
	ChainID      pgtype.Int8
	ChainName    string
	OwningTeamID pgtype.Int8
	Sources      []byte
	Steps        []byte
	Generation   int64
	Now          time.Time
}

type InsertRunStepParams

type InsertRunStepParams struct {
	OrgID   int64
	RunID   int64
	Number  int32
	Kind    string
	At      time.Time
	Outcome string
	Reason  pgtype.Text
}

type InsertStepParams

type InsertStepParams struct {
	OrgID               int64
	ChainID             int64
	Position            int32
	Kind                string
	Importance          pgtype.Text
	ScheduleID          pgtype.Int8
	TeamID              pgtype.Int8
	Everyone            pgtype.Text
	CallTarget          pgtype.Text
	GatewayConnectionID pgtype.Int8
	WaitSeconds         pgtype.Int4
	DestinationID       pgtype.Int8
	RepeatFrom          pgtype.Int4
	RepeatTimes         pgtype.Int4
	WorkingHoursOnly    bool
	SeverityCondition   string
}

type InsertStepUsersParams

type InsertStepUsersParams struct {
	OrgID   int64
	StepID  int64
	UserIds []int64
}

type ListChainDestinationsParams

type ListChainDestinationsParams struct {
	OrgID    int64
	ChainIds []int64
}

type ListChainDestinationsRow

type ListChainDestinationsRow struct {
	ChainID          int64
	ID               int64
	PublicID         string
	Name             string
	Type             string
	Health           string
	BrokenSince      pgtype.Timestamptz
	BrokenReason     pgtype.Text
	UsergroupsRead   bool
	GroupMentions    bool
	Messenger        bool
	EveryoneMentions []string
}

type ListChainInfoRow

type ListChainInfoRow struct {
	PublicID string
	Name     string
}

type ListChainRunsParams

type ListChainRunsParams struct {
	OrgID    int64
	ChainID  pgtype.Int8
	AfterID  pgtype.Int8
	AfterAt  pgtype.Timestamptz
	PageSize int32
}

type ListChainRunsRow

type ListChainRunsRow struct {
	ID                        int64
	PublicID                  string
	State                     string
	StartedAt                 time.Time
	EndedAt                   pgtype.Timestamptz
	StopCommand               pgtype.Text
	GroupPublicID             string
	GroupNumber               int64
	GroupTitle                string
	GroupSeverity             string
	GroupResolvedAt           pgtype.Timestamptz
	RetentionAlertDetailsDays int64
	ActorKind                 string
	UserPublicID              pgtype.Text
	UserName                  pgtype.Text
	UserLogin                 pgtype.Text
	UserDeleted               bool
	ServiceAccountPublicID    pgtype.Text
	ServiceAccountName        pgtype.Text
	ServiceAccountDeleted     bool
}

type ListChainSourcesParams

type ListChainSourcesParams struct {
	OrgID        int64
	RouteID      int64
	AlertGroupID int64
}

type ListChainSourcesRow

type ListChainSourcesRow struct {
	Kind              string
	TeamID            int64
	ChainID           int64
	SeverityCondition string
}

type ListChainsParams

type ListChainsParams struct {
	OrgID     int64
	Q         pgtype.Text
	TeamIds   []int64
	AfterID   pgtype.Int8
	AfterName pgtype.Text
	PageSize  int32
}

type ListChainsRow

type ListChainsRow struct {
	ID           int64
	PublicID     string
	Name         string
	Description  string
	CreatedAt    time.Time
	Version      int64
	ManagedBy    pgtype.Text
	OwningTeamID pgtype.Int8
	TeamPublicID pgtype.Text
	TeamName     pgtype.Text
	TeamSlug     pgtype.Text
	TeamDeleted  bool
	SortName     string
}

type ListGatewaysRow

type ListGatewaysRow struct {
	ID       int64
	PublicID string
	Name     string
	Live     bool
}

type ListGenerationRunsParams

type ListGenerationRunsParams struct {
	OrgID        int64
	AlertGroupID int64
	Generation   int64
}

type ListGenerationRunsRow

type ListGenerationRunsRow struct {
	ID       int64
	PublicID string
	ChainID  pgtype.Int8
	State    string
	Sources  []byte
}

type ListGroupRunsParams

type ListGroupRunsParams struct {
	OrgID     int64
	PublicIds []string
}

type ListGroupRunsRow

type ListGroupRunsRow struct {
	GroupPublicID    string
	ID               int64
	PublicID         string
	ChainID          pgtype.Int8
	ChainName        string
	Sources          []byte
	Steps            []byte
	StepIndex        int32
	State            string
	StartedAt        time.Time
	ChainPublicID    pgtype.Text
	CurrentChainName pgtype.Text
	TeamPublicID     pgtype.Text
	TeamName         pgtype.Text
	TeamSlug         pgtype.Text
	TeamDeleted      bool
	Deadline         time.Time
}

type ListPeopleStatesParams

type ListPeopleStatesParams struct {
	OrgID int64
	Ids   []int64
}

type ListPeopleStatesRow

type ListPeopleStatesRow struct {
	ID       int64
	PublicID string
	Name     string
	Login    string
	Role     string
	Status   string
}

type ListRouteReferrersParams

type ListRouteReferrersParams struct {
	OrgID    int64
	ChainIds []int64
}

type ListRouteReferrersRow

type ListRouteReferrersRow struct {
	ChainID           int64
	ID                int64
	PublicID          string
	Name              string
	SeverityCondition string
}

type ListRunPagesParams

type ListRunPagesParams struct {
	OrgID  int64
	RunIds []int64
}

type ListRunPagesRow

type ListRunPagesRow struct {
	ID              int64
	RunID           int64
	StepNumber      int32
	RunStepSeq      pgtype.Int4
	StepAt          time.Time
	Kind            string
	Everyone        pgtype.Text
	State           string
	Reason          pgtype.Text
	CreatedAt       time.Time
	TeamPublicID    pgtype.Text
	TeamName        pgtype.Text
	TeamSlug        pgtype.Text
	TeamDeleted     bool
	GatewayPublicID pgtype.Text
	GatewayName     pgtype.Text
	UserPublicID    pgtype.Text
	UserName        pgtype.Text
	UserLogin       pgtype.Text
	UserStatus      pgtype.Text
}

type ListRunStepsParams

type ListRunStepsParams struct {
	OrgID  int64
	RunIds []int64
}

type ListRunStepsRow

type ListRunStepsRow struct {
	RunID   int64
	Seq     int32
	Number  int32
	Kind    string
	At      time.Time
	Outcome string
	Reason  pgtype.Text
}

type ListStepUsersParams

type ListStepUsersParams struct {
	OrgID   int64
	StepIds []int64
}

type ListStepUsersRow

type ListStepUsersRow struct {
	StepID   int64
	PublicID string
	Name     string
	Login    string
	Role     string
	Status   string
}

type ListStepsParams

type ListStepsParams struct {
	OrgID    int64
	ChainIds []int64
}

type ListStepsRow

type ListStepsRow struct {
	ID                   int64
	ChainID              int64
	Position             int32
	Kind                 string
	Importance           pgtype.Text
	Everyone             pgtype.Text
	CallTarget           pgtype.Text
	WaitSeconds          pgtype.Int4
	RepeatFrom           pgtype.Int4
	RepeatTimes          pgtype.Int4
	WorkingHoursOnly     bool
	SeverityCondition    string
	SchedulePublicID     pgtype.Text
	ScheduleName         pgtype.Text
	ScheduleTeamPublicID pgtype.Text
	ScheduleTeamName     pgtype.Text
	ScheduleTeamSlug     pgtype.Text
	ScheduleTeamDeleted  bool
	TeamPublicID         pgtype.Text
	TeamName             pgtype.Text
	TeamSlug             pgtype.Text
	TeamDeleted          bool
	GatewayPublicID      pgtype.Text
	GatewayName          pgtype.Text
	GatewayLive          bool
	DestinationPublicID  pgtype.Text
	DestinationName      pgtype.Text
	DestinationType      pgtype.Text
	DestinationMode      pgtype.Text
	DestinationDeleted   bool
}

type ListTeamReferrersParams

type ListTeamReferrersParams struct {
	OrgID    int64
	ChainIds []int64
}

type ListTeamReferrersRow

type ListTeamReferrersRow struct {
	ChainID           int64
	ID                int64
	PublicID          string
	Name              string
	Slug              string
	SeverityCondition string
}

type ListTeamRefsParams

type ListTeamRefsParams struct {
	OrgID int64
	Ids   []int64
}

type ListTeamRefsRow

type ListTeamRefsRow struct {
	ID       int64
	PublicID string
	Name     string
	Slug     string
	Deleted  bool
}

type ListUserTeamsParams

type ListUserTeamsParams struct {
	OrgID  int64
	UserID int64
}

type LockChainForDeletionParams

type LockChainForDeletionParams struct {
	OrgID    int64
	PublicID string
}

type LockChainParams

type LockChainParams struct {
	OrgID    int64
	PublicID string
}

type LockOwningTeamParams

type LockOwningTeamParams struct {
	OrgID    int64
	PublicID string
}

type LockOwningTeamRow

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

type LockRunParams

type LockRunParams struct {
	OrgID int64
	ID    int64
}

type LockRunRow

type LockRunRow struct {
	ID            int64
	PublicID      string
	AlertGroupID  int64
	ChainID       pgtype.Int8
	ChainName     string
	Steps         []byte
	StepIndex     int32
	Repeats       []byte
	State         string
	Generation    int64
	ChainPublicID pgtype.Text
	OwningTeamID  pgtype.Int8
	Sources       []byte
	StepsMade     int64
	Deadline      time.Time
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CountGenerationRuns

func (q *Queries) CountGenerationRuns(ctx context.Context, arg CountGenerationRunsParams) (CountGenerationRunsRow, error)

CountGenerationRuns counts the runs of an Alert Group in a start of its chains: all of them, those that ran out and those stopped.

func (*Queries) DeleteChain

func (q *Queries) DeleteChain(ctx context.Context, arg DeleteChainParams) error

DeleteChain deletes a chain; its steps, their people and the entries of deleted Routes go with it.

func (*Queries) DeleteRunTimers

func (q *Queries) DeleteRunTimers(ctx context.Context, arg DeleteRunTimersParams) error

DeleteRunTimers deletes the timers of the runs.

func (*Queries) DeleteSteps

func (q *Queries) DeleteSteps(ctx context.Context, arg DeleteStepsParams) error

DeleteSteps deletes the steps of a chain with their people, before a save writes them again.

func (*Queries) GetChain

func (q *Queries) GetChain(ctx context.Context, arg GetChainParams) (GetChainRow, error)

GetChain reads a chain with its owning Team.

func (*Queries) GetChainID

func (q *Queries) GetChainID(ctx context.Context, arg GetChainIDParams) (int64, error)

GetChainID reads the id of a chain by public_id.

func (*Queries) GetOrganizationWorkingHours

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

SPDX-License-Identifier: AGPL-3.0-only Copyright The Muster Authors Escalation chains (C-32): the chains with their steps and the people of their steps, what the steps name, the Routes and Teams that name a chain and the Destinations a chain writes in. GetOrganizationWorkingHours reads the Organization's Working hours, which the steps of a chain without an owning Team, or whose Team has none of its own, use.

func (*Queries) GetRunGroup

func (q *Queries) GetRunGroup(ctx context.Context, arg GetRunGroupParams) (int64, error)

GetRunGroup reads the Alert Group of a run, which the step of its timer locks first.

func (*Queries) GetStepDestination

func (q *Queries) GetStepDestination(ctx context.Context, arg GetStepDestinationParams) (GetStepDestinationRow, error)

GetStepDestination reads the Destination of a webhook step with its type and mode, deleted or not. It takes no lock: locking the Destination after the Alert Group would close cycles with the delivery worker, which locks deliveries before it updates a Destination's health, and with a Team save, which locks Destinations by id.

func (*Queries) GetTeamID

func (q *Queries) GetTeamID(ctx context.Context, arg GetTeamIDParams) (int64, error)

GetTeamID reads the id of a Team that is not deleted, for the filter by Team.

func (*Queries) GetTeamWorkingHours

func (q *Queries) GetTeamWorkingHours(ctx context.Context, arg GetTeamWorkingHoursParams) (GetTeamWorkingHoursRow, error)

GetTeamWorkingHours reads the own Working hours of a Team, deleted ones included.

func (*Queries) InsertChain

func (q *Queries) InsertChain(ctx context.Context, arg InsertChainParams) (int64, error)

InsertChain creates a chain.

func (*Queries) InsertRun

func (q *Queries) InsertRun(ctx context.Context, arg InsertRunParams) (int64, error)

InsertRun starts a run of a chain on an Alert Group at its first step, with the chain's name and owning Team.

func (*Queries) InsertRunStep

func (q *Queries) InsertRunStep(ctx context.Context, arg InsertRunStepParams) error

InsertRunStep records a step a run made or skipped, numbered after the run's last one.

func (*Queries) InsertStep

func (q *Queries) InsertStep(ctx context.Context, arg InsertStepParams) (int64, error)

InsertStep writes one step of a chain.

func (*Queries) InsertStepUsers

func (q *Queries) InsertStepUsers(ctx context.Context, arg InsertStepUsersParams) error

InsertStepUsers writes the people of a step in their order.

func (*Queries) ListChainDestinations

func (q *Queries) ListChainDestinations(ctx context.Context, arg ListChainDestinationsParams) ([]ListChainDestinationsRow, error)

ListChainDestinations lists, for each chain, the Destinations that are not deleted where it writes (C-32.FR-8): those of the Routes and of the Teams that are not deleted and name it, each once, by name, with their health and what their Connection can mention, none for an outgoing webhook or a deleted Connection. What a Connection can mention mirrors internal/mentions/query.sql GetMentionConnection; change both together.

func (*Queries) ListChainInfo

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

ListChainInfo lists every chain for muster_escalation_chain_info.

func (*Queries) ListChainRuns

func (q *Queries) ListChainRuns(ctx context.Context, arg ListChainRunsParams) ([]ListChainRunsRow, error)

ListChainRuns reads a page of the runs of a chain, newest first, after a position, with their Alert Groups — with when they resolved and retention.alert_details, which decide whether their details are removed — and what stopped them: the Command and its actor, from the lifecycle event that stopped them.

func (*Queries) ListChainSources

func (q *Queries) ListChainSources(ctx context.Context, arg ListChainSourcesParams) ([]ListChainSourcesRow, error)

The runs of Escalation chains on Alert Groups (C-32.FR-4 to FR-7, FR-14 to FR-16, FR-18). Every statement below runs in the dispatcher's transaction, after the Alert Group's lock (Lock order of runs.go). ListChainSources lists the chains that may run on an Alert Group, each by the source that names it: its Route's, and, where the Route delivers to the Teams and runs their chains, those of the Teams of the Alert Group that are not deleted, each with its Severity condition.

func (*Queries) ListChains

func (q *Queries) ListChains(ctx context.Context, arg ListChainsParams) ([]ListChainsRow, error)

ListChains reads a page of the chains by name, after a cursor, with their owning Teams; @q matches the name ignoring case, and @team_ids, when given, keeps the chains those Teams own.

func (*Queries) ListGateways

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

ListGateways lists every Bridge Connection, deleted ones included, which a call step may name, with whether it is a Notification gateway now — not deleted, its info declaring the role gateway — by name. The condition mirrors internal/gateways/query.sql ListGateways; change both together.

func (*Queries) ListGenerationRuns

func (q *Queries) ListGenerationRuns(ctx context.Context, arg ListGenerationRunsParams) ([]ListGenerationRunsRow, error)

ListGenerationRuns lists the runs of an Alert Group in a start of its chains.

func (*Queries) ListGroupRuns

func (q *Queries) ListGroupRuns(ctx context.Context, arg ListGroupRunsParams) ([]ListGroupRunsRow, error)

ListGroupRuns reads the runs of Alert Groups, by public_id, in the current start of their chains (alert_groups.chain_generation), with their chains, owning Teams and the deadline of their timers, the zero time 0001-01-01 for none.

func (*Queries) ListPeopleStates

func (q *Queries) ListPeopleStates(ctx context.Context, arg ListPeopleStatesParams) ([]ListPeopleStatesRow, error)

ListPeopleStates reads the Role and status of the people a step names, deleted ones included.

func (*Queries) ListRouteReferrers

func (q *Queries) ListRouteReferrers(ctx context.Context, arg ListRouteReferrersParams) ([]ListRouteReferrersRow, error)

ListRouteReferrers lists the Routes that are not deleted and name the chains, with their Severity conditions, by name.

func (*Queries) ListRunPages

func (q *Queries) ListRunPages(ctx context.Context, arg ListRunPagesParams) ([]ListRunPagesRow, error)

ListRunPages reads the Pages by Mention of the runs, in the order they were made, one row per person a Page names and one row with no person for a Page of a Team or of everyone in the chat (C-32.FR-18): each with the run step it belongs to — that of the rule run of a later Mention of a Notification rule, which the step that started it made, else its own; null for a Page or a rule run written before migration 0050 —, when that step was made at the latest — the start of the rule run of a later Mention or of a call action, else the Page's own time —, its Team, the Notification gateway of a call, deleted ones included, and its outcome: Pages by Mention and calls.

func (*Queries) ListRunSteps

func (q *Queries) ListRunSteps(ctx context.Context, arg ListRunStepsParams) ([]ListRunStepsRow, error)

ListRunSteps reads the steps the runs made or skipped, in their order.

func (*Queries) ListStepUsers

func (q *Queries) ListStepUsers(ctx context.Context, arg ListStepUsersParams) ([]ListStepUsersRow, error)

ListStepUsers lists the people of the steps in their order, deleted ones included.

func (*Queries) ListSteps

func (q *Queries) ListSteps(ctx context.Context, arg ListStepsParams) ([]ListStepsRow, error)

ListSteps lists the steps of the chains in their order with what they name: the Schedule with its Team, the Team, the gateway's Connection with whether it is a Notification gateway now — not deleted, its info declaring the role gateway — and the Destination with its type, mode and whether it is deleted. The condition of a live gateway mirrors internal/gateways/query.sql ListGateways; change both together.

func (*Queries) ListTeamReferrers

func (q *Queries) ListTeamReferrers(ctx context.Context, arg ListTeamReferrersParams) ([]ListTeamReferrersRow, error)

ListTeamReferrers lists the Teams that are not deleted and name the chains, with their Severity conditions, by name.

func (*Queries) ListTeamRefs

func (q *Queries) ListTeamRefs(ctx context.Context, arg ListTeamRefsParams) ([]ListTeamRefsRow, error)

ListTeamRefs names Teams by id, deleted ones included.

func (*Queries) ListUserTeams

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

ListUserTeams lists the Teams that are not deleted that a User is in, for the filter "My Teams".

func (*Queries) LockChain

func (q *Queries) LockChain(ctx context.Context, arg LockChainParams) (int64, error)

LockChain locks a chain for a change, FOR NO KEY UPDATE: the saves of Routes and Teams that name it take it FOR KEY SHARE and do not wait for a change of it.

func (*Queries) LockChainForDeletion

func (q *Queries) LockChainForDeletion(ctx context.Context, arg LockChainForDeletionParams) (int64, error)

LockChainForDeletion locks a chain FOR UPDATE before its deletion, which conflicts with the FOR KEY SHARE of a save of a Route or a Team that names it: either that save committed and its entry refuses the deletion, or it waits and then finds the chain gone.

func (*Queries) LockOwningTeam

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

LockOwningTeam reads a Team that is not deleted as the owner of a chain FOR SHARE, before the chain's row: the deletion of the Team, which locks it first FOR NO KEY UPDATE and then reads the chains it owns, either sees the chain or makes this save wait and then find the Team deleted.

func (*Queries) LockRun

func (q *Queries) LockRun(ctx context.Context, arg LockRunParams) (LockRunRow, error)

LockRun locks a run for its step, after its Alert Group, with the deadline of its timer — none, the zero time 0001-01-01, once it was stopped or replaced — the number of steps it made and skipped so far, and its sources, which say where its Pages go.

func (*Queries) NotifyRunTimers

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

NotifyRunTimers wakes the timer workers of every replica once the transaction commits.

func (*Queries) ResolveDestinations

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

ResolveDestinations reads the Destinations among the public_ids with their type and mode, deleted ones included.

func (*Queries) ResolveSchedules

func (q *Queries) ResolveSchedules(ctx context.Context, arg ResolveSchedulesParams) ([]ResolveSchedulesRow, error)

ResolveSchedules reads the Schedules among the public_ids with their Teams, FOR KEY SHARE in id order: the deletion of a Schedule locks it FOR UPDATE and then reads the steps that name it, so either it sees this save's step or this save waits and then finds the Schedule gone. KEY SHARE, unlike SHARE, does not conflict with the NO KEY UPDATE of a change of a Schedule, so a save naming two Schedules never deadlocks with making one of them main.

func (*Queries) ResolveTeams

func (q *Queries) ResolveTeams(ctx context.Context, arg ResolveTeamsParams) ([]ResolveTeamsRow, error)

ResolveTeams reads the Teams among the public_ids, deleted ones included.

func (*Queries) ResolveUsers

func (q *Queries) ResolveUsers(ctx context.Context, arg ResolveUsersParams) ([]ResolveUsersRow, error)

ResolveUsers reads the Users among the public_ids with their Role and status, deleted ones included.

func (*Queries) SaveRun

func (q *Queries) SaveRun(ctx context.Context, arg SaveRunParams) error

SaveRun writes where a run is after its steps.

func (*Queries) SetRunSources

func (q *Queries) SetRunSources(ctx context.Context, arg SetRunSourcesParams) error

SetRunSources writes the sources of a run that another source now names too (P-70).

func (*Queries) ShareChains

func (q *Queries) ShareChains(ctx context.Context, arg ShareChainsParams) ([]ShareChainsRow, error)

ShareChains reads the chains a start runs FOR KEY SHARE in id order, before any run is written: the deletion of a chain locks it FOR UPDATE first and waits, or has deleted it and the start finds it gone.

func (*Queries) SnapshotSteps

func (q *Queries) SnapshotSteps(ctx context.Context, arg SnapshotStepsParams) ([]SnapshotStepsRow, error)

SnapshotSteps reads the steps of the chains with the people of each, in one statement, so that a run takes the steps of one version of its chain (P-73).

func (*Queries) StopRuns

func (q *Queries) StopRuns(ctx context.Context, arg StopRunsParams) ([]StopRunsRow, error)

StopRuns stops the running runs of an Alert Group with what stopped them; runs that ran out stay as they are.

func (*Queries) UpdateChain

func (q *Queries) UpdateChain(ctx context.Context, arg UpdateChainParams) error

UpdateChain replaces the fields of a chain and bumps its version.

func (*Queries) UpsertRunTimer

func (q *Queries) UpsertRunTimer(ctx context.Context, arg UpsertRunTimerParams) error

UpsertRunTimer sets the timer of a run at its deadline, a new lease to claim. The subject is the run: the Alert Group and the Storm are null, and the conflict is on timers_escalation_run_key, never timers_alert_group_key.

func (*Queries) WithTx

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

type ResolveDestinationsParams

type ResolveDestinationsParams struct {
	OrgID     int64
	PublicIds []string
}

type ResolveDestinationsRow

type ResolveDestinationsRow struct {
	ID          int64
	PublicID    string
	Name        string
	Type        string
	WebhookMode pgtype.Text
	Deleted     bool
}

type ResolveSchedulesParams

type ResolveSchedulesParams struct {
	OrgID     int64
	PublicIds []string
}

type ResolveSchedulesRow

type ResolveSchedulesRow struct {
	ID           int64
	PublicID     string
	Name         string
	TeamPublicID string
	TeamName     string
	TeamSlug     string
	TeamDeleted  bool
}

type ResolveTeamsParams

type ResolveTeamsParams struct {
	OrgID     int64
	PublicIds []string
}

type ResolveTeamsRow

type ResolveTeamsRow struct {
	ID       int64
	PublicID string
	Name     string
	Slug     string
	Deleted  bool
}

type ResolveUsersParams

type ResolveUsersParams struct {
	OrgID     int64
	PublicIds []string
}

type ResolveUsersRow

type ResolveUsersRow struct {
	ID       int64
	PublicID string
	Name     string
	Login    string
	Role     string
	Status   string
}

type SaveRunParams

type SaveRunParams struct {
	StepIndex int32
	Repeats   []byte
	State     string
	EndedAt   pgtype.Timestamptz
	OrgID     int64
	ID        int64
}

type SetRunSourcesParams

type SetRunSourcesParams struct {
	Sources []byte
	OrgID   int64
	ID      int64
}

type ShareChainsParams

type ShareChainsParams struct {
	OrgID int64
	Ids   []int64
}

type ShareChainsRow

type ShareChainsRow struct {
	ID           int64
	PublicID     string
	Name         string
	OwningTeamID pgtype.Int8
}

type SnapshotStepsParams

type SnapshotStepsParams struct {
	OrgID    int64
	ChainIds []int64
}

type SnapshotStepsRow

type SnapshotStepsRow struct {
	ChainID             int64
	Position            int32
	Kind                string
	Importance          pgtype.Text
	ScheduleID          pgtype.Int8
	SchedulePublicID    pgtype.Text
	TeamID              pgtype.Int8
	Everyone            pgtype.Text
	CallTarget          pgtype.Text
	GatewayConnectionID pgtype.Int8
	WaitSeconds         pgtype.Int4
	DestinationID       pgtype.Int8
	RepeatFrom          pgtype.Int4
	RepeatTimes         pgtype.Int4
	WorkingHoursOnly    bool
	SeverityCondition   string
	UserIds             []int64
}

type StopRunsParams

type StopRunsParams struct {
	Now          pgtype.Timestamptz
	StopCommand  pgtype.Text
	StopEventSeq pgtype.Int8
	OrgID        int64
	AlertGroupID int64
}

type StopRunsRow

type StopRunsRow struct {
	ID            int64
	PublicID      string
	ChainPublicID string
}

type UpdateChainParams

type UpdateChainParams struct {
	Name         string
	Description  string
	OwningTeamID pgtype.Int8
	ManagedBy    pgtype.Text
	Now          time.Time
	OrgID        int64
	ID           int64
}

type UpsertRunTimerParams

type UpsertRunTimerParams struct {
	OrgID           int64
	EscalationRunID int64
	Deadline        time.Time
	Now             time.Time
}

Jump to

Keyboard shortcuts

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