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 AddCallItemParams

type AddCallItemParams struct {
	OrgID                 int64
	CallID                int64
	AlertGroupID          int64
	Now                   time.Time
	EscalationRunID       pgtype.Int8
	NotificationRuleRunID pgtype.Int8
	PageID                pgtype.Int8
}

type BreakGatewayParams

type BreakGatewayParams struct {
	Now       time.Time
	Reason    string
	NextProbe time.Time
	OrgID     int64
	ID        int64
	FailedAt  pgtype.Timestamptz
}

type BreakGatewayRow

type BreakGatewayRow struct {
	PublicID string
	Name     string
}

type CallContactParams

type CallContactParams struct {
	OrgID        int64
	UserID       int64
	ConnectionID int64
}

type CallContactRow

type CallContactRow struct {
	ID      int64
	Contact string
}

type ClaimDueCallsParams

type ClaimDueCallsParams struct {
	Owner      string
	LeaseUntil time.Time
	OrgID      int64
	Due        time.Time
	Now        time.Time
	Lim        int32
}

type ClaimDueCallsRow

type ClaimDueCallsRow struct {
	ID            int64
	PublicID      string
	ConnectionID  int64
	UserID        int64
	Critical      bool
	NextAttemptAt time.Time
}

type ClaimGatewayProbesParams

type ClaimGatewayProbesParams struct {
	Owner      string
	LeaseUntil time.Time
	NextProbe  time.Time
	OrgID      int64
	Due        time.Time
	Now        time.Time
	Lim        int32
}

type ClaimGatewayProbesRow

type ClaimGatewayProbesRow struct {
	ID       int64
	PublicID string
	Name     string
}

type ConfirmContactParams

type ConfirmContactParams struct {
	Now   time.Time
	OrgID int64
	ID    int64
}

type ConfirmedContactParams

type ConfirmedContactParams struct {
	OrgID        int64
	UserID       int64
	ConnectionID int64
}

type CountContactCodesParams

type CountContactCodesParams struct {
	Since       time.Time
	OrgID       int64
	ContactHash []byte
}

type CountContactCodesRow

type CountContactCodesRow struct {
	Requests int64
	Oldest   time.Time
}

type CountUserCodesParams

type CountUserCodesParams struct {
	Since  time.Time
	OrgID  int64
	UserID int64
}

type CountUserCodesRow

type CountUserCodesRow struct {
	Requests int64
	Oldest   time.Time
}

type CountUserContactCodesParams

type CountUserContactCodesParams struct {
	Since       time.Time
	OrgID       int64
	UserID      int64
	ContactHash []byte
}

type CountUserContactCodesRow

type CountUserContactCodesRow struct {
	Requests int64
	Oldest   time.Time
}

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 DeleteCodeParams

type DeleteCodeParams struct {
	OrgID int64
	ID    int64
}

type DeleteContactParams

type DeleteContactParams struct {
	OrgID int64
	ID    int64
}

type DeleteReplacedContactsParams

type DeleteReplacedContactsParams struct {
	OrgID        int64
	UserID       int64
	ConnectionID int64
	Keep         int64
}

type DeleteReplacedContactsRow

type DeleteReplacedContactsRow struct {
	PublicID string
	Contact  string
}

type DeleteUnconfirmedContactsParams

type DeleteUnconfirmedContactsParams struct {
	OrgID        int64
	UserID       int64
	ConnectionID int64
}

type DeleteUnconfirmedContactsRow

type DeleteUnconfirmedContactsRow struct {
	PublicID string
	Contact  string
}

type DeleteUserCodesParams

type DeleteUserCodesParams struct {
	OrgID  int64
	UserID int64
}

type DeleteUserContactsParams

type DeleteUserContactsParams struct {
	OrgID  int64
	UserID int64
}

type DeleteUserContactsRow

type DeleteUserContactsRow struct {
	PublicID           string
	Contact            string
	Confirmed          bool
	ConnectionPublicID string
	ConnectionName     string
}

type DropCallItemsParams

type DropCallItemsParams struct {
	Now           time.Time
	OrgID         int64
	CallID        int64
	AlertGroupIds []int64
}

type EndCallParams

type EndCallParams struct {
	State          string
	Reason         pgtype.Text
	NotificationID pgtype.Text
	Attempted      int64
	Now            time.Time
	ErrorClass     pgtype.Text
	Error          pgtype.Text
	OrgID          int64
	ID             int64
	Owner          string
}

type EndGatewayBrokenParams

