Go · 2150 bytes Raw Blame History
1 // Code generated by sqlc. DO NOT EDIT.
2 // versions:
3 // sqlc v1.31.1
4
5 package ratelimitdb
6
7 import (
8 "context"
9
10 "github.com/jackc/pgx/v5/pgtype"
11 )
12
13 type Querier interface {
14 // Concurrent-lease variant for long-lived streams. `hits` is the
15 // currently-held lease count. The ttl rolls stale rows forward so a process
16 // crash or severed TCP connection cannot consume capacity indefinitely.
17 AcquireRateLimitLease(ctx context.Context, db DBTX, arg AcquireRateLimitLeaseParams) (AcquireRateLimitLeaseRow, error)
18 // SPDX-License-Identifier: AGPL-3.0-or-later
19 //
20 // Generic rate-limit counter queries (S35). Two write paths:
21 // * BumpRateLimit — atomic UPSERT that rolls the window forward
22 // when stale, increments hits otherwise. Returns
23 // the post-update hits + window_started_at so
24 // the caller can compute Retry-After without a
25 // second round trip.
26 // * BumpSignupIPThrottle — same shape against signup_ip_throttle
27 // keyed by inet/CIDR.
28 //
29 // Reads (PeekRateLimit, PeekSignupIPThrottle) are kept around for
30 // the admin observability surface; the hot path uses Bump-and-decide.
31 // Roll-or-increment in one statement. The CASE in the UPDATE branch
32 // handles the window roll: when the existing window started before
33 // (now - $3 interval), we treat it as a new window and reset hits
34 // to 1; otherwise we increment in place.
35 BumpRateLimit(ctx context.Context, db DBTX, arg BumpRateLimitParams) (BumpRateLimitRow, error)
36 // Same UPSERT shape against the inet-keyed signup throttle.
37 BumpSignupIPThrottle(ctx context.Context, db DBTX, arg BumpSignupIPThrottleParams) (BumpSignupIPThrottleRow, error)
38 PeekRateLimit(ctx context.Context, db DBTX, arg PeekRateLimitParams) (RateLimit, error)
39 PruneRateLimits(ctx context.Context, db DBTX, retention pgtype.Interval) (int64, error)
40 PruneSignupIPThrottle(ctx context.Context, db DBTX, retention pgtype.Interval) (int64, error)
41 ReleaseRateLimitLease(ctx context.Context, db DBTX, arg ReleaseRateLimitLeaseParams) (int64, error)
42 }
43
44 var _ Querier = (*Queries)(nil)
45