Documentation
¶
Overview ¶
Package postgres provides an inspectable durable PostgreSQL rate-limit store.
Index ¶
Constants ¶
const ( DefaultTable = "goforge_rate_limits" MaxAttempts = 1_000_001 // Schema is the default plain SQL schema for application migrations. Schema = `` /* 320-byte string literal not displayed */ // DropSchema is intended for isolated integration-test cleanup. DropSchema = `DROP TABLE IF EXISTS "goforge_rate_limits";` )
Variables ¶
This section is empty.
Functions ¶
func DropSchemaFor ¶
DropSchemaFor returns a quoted cleanup statement for an isolated table.
Types ¶
type Option ¶
type Option func(*config) error
func WithPruneLimit ¶
WithPruneLimit bounds how many expired counters each Take may remove before consuming an attempt. Pruning runs first, so a pruning failure never leaves a caller unsure whether its attempt was consumed.
type SQLStatements ¶
SQLStatements exposes the exact SQL used by a Store. Values remain bind parameters; only the validated table identifier is interpolated.
func StatementsFor ¶
func StatementsFor(table string) (SQLStatements, error)
StatementsFor returns the parameterized operational SQL for a validated application-owned table without requiring a live database.
func (SQLStatements) String ¶
func (statements SQLStatements) String() string
Ensure SQL stays easy to inspect in source and diagnostics.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a durable fixed-window limiter shared by every process using its PostgreSQL table. It owns neither the database nor schema lifecycle.
func (*Store) Statements ¶
func (store *Store) Statements() SQLStatements