type EndGatewayBrokenParams struct {
	RecoveredAt time.Time
	OrgID       int64
	Owner       pgtype.Text
	Now         time.Time
	ID          int64
}

type EndGatewayBrokenRow

type EndGatewayBrokenRow struct {
	PublicID       string
	Name           string
	WasBrokenSince time.Time
	Deleted        bool
}

type FailGatewayProbeParams

type FailGatewayProbeParams struct {
	Reason string
	OrgID  int64
	ID     int64
	Owner  string
	Now    time.Time
}

type GetAcknowledgedCallParams

type GetAcknowledgedCallParams struct {
	OrgID        int64
	ConnectionID int64
	PublicID     string
}

type GetAcknowledgedCallRow

type GetAcknowledgedCallRow struct {
	ID             int64
	PublicID       string
	State          string
	NotificationID pgtype.Text
	EndedAt        pgtype.Timestamptz
	UserID         int64
	UserPublicID   string
	UserRole       string
	UserStatus     string
	UserLanguage   pgtype.Text
}

type GetGatewayByIDParams

type GetGatewayByIDParams struct {
	OrgID int64
	ID    int64
}

type GetGatewayByIDRow

type GetGatewayByIDRow struct {
	ID       int64
	PublicID string
	Name     string
}

type GetGatewayParams

type GetGatewayParams struct {
	OrgID    int64
	PublicID string
}

type GetGatewayRow

type GetGatewayRow struct {
	ID       int64
	PublicID string
	Name     string
}

type GetGatewayStateParams

type GetGatewayStateParams struct {
	OrgID    int64
	PublicID string
}

type GetGatewayStateRow

type GetGatewayStateRow struct {
	ID     int64
	Broken bool
}

type GetLeasedCallParams

type GetLeasedCallParams struct {
	OrgID int64
	ID    int64
	Owner string
	Now   time.Time
}

type GetLeasedCallRow

type GetLeasedCallRow struct {
	ID                 int64
	PublicID           string
	ConnectionID       int64
	UserID             int64
	State              string
	Critical           bool
	Language           pgtype.Text
	Text               pgtype.Text
	Attempts           int64
	FirstFailedAt      pgtype.Timestamptz
	FirstAttemptAt     pgtype.Timestamptz
	ActionData         pgtype.Text
	ConnectionPublicID string
	ConnectionName     string
	Gateway            bool
	GatewayBroken      bool
	UserPublicID       string
	UserName           string
	UserLogin          string
	UserLanguage       pgtype.Text
	Contact            pgtype.Text
}

type GetPageGroupIDParams

type GetPageGroupIDParams struct {
	OrgID    int64
	PublicID string
}

type GetPageParams

type GetPageParams struct {
	OrgID        int64
	AlertGroupID int64
	ConnectionID int64
	UserID       int64
}

type GetPageRow

type GetPageRow struct {
	Number             int64
	Critical           bool
	ConnectionPublicID string
	UserPublicID       string
}

type GetUserByPublicIDParams

type GetUserByPublicIDParams struct {
	OrgID    int64
	PublicID string
}

type GetUserByPublicIDRow

type GetUserByPublicIDRow struct {
	ID       int64
	PublicID string
	Status   string
}

type InsertCodeParams

type InsertCodeParams struct {
	OrgID       int64
	UserID      int64
	ContactID   pgtype.Int8
	ContactHash []byte
	SessionID   int64
	CodeHash    []byte
	CreatedAt   time.Time
	ExpiresAt   time.Time
}

type InsertContactParams

type InsertContactParams struct {
	OrgID        int64
	PublicID     string
	UserID       int64
	ConnectionID int64
	Contact      string
	CreatedAt    time.Time
}

type InsertWaitingCallParams

type InsertWaitingCallParams struct {
	OrgID        int64
	PublicID     string
	ConnectionID int64
	UserID       int64
	Critical     bool
	NotBefore    pgtype.Timestamptz
	Now          time.Time
}

type ListCallGroupsParams

type ListCallGroupsParams struct {
	OrgID  int64
	CallID int64
}

type ListCallGroupsRow

type ListCallGroupsRow struct {
	ID            int64
	PublicID      string
	Number        int64
	Title         string
	SeverityLevel string
	Status        string
	Stopped       bool
}

type ListCallableUsersParams

type ListCallableUsersParams struct {
	OrgID        int64
	ConnectionID int64
	UserIds      []int64
}

type ListContactsOfUserParams

