205 lines
14 KiB
Go
205 lines
14 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
type Querier interface {
|
|
// Adds recipients to the day and the month row. The caller holds their
|
|
// locks from LockMailQuotaRows and has checked both limits.
|
|
AddMailQuotaUsage(ctx context.Context, arg AddMailQuotaUsageParams) (int64, error)
|
|
// Consumes a token in one statement. Concurrent callers queue on the token
|
|
// row lock; under READ COMMITTED each waiter re-checks the WHERE clause
|
|
// against the committed row, so exactly one of them updates it. The join
|
|
// compares the registration version with the account row as the statement
|
|
// reads it, without locking that row, so it rejects a token from an earlier
|
|
// registration that already committed but not one that commits afterwards.
|
|
// The confirmation guarantee therefore needs MarkUserEmailVerified with the
|
|
// returned registration version in the same transaction, rolled back when it
|
|
// matches no row.
|
|
ConsumeEmailToken(ctx context.Context, arg ConsumeEmailTokenParams) (EmailToken, error)
|
|
DeleteMailRequest(ctx context.Context, id pgtype.UUID) (int64, error)
|
|
// Deletes one batch of accounts that stayed unverified since before cutoff,
|
|
// oldest first, with their tokens, sessions, mail requests, and mail
|
|
// deliveries (and through the deliveries their attempts). Every lock is taken
|
|
// with SKIP LOCKED, so the statement never waits: an account whose row is
|
|
// locked, for example by a re-registration, a token insert, or a delivery
|
|
// insert, is skipped, and so is an account with any token, session, mail
|
|
// request, or delivery row locked, for example by a confirmation that
|
|
// consumed a token, the delivery consumer, or a worker recording an attempt.
|
|
// Skipped accounts stay for the next run.
|
|
// Taking the account lock before the token locks is the reverse of the
|
|
// documented order, which is safe only because no lock here waits.
|
|
// An account qualifies only when every token, session, mail request, and
|
|
// delivery row visible to the statement was locked above.
|
|
DeleteUnverifiedUsersRegisteredBefore(ctx context.Context, arg DeleteUnverifiedUsersRegisteredBeforeParams) (int64, error)
|
|
// Lock order. Every transaction that writes mail_quota_usage first creates
|
|
// and locks all the usage rows it will touch with EnsureMailQuotaRows and
|
|
// LockMailQuotaRows, which both work in (period_kind, period_start) order,
|
|
// and only then writes them or a mail_quota_reservations row. Later UPDATE
|
|
// statements of the same transaction find their rows locked already, so the
|
|
// scan order of an UPDATE never decides the lock order.
|
|
// Creates the listed window rows of a provider account with no usage when
|
|
// they do not exist yet, in (period_kind, period_start) order. A window key
|
|
// is "<period_kind>/<YYYY-MM-DD>". A concurrent insert of the same row waits
|
|
// for the first transaction and then inserts nothing. Existing rows are
|
|
// neither changed nor locked here.
|
|
EnsureMailQuotaRows(ctx context.Context, arg EnsureMailQuotaRowsParams) error
|
|
// Returns the newest open reservation of a delivery under a provider account
|
|
// made at or after reserved_since. A retry of the delivery inside the
|
|
// provider's idempotency window reuses it instead of counting again.
|
|
FindOpenMailQuotaReservation(ctx context.Context, arg FindOpenMailQuotaReservationParams) (FindOpenMailQuotaReservationRow, error)
|
|
GetActiveSessionByTokenHash(ctx context.Context, arg GetActiveSessionByTokenHashParams) (Session, error)
|
|
GetDeliveryByID(ctx context.Context, id pgtype.UUID) (Delivery, error)
|
|
// Among the versions of a family already effective at a time, the newest
|
|
// publication wins. A version scheduled for later therefore never undoes a
|
|
// version published after it. The unique (policy_key, version) index serves
|
|
// the backward scan.
|
|
GetEffectivePolicyVersion(ctx context.Context, arg GetEffectivePolicyVersionParams) (PolicyVersion, error)
|
|
// Explains why ConsumeEmailToken matched no row.
|
|
GetEmailTokenState(ctx context.Context, arg GetEmailTokenStateParams) (GetEmailTokenStateRow, error)
|
|
// Reads the status of the newest delivery of a kind addressed to an account,
|
|
// for the account's own view of its mail. It selects no address and no
|
|
// content. The recipient index narrows the scan to the account's rows.
|
|
GetLatestDeliveryStatus(ctx context.Context, arg GetLatestDeliveryStatusParams) (GetLatestDeliveryStatusRow, error)
|
|
GetLatestPolicyVersion(ctx context.Context, policyKey string) (PolicyVersion, error)
|
|
// Reads the usage of the day and the month window without locking.
|
|
GetMailQuotaUsage(ctx context.Context, arg GetMailQuotaUsageParams) ([]GetMailQuotaUsageRow, error)
|
|
// Reads the relay backlog for metrics without locking. Both subqueries use
|
|
// the partial index on unpublished positions, so the cost follows the backlog
|
|
// size, not the table size. The age comes from the database clock, the same
|
|
// clock that set occurred_at.
|
|
GetOutboxBacklog(ctx context.Context) (GetOutboxBacklogRow, error)
|
|
GetPolicyVersionByID(ctx context.Context, id pgtype.UUID) (PolicyVersion, error)
|
|
GetUserByEmailNormalized(ctx context.Context, emailNormalized string) (User, error)
|
|
GetUserByID(ctx context.Context, id pgtype.UUID) (User, error)
|
|
// Stores a record that a consumer could not apply. A second delivery of the
|
|
// same record (same position and value) refreshes the outcome of its row:
|
|
// after a rewind the handler may fail differently. A different value at a
|
|
// reused position, after the topic was recreated, gets its own row.
|
|
InsertConsumerDeadLetter(ctx context.Context, arg InsertConsumerDeadLetterParams) error
|
|
// Stores a new delivery. A delivery with the same ID already exists when the
|
|
// same request is handled again; the statement then inserts nothing and
|
|
// returns 0 rows, and the stored content stays as it was. While another
|
|
// transaction holds an uncommitted row with the same ID, the insert waits
|
|
// for it.
|
|
InsertDelivery(ctx context.Context, arg InsertDeliveryParams) (int64, error)
|
|
InsertEmailToken(ctx context.Context, arg InsertEmailTokenParams) error
|
|
InsertMailQuotaReservation(ctx context.Context, arg InsertMailQuotaReservationParams) error
|
|
InsertMailRequest(ctx context.Context, arg InsertMailRequestParams) error
|
|
InsertOutboxEvent(ctx context.Context, arg InsertOutboxEventParams) error
|
|
// Stores a version and returns the stored row with the publication time and
|
|
// effective time set by the stamp trigger. A taken ID or version number
|
|
// returns no row instead of an error, so a conflict does not abort the
|
|
// surrounding transaction. created_at is never taken from the caller, and a
|
|
// NULL effective_at means "at publication".
|
|
InsertPolicyVersion(ctx context.Context, arg InsertPolicyVersionParams) (PolicyVersion, error)
|
|
// Records that a consumer applies an event, in the transaction of the effect.
|
|
// It returns 0 rows when the marker exists. While another transaction holds
|
|
// an uncommitted marker for the same key, the insert waits for it: after a
|
|
// commit it returns 0, after a rollback it inserts. So a concurrent duplicate
|
|
// never runs the effect at the same time as the first delivery.
|
|
InsertProcessedEventMarker(ctx context.Context, arg InsertProcessedEventMarkerParams) (int64, error)
|
|
InsertSession(ctx context.Context, arg InsertSessionParams) error
|
|
InsertUser(ctx context.Context, arg InsertUserParams) error
|
|
InvalidateActiveEmailTokens(ctx context.Context, arg InvalidateActiveEmailTokensParams) (int64, error)
|
|
ListDeliveryAttempts(ctx context.Context, deliveryID pgtype.UUID) ([]DeliveryAttempt, error)
|
|
// Lists the other accounts of a provider that have usage in a month, so
|
|
// startup can warn about a renamed EMAIL_ACCOUNT.
|
|
ListOtherMailQuotaAccounts(ctx context.Context, arg ListOtherMailQuotaAccountsParams) ([]string, error)
|
|
// Locks the listed window rows until the transaction ends, in
|
|
// (period_kind, period_start) order, the same order for every caller, and
|
|
// returns their usage. Under READ COMMITTED a waiting caller reads the usage
|
|
// the first caller committed. period_starts narrows the index scan;
|
|
// window_keys selects the exact rows.
|
|
LockMailQuotaRows(ctx context.Context, arg LockMailQuotaRowsParams) ([]LockMailQuotaRowsRow, error)
|
|
// Locks a request for the consumer transaction that turns it into a
|
|
// delivery. A concurrent consumer of the same request waits here and then
|
|
// finds the row deleted. The account cleanup and the cascade from users take
|
|
// the same row lock, so a request is never converted for an account whose
|
|
// deletion is in progress without one of the two transactions waiting.
|
|
LockMailRequest(ctx context.Context, id pgtype.UUID) (MailRequest, error)
|
|
// Locks the next relay batch. For each aggregate only its earliest unpublished
|
|
// event (lowest aggregate_version, then position) qualifies, so a relay never
|
|
// holds a later version while an earlier one is still pending, whether that
|
|
// earlier row is locked by another relay or was just rolled back. Rows locked
|
|
// by another relay are skipped without waiting. The statement snapshot can
|
|
// only see a later version after the earlier version's transaction committed,
|
|
// because aggregate writers check the expected version, so scanning without a
|
|
// position watermark cannot overtake an earlier version.
|
|
LockPendingOutboxEvents(ctx context.Context, batchLimit int32) ([]LockPendingOutboxEventsRow, error)
|
|
// Records that the provider refused a send because the quota of a window is
|
|
// used up: the usage rises to at least the configured limit, so the local
|
|
// gate stops admitting sends until the window resets or an operator raises
|
|
// the limit. The caller holds the row lock.
|
|
MarkMailQuotaExhausted(ctx context.Context, arg MarkMailQuotaExhaustedParams) (int64, error)
|
|
// Marks the events that the broker acknowledged. The relay passes only IDs
|
|
// whose rows its own transaction locked, so the statement never waits and the
|
|
// count equals the number of distinct IDs.
|
|
MarkOutboxEventsPublished(ctx context.Context, eventIds []pgtype.UUID) (int64, error)
|
|
// Verifies the email only for the registration version the consumed token
|
|
// was issued for.
|
|
MarkUserEmailVerified(ctx context.Context, arg MarkUserEmailVerifiedParams) (User, error)
|
|
Ping(ctx context.Context) (int32, error)
|
|
// Reports whether a family has any version without reading a document, so a
|
|
// caller that only needs presence never depends on decoding.
|
|
PolicyVersionExists(ctx context.Context, policyKey string) (bool, error)
|
|
// Advances a delivery past one attempt and appends the attempt in one
|
|
// statement, so both happen or neither does, inside or outside a
|
|
// transaction. The update applies only while the stored version still
|
|
// equals expected_version; otherwise nothing is written and the statement
|
|
// returns 0 rows. Two workers that record the same attempt number therefore
|
|
// cannot both succeed. Content columns are not touched; a trigger refuses
|
|
// any change to them.
|
|
RecordDeliveryAttempt(ctx context.Context, arg RecordDeliveryAttemptParams) (int64, error)
|
|
// Records the latest settled outcome of a send under the reservation.
|
|
RecordMailQuotaOutcome(ctx context.Context, arg RecordMailQuotaOutcomeParams) (int64, error)
|
|
// Marks a reservation released. It matches only an open reservation, so a
|
|
// repeated release changes nothing and returns 0 rows.
|
|
ReleaseMailQuotaReservation(ctx context.Context, arg ReleaseMailQuotaReservationParams) (int64, error)
|
|
// Gives back recipients of a released reservation. The caller holds the row
|
|
// locks. A window that the provider reported exhausted keeps its usage: the
|
|
// provider's answer outranks the local count until the window resets. The
|
|
// count never drops below zero.
|
|
ReleaseMailQuotaUsage(ctx context.Context, arg ReleaseMailQuotaUsageParams) (int64, error)
|
|
RevokeSession(ctx context.Context, arg RevokeSessionParams) (int64, error)
|
|
RevokeUserSessions(ctx context.Context, arg RevokeUserSessionsParams) (int64, error)
|
|
// Bounds a consumer transaction on the server, local to the transaction.
|
|
// statement_timeout stops a slow statement; idle_in_transaction_session_timeout
|
|
// ends the session of a process that froze or lost the network inside the
|
|
// handler, which releases the processed-event marker that a concurrent
|
|
// duplicate waits for.
|
|
SetConsumerTransactionTimeouts(ctx context.Context, arg SetConsumerTransactionTimeoutsParams) error
|
|
// Bounds the claim transaction on the server. statement_timeout stops a
|
|
// statement that runs too long; idle_in_transaction_session_timeout ends the
|
|
// session, and with it the transaction and its row locks, when the client
|
|
// stays silent longer than a publish may take, for example after the process
|
|
// froze or lost the network without closing the connection. Both settings
|
|
// are local to the transaction.
|
|
SetRelayTransactionTimeouts(ctx context.Context, arg SetRelayTransactionTimeoutsParams) error
|
|
// Records activity on an active session and reports whether it is active.
|
|
// The row is written only when last_seen_at is older than touch_cutoff, so
|
|
// frequent requests do not rewrite it. last_seen_at never moves back, and a
|
|
// revoked, expired, or idle session is not revived; the update re-checks
|
|
// those conditions against a concurrent change.
|
|
TouchSession(ctx context.Context, arg TouchSessionParams) (TouchSessionRow, error)
|
|
// Stores a change of the delivery state that is not an attempt: a quota wait
|
|
// or a new provider account before the first attempt. It applies only while
|
|
// the stored version still equals expected_version and returns 0 rows
|
|
// otherwise. The trigger refuses a provider change after an attempt.
|
|
UpdateDeliveryState(ctx context.Context, arg UpdateDeliveryStateParams) (int64, error)
|
|
// Replaces the registration of an unverified account and advances the
|
|
// registration version in the same statement, so no caller can choose it.
|
|
// The version check rejects a writer that read an older row; a verified
|
|
// account never changes.
|
|
UpdateUserRegistration(ctx context.Context, arg UpdateUserRegistrationParams) (User, error)
|
|
}
|
|
|
|
var _ Querier = (*Queries)(nil)
|