type ListContactsOfUserParams struct {
	OrgID  int64
	UserID int64
}

type ListContactsOfUserRow

type ListContactsOfUserRow struct {
	ID                 int64
	PublicID           string
	Contact            string
	ConfirmedAt        pgtype.Timestamptz
	CreatedAt          time.Time
	ConnectionPublicID string
	ConnectionName     string
	Replaces           pgtype.Text
}

type ListGatewayHealthRow

type ListGatewayHealthRow struct {
	PublicID string
	Broken   bool
}

type ListGatewaysRow

type ListGatewaysRow struct {
	ID       int64
	PublicID string
	Name     string
}

type ListUnmarkedFailuresParams

type ListUnmarkedFailuresParams struct {
	Since time.Time
	OrgID int64
}

type ListUnmarkedFailuresRow

type ListUnmarkedFailuresRow struct {
	ID         int64
	PublicID   string
	Reason     string
	ErrorClass string
	Error      string
	EndedAt    time.Time
}

type LockCallPersonParams

type LockCallPersonParams struct {
	LockClass    int32
	OrgID        int64
	ConnectionID int64
	UserID       int64
}

type LockContactOfUserParams

type LockContactOfUserParams struct {
	OrgID    int64
	UserID   int64
	PublicID string
}

type LockContactOfUserRow

type LockContactOfUserRow struct {
	ID                 int64
	PublicID           string
	ConnectionID       int64
	Contact            string
	ConfirmedAt        pgtype.Timestamptz
	CreatedAt          time.Time
	ConnectionPublicID string
	ConnectionName     string
	Gateway            bool
	Replaces           pgtype.Text
}

type LockContactTextParams

type LockContactTextParams struct {
	LockClass   int32
	OrgID       int64
	ContactHash []byte
}

type LockContactUserParams

type LockContactUserParams struct {
	OrgID int64
	ID    int64
}

type LockContactUserRow

type LockContactUserRow struct {
	ID       int64
	PublicID string
	Language pgtype.Text
	Status   string
}

type LockGatewayStateParams

type LockGatewayStateParams struct {
	LockClass int32
	ID        int64
}

type LockNewestCodeParams

type LockNewestCodeParams struct {
	OrgID     int64
	ContactID pgtype.Int8
}

type LockNewestCodeRow

type LockNewestCodeRow struct {
	ID           int64
	SessionID    int64
	CodeHash     []byte
	Attempts     int64
	ExpiresAt    time.Time
	UsedAt       pgtype.Timestamptz
	VoidedAt     pgtype.Timestamptz
	SessionEnded bool
}

type LockWaitingCallParams

type LockWaitingCallParams struct {
	OrgID        int64
	ConnectionID int64
	UserID       int64
}

type LockWaitingCallRow

type LockWaitingCallRow struct {
	ID       int64
	PublicID string
}

type MarkCallCriticalParams

type MarkCallCriticalParams struct {
	OrgID int64
	ID    int64
}

type MarkCodeSentParams

type MarkCodeSentParams struct {
	Now   time.Time
	OrgID int64
	ID    int64
}

type NextCallWorkParams

type NextCallWorkParams struct {
	Now   time.Time
	OrgID int64
}

type NextCallWorkRow

type NextCallWorkRow struct {
	FreeAt   time.Time
	LeaseEnd time.Time
}

type NextGatewayProbeParams

type NextGatewayProbeParams struct {
	Now   time.Time
	OrgID int64
}

type NextGatewayProbeRow

type NextGatewayProbeRow struct {
	FreeAt   time.Time
	LeaseEnd time.Time
}

type PreviousCallParams

type PreviousCallParams struct {
	OrgID        int64
	ConnectionID int64
	UserID       int64
}

type PreviousCallRow

type PreviousCallRow struct {
	State   string
	EndedAt pgtype.Timestamptz
}

type PruneCodesParams

type PruneCodesParams struct {
	OrgID     int64
	Before    time.Time
	BatchSize int32
}

type PruneEndedCallsParams

type PruneEndedCallsParams struct {
	OrgID     int64
	Now       time.Time
	BatchSize int32
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) AddCallItem

func (q *Queries) AddCallItem(ctx context.Context, arg AddCallItemParams) error

AddCallItem adds an Alert Group to a waiting call with the Page that queued it and the stop check that Page passed: the run of its chain and the rule run of a call action, none for the hook of muster dev. One it is about already takes the Page and the stop check of this later Page, as a chain that started over and Paged again — a later Page of the hook, without them, keeps those of the last Page that had them; one dropped from it while it waited — a preparation that dropped it and then found no limiter token — is queued again.

func (*Queries) BreakGateway

func (q *Queries) BreakGateway(ctx context.Context, arg BreakGatewayParams) (BreakGatewayRow, error)

The Broken state of Notification gateways (C-30.FR-8, broken.go): a call answered with a Fatal error, or one that used up delivery.transient_budget, makes its gateway's Connection Broken; any replica probes it through info every delivery.broken_probe_interval, claimed with a lease, and a successful probe or Connection check ends the state. BreakGateway makes the Connection of a Notification gateway Broken with reason, probed first at @next_probe. With @failed_at, the end of the call that failed, only when its last Broken state, if any, ended before it, so that the reconciliation never breaks it again for a call that the end of the state followed. No row when it is Broken already, deleted, not a Bridge Connection or recovered since the call failed.

func (*Queries) CallContact

func (q *Queries) CallContact(ctx context.Context, arg CallContactParams) (CallContactRow, error)

CallContact reads the confirmed contact of a User at a Notification gateway that is not deleted, the one a call's first attempt goes to.

func (*Queries) ClaimDueCalls

func (q *Queries) ClaimDueCalls(ctx context.Context, arg ClaimDueCallsParams) ([]ClaimDueCallsRow, error)

ClaimDueCalls leases the due calls that wait for their first attempt or are being retried, whose lease is free or ran out, critical first, then by when they are due. The choice is a materialized CTE, run once, as in ClaimDueDeliveries.

func (*Queries) ClaimGatewayProbes

func (q *Queries) ClaimGatewayProbes(ctx context.Context, arg ClaimGatewayProbesParams) ([]ClaimGatewayProbesRow, error)

ClaimGatewayProbes leases the Broken gateways that are not deleted whose probe is due and whose lease is free or ran out, and moves their next probe to @next_probe, so that a probe that a replica dies in is made again after delivery.broken_probe_interval. The choice is a materialized CTE, run once, as in ClaimDueCalls.

func (*Queries) ConfirmContact

func (q *Queries) ConfirmContact(ctx context.Context, arg ConfirmContactParams) error

func (*Queries) ConfirmedContact

func (q *Queries) ConfirmedContact(ctx context.Context, arg ConfirmedContactParams) (string, error)

ConfirmedContact reads the confirmed contact of a User at a Notification gateway that is not deleted, the one that is called.

func (*Queries) CountContactCodes

func (q *Queries) CountContactCodes(ctx context.Context, arg CountContactCodesParams) (CountContactCodesRow, error)

CountContactCodes counts the codes for one contact text asked for after since, by any User, with the oldest of them.

func (*Queries) CountUserCodes

func (q *Queries) CountUserCodes(ctx context.Context, arg CountUserCodesParams) (CountUserCodesRow, error)

CountUserCodes counts the codes a User asked for after since, with the oldest of them.

func (*Queries) CountUserContactCodes

func (q *Queries) CountUserContactCodes(ctx context.Context, arg CountUserContactCodesParams) (CountUserContactCodesRow, error)

CountUserContactCodes counts the codes a User asked for to one contact text after since, with the oldest of them.

func (*Queries) DeleteCode

func (q *Queries) DeleteCode(ctx context.Context, arg DeleteCodeParams) error

DeleteCode deletes a code that was never sent, since no limiter token was free: it does not count.

func (*Queries) DeleteContact

func (q *Queries) DeleteContact(ctx context.Context, arg DeleteContactParams) (int64, error)

func (*Queries) DeleteReplacedContacts

func (q *Queries) DeleteReplacedContacts(ctx context.Context, arg DeleteReplacedContactsParams) ([]DeleteReplacedContactsRow, error)

DeleteReplacedContacts deletes the confirmed contacts of a User at a gateway other than keep, which the confirmation of keep replaces.

func (*Queries) DeleteUnconfirmedContacts

func (q *Queries) DeleteUnconfirmedContacts(ctx context.Context, arg DeleteUnconfirmedContactsParams) ([]DeleteUnconfirmedContactsRow, error)

DeleteUnconfirmedContacts deletes the unconfirmed contacts of a User at a gateway, which a new contact replaces; the codes keep counting toward the limits without them.

func (*Queries) DeleteUserCodes

func (q *Queries) DeleteUserCodes(ctx context.Context, arg DeleteUserCodesParams) (int64, error)

func (*Queries) DeleteUserContacts

func (q *Queries) DeleteUserContacts(ctx context.Context, arg DeleteUserContactsParams) ([]DeleteUserContactsRow, error)

DeleteUserContacts deletes every contact of a User and returns them with their gateways (C-03.FR-13).

func (*Queries) DropCallItems

func (q *Queries) DropCallItems(ctx context.Context, arg DropCallItemsParams) error

DropCallItems drops from a call, before its first attempt, the Alert Groups that stopped.

func (*Queries) EndCall

func (q *Queries) EndCall(ctx context.Context, arg EndCallParams) (bool, error)

EndCall ends a call — accepted, Not delivered with its reason, or dropped — counting the attempt that ended it, if one did, and clears its text, which names its Alert Groups, and its action data, which are never sent again; the language and the id of the key that signed the data stay. It returns whether the call went, which starts the combine window of the next one.

func (*Queries) EndGatewayBroken

func (q *Queries) EndGatewayBroken(ctx context.Context, arg EndGatewayBrokenParams) (EndGatewayBrokenRow, error)

EndGatewayBroken ends the Broken state of a gateway at @recovered_at and frees the lease of its probe, and tells when it became Broken and whether the Connection is deleted; it locks the row once, by the update, after the gateway's advisory lock (LockGatewayState). A probe passes its owner: then only while this replica still holds the probe's lease at the real time @now. No row when it is not Broken, or the probe's lease is not held.

func (*Queries) FailGatewayProbe

func (q *Queries) FailGatewayProbe(ctx context.Context, arg FailGatewayProbeParams) (int64, error)

FailGatewayProbe records the error of a failed probe as the reason of the Broken gateway and frees its lease, while this replica still holds it at the real time @now; no row changes when the lease ran out or went to another replica, or the state ended.

func (*Queries) GetAcknowledgedCall

func (q *Queries) GetAcknowledgedCall(ctx context.Context, arg GetAcknowledgedCallParams) (GetAcknowledgedCallRow, error)

GetAcknowledgedCall reads the call public_id of a Notification gateway's Connection, whatever its state, with the notification_id the gateway accepted it under and when it ended, and with the User it was for — Role, state, name and profile language — for the Acknowledge of a notification_acknowledged event (C-30.FR-6). No row for a call of another Connection or Organization, or none.

func (*Queries) GetGateway

func (q *Queries) GetGateway(ctx context.Context, arg GetGatewayParams) (GetGatewayRow, error)

GetGateway reads the Notification gateway public_id, which is not deleted.

func (*Queries) GetGatewayByID

func (q *Queries) GetGatewayByID(ctx context.Context, arg GetGatewayByIDParams) (GetGatewayByIDRow, error)

GetGatewayByID reads the Notification gateway by internal id, which is not deleted and still declares the role gateway: the gateway of a call step.

func (*Queries) GetGatewayState

func (q *Queries) GetGatewayState(ctx context.Context, arg GetGatewayStateParams) (GetGatewayStateRow, error)

GetGatewayState reads the Connection public_id, deleted ones included, with whether it is a Broken gateway, for the resolve of an open MusterNotificationGatewayBroken of a gateway that is not Broken, under the gateway's advisory lock. No row when no Connection of the Organization has the public_id.

func (*Queries) GetLeasedCall

func (q *Queries) GetLeasedCall(ctx context.Context, arg GetLeasedCallParams) (GetLeasedCallRow, error)

GetLeasedCall reads, and locks, a call whose lease this replica still holds at the real time now, with its gateway and whether it is still a Notification gateway, not deleted, and whether the call came due while the gateway was Broken — it is Broken, or the call's due time lies before the end of its last Broken state, which another replica ended after this one claimed the call (P-68); this holds within the replicas' clock skew, so a Page made on a replica whose clock is behind by δ, within δ after the end, may be ended too, accepted as NTP keeps δ to milliseconds and MusterClockSkew fires above 2 s — its User and, from its first attempt, its contact while that is still confirmed and its signed action data, null for a call that a replica of an earlier version started. No row when the lease ran out or went to another replica, or the call ended.

func (*Queries) GetPage

func (q *Queries) GetPage(ctx context.Context, arg GetPageParams) (GetPageRow, error)

The calls through Notification gateways (C-30.FR-4): a row per call to a person through a gateway, the Alert Groups it is about, claimed with a lease by any replica's gateway sender (sender.go, calls.go). GetPage reads what a Page names: the Alert Group, with whether it is critical, which puts its call first; the Notification gateway, not deleted; and the User, not deleted. No row when one of them is not so.

func (*Queries) GetPageGroupID

func (q *Queries) GetPageGroupID(ctx context.Context, arg GetPageGroupIDParams) (int64, error)

GetPageGroupID reads the internal id of the Alert Group public_id, for the hook of muster dev.

func (*Queries) GetUserByPublicID

func (q *Queries) GetUserByPublicID(ctx context.Context, arg GetUserByPublicIDParams) (GetUserByPublicIDRow, error)

GetUserByPublicID reads a User an Admin names, deleted ones included.

func (*Queries) InsertCode

func (q *Queries) InsertCode(ctx context.Context, arg InsertCodeParams) (int64, error)

func (*Queries) InsertContact

func (q *Queries) InsertContact(ctx context.Context, arg InsertContactParams) (int64, error)

func (*Queries) InsertWaitingCall

func (q *Queries) InsertWaitingCall(ctx context.Context, arg InsertWaitingCallParams) (int64, error)

InsertWaitingCall creates the call that waits for its first attempt, due at not_before, never while it is null.

func (*Queries) ListCallGroups

func (q *Queries) ListCallGroups(ctx context.Context, arg ListCallGroupsParams) ([]ListCallGroupsRow, error)

ListCallGroups lists the Alert Groups a call is about, without those dropped before its first attempt, by number, each with whether the chain or the rule that Paged has stopped on it (C-30.FR-4), the stop check its item keeps: the Alert Group is no longer firing — acknowledged, snoozed or resolved —; the run of its chain stopped, or is of an earlier start of its chains, which a start-over left as it was when it had run out; or the rule run of a call action stopped.

func (*Queries) ListCallableUsers

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

ListCallableUsers lists those of the Users user_ids who have a confirmed contact at the Notification gateway, whom a Page through it may call.

func (*Queries) ListContactsOfUser

func (q *Queries) ListContactsOfUser(ctx context.Context, arg ListContactsOfUserParams) ([]ListContactsOfUserRow, error)

ListContactsOfUser lists the contacts of a User with their gateway, by gateway and creation, each unconfirmed one with the confirmed contact it replaces once confirmed.

func (*Queries) ListGatewayHealth

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

ListGatewayHealth lists the Notification gateways that are not deleted, and the Broken ones whose stored info no longer declares the role gateway, each with whether it is Broken, for muster_notification_gateway_broken.

func (*Queries) ListGateways

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

SPDX-License-Identifier: AGPL-3.0-only Copyright The Muster Authors Notification gateways (C-30): the Bridge Connections whose stored info declares the role gateway, the contacts of people at them and the confirmation codes of the contacts, hashed. ListGateways lists the Notification gateways that are not deleted, by name.

func (*Queries) ListUnmarkedFailures

func (q *Queries) ListUnmarkedFailures(ctx context.Context, arg ListUnmarkedFailuresParams) ([]ListUnmarkedFailuresRow, error)

ListUnmarkedFailures lists the Notification gateways that are not deleted and not Broken whose latest call that failed in a way that breaks a gateway — Not delivered with call_refused after a Fatal outcome that reached the gateway or the outbound policy (the class fatal; Muster's own refusals end gateway_deleted), or with call_budget_used — ended after @since and after the end of their last Broken state, with that call's reason, class, error and end. The Leader's reconciliation makes them Broken: the replica that ended the call stopped before it did.

func (*Queries) LockCallPerson

func (q *Queries) LockCallPerson(ctx context.Context, arg LockCallPersonParams) error

LockCallPerson takes, until the transaction ends, the lock of the calls of a User through a Notification gateway (class db.GatewayCallLockClass): a Page joining or creating the waiting call, the start of a first attempt and the end of a call serialize. A collision of the hash only serializes two people.

func (*Queries) LockContactOfUser

func (q *Queries) LockContactOfUser(ctx context.Context, arg LockContactOfUserParams) (LockContactOfUserRow, error)

LockContactOfUser locks the contact public_id of a User, with its gateway, whether that is still a Notification gateway, and the confirmed contact it replaces once confirmed.

func (*Queries) LockContactText

func (q *Queries) LockContactText(ctx context.Context, arg LockContactTextParams) error

LockContactText takes, until the transaction ends, the lock of the code requests for one contact text (class db.GatewayContactLockClass), so that the count of its requests and the new one of concurrent requests of several Users serialize. A collision of the hash only serializes two texts.

func (*Queries) LockContactUser

func (q *Queries) LockContactUser(ctx context.Context, arg LockContactUserParams) (LockContactUserRow, error)

LockContactUser locks the User whose contacts change, so that the contacts and codes of one User change one at a time.

func (*Queries) LockGatewayState

func (q *Queries) LockGatewayState(ctx context.Context, arg LockGatewayStateParams) error

LockGatewayState takes, until the transaction ends, the advisory lock of the Broken state of the gateway's Connection id (class db.GatewayStateLockClass), which every transaction of the state takes before the row.

func (*Queries) LockNewestCode

func (q *Queries) LockNewestCode(ctx context.Context, arg LockNewestCodeParams) (LockNewestCodeRow, error)

LockNewestCode locks the newest code of a contact that the gateway accepted, for checking it, with whether the web session that asked for it ended; a code whose sending failed, or that is still being sent, is never the one checked. Newest is by id, as VoidEarlierCodes counts earlier, not by created_at, which replicas may set with skewed clocks.

func (*Queries) LockWaitingCall

func (q *Queries) LockWaitingCall(ctx context.Context, arg LockWaitingCallParams) (LockWaitingCallRow, error)

LockWaitingCall locks the call of a User through a gateway that waits for its first attempt.

func (*Queries) MarkCallCritical

func (q *Queries) MarkCallCritical(ctx context.Context, arg MarkCallCriticalParams) error

MarkCallCritical makes a waiting call critical once a critical Alert Group joins it.

func (*Queries) MarkCodeSent

func (q *Queries) MarkCodeSent(ctx context.Context, arg MarkCodeSentParams) error

MarkCodeSent records that the gateway accepted the notification of a code, which makes it the one checked.

func (*Queries) NextCallWork

func (q *Queries) NextCallWork(ctx context.Context, arg NextCallWorkParams) (NextCallWorkRow, error)

NextCallWork is when the next call can be claimed: the earliest due time of a call without a live lease (business clock), and the earliest end of a live lease (real clock), the zero time for none.

func (*Queries) NextGatewayProbe

func (q *Queries) NextGatewayProbe(ctx context.Context, arg NextGatewayProbeParams) (NextGatewayProbeRow, error)

NextGatewayProbe is when the next probe of a Broken gateway that is not deleted is due (business clock), and the earliest end of a live lease of one (real clock), the zero time for none.

func (*Queries) NotifyCalls

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

NotifyCalls wakes the gateway senders of every replica once the transaction commits.

func (*Queries) PreviousCall

func (q *Queries) PreviousCall(ctx context.Context, arg PreviousCallParams) (PreviousCallRow, error)

PreviousCall reads the latest call of a User through a gateway that went — whose first attempt was made, or tried — with its state and its end, null while it is being sent.

func (*Queries) PruneCodes

func (q *Queries) PruneCodes(ctx context.Context, arg PruneCodesParams) (int64, error)

PruneCodes deletes up to batch_size codes that expired before @before, used and void ones included. A code being checked is skipped and taken at the next run. The batch is chosen once, in a materialized CTE, as PruneLinkRequests does.

func (*Queries) PruneEndedCalls

func (q *Queries) PruneEndedCalls(ctx context.Context, arg PruneEndedCallsParams) (int64, error)

PruneEndedCalls deletes up to batch_size calls that ended at or before @now and are about no Alert Group any more: the retention of Alert Groups deleted every one of theirs, and its cascade their items. The batch is chosen once, in a materialized CTE, as PruneCodes does; a call that another transaction holds is taken at the next run.

func (*Queries) RecordCallRetry

func (q *Queries) RecordCallRetry(ctx context.Context, arg RecordCallRetryParams) (int64, error)

RecordCallRetry counts a failed attempt of the budget and makes the call due again at a later time.

func (*Queries) RecordWrongCode

func (q *Queries) RecordWrongCode(ctx context.Context, arg RecordWrongCodeParams) (int64, error)

RecordWrongCode counts a wrong code; the attempt that reaches max_attempts voids the code.

func (*Queries) ReleaseWaitingCall

func (q *Queries) ReleaseWaitingCall(ctx context.Context, arg ReleaseWaitingCallParams) error

ReleaseWaitingCall sets when the call that waits behind a call being sent may go, once that call ended.

func (*Queries) RenewCallLease

func (q *Queries) RenewCallLease(ctx context.Context, arg RenewCallLeaseParams) (int64, error)

RenewCallLease renews the lease of a call being retried for its next attempt.

func (*Queries) RescheduleCall

func (q *Queries) RescheduleCall(ctx context.Context, arg RescheduleCallParams) (int64, error)

RescheduleCall makes a call due again at a later time without counting an attempt — no limiter token was free, or the gateway asked to wait — and frees its lease. A gateway's RetryAfter passes failed_at, which starts the time budget of delivery.transient_budget when no failure started it yet.

func (*Queries) StartCall

func (q *Queries) StartCall(ctx context.Context, arg StartCallParams) (int64, error)

StartCall makes the first attempt of a waiting call: it keeps its contact, its text, its language and its action data, signed by the key button_key_id, from now on, takes no more Alert Groups and is due now, its lease renewed for the attempt.

func (*Queries) UnstartCall

func (q *Queries) UnstartCall(ctx context.Context, arg UnstartCallParams) (int64, error)

UnstartCall undoes the start of a call that its round stopped before it was made (sender.go, gate): it waits again, due at @at, without its contact, language, text, action data and the id of their key, and frees its lease, so that the Pages that come due join it and its Alert Groups are read again right before its first attempt, as when its preparation had found no limiter token. Only a call this replica holds the lease of, started and never attempted, and only while no call waits behind it: the caller holds the person's lock, and a Page that came due since the start queued a call that waits behind it; the call then stays started (no row).

func (*Queries) UpdateGatewayBrokenReason

func (q *Queries) UpdateGatewayBrokenReason(ctx context.Context, arg UpdateGatewayBrokenReasonParams) (int64, error)

UpdateGatewayBrokenReason keeps a Broken gateway Broken with the error of its last failure as the reason; it returns whether the gateway was Broken.

func (*Queries) UseCode

func (q *Queries) UseCode(ctx context.Context, arg UseCodeParams) (int64, error)

UseCode marks the code used; a used code is void.

func (*Queries) VoidCode

func (q *Queries) VoidCode(ctx context.Context, arg VoidCodeParams) error

VoidCode voids a code whose sending failed; it still counts toward the limits.

func (*Queries) VoidEarlierCodes

func (q *Queries) VoidEarlierCodes(ctx context.Context, arg VoidEarlierCodesParams) (int64, error)

VoidEarlierCodes voids the codes of a contact asked for before keep that are neither used nor void, which keep replaces once the gateway accepted it.

func (*Queries) WithTx

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

type RecordCallRetryParams

type RecordCallRetryParams struct {
	Now        time.Time
	At         time.Time
	ErrorClass string
	Error      pgtype.Text
	OrgID      int64
	ID         int64
	Owner      string
}

type RecordWrongCodeParams

type RecordWrongCodeParams struct {
	MaxAttempts int64
	Now         time.Time
	OrgID       int64
	ID          int64
}

type ReleaseWaitingCallParams

type ReleaseWaitingCallParams struct {
	At           time.Time
	OrgID        int64
	ConnectionID int64
	UserID       int64
}

type RenewCallLeaseParams

type RenewCallLeaseParams struct {
	LeaseUntil time.Time
	OrgID      int64
	ID         int64
	Owner      string
}

type RescheduleCallParams

type RescheduleCallParams struct {
	At         time.Time
	FailedAt   pgtype.Timestamptz
	ErrorClass pgtype.Text
	Error      pgtype.Text
	OrgID      int64
	ID         int64
	Owner      string
}

type StartCallParams

type StartCallParams struct {
	ContactID   pgtype.Int8
	Language    string
	Text        string
	ActionData  pgtype.Text
	ButtonKeyID pgtype.Text
	Now         time.Time
	LeaseUntil  time.Time
	OrgID       int64
	ID          int64
	Owner       string
}

type UnstartCallParams

type UnstartCallParams struct {
	At    time.Time
	OrgID int64
	ID    int64
	Owner string
}

type UpdateGatewayBrokenReasonParams

type UpdateGatewayBrokenReasonParams struct {
	Reason string
	OrgID  int64
	ID     int64
}

type UseCodeParams

type UseCodeParams struct {
	Now   time.Time
	OrgID int64
	ID    int64
}

type VoidCodeParams

type VoidCodeParams struct {
	Now   time.Time
	OrgID int64
	ID    int64
}

type VoidEarlierCodesParams

type VoidEarlierCodesParams struct {
	Now       time.Time
	OrgID     int64
	ContactID pgtype.Int8
	Keep      int64
}

Jump to

Keyboard shortcuts

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