mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
- Generate Server/db/dbgen/{events,plugins}.sql.go and full Server/db/pgdbgen/ (//go:build postgres gated)
- Implement PostgresStore EventStore and PluginStore methods in store/postgres.go
- Wire plugin host_events.go EventSink into hub broadcast path (SetPluginEventSink)
- Wire host_commands.go slash-command dispatcher: chat_command V1 handler + hub.SetPluginRegistry
- Add handlers_command.go + handlers_command_test.go for plugin slash-command dispatch
- Add reconnect_db_test.go: TestReconnect_BufferMiss_FallsBackToDBTier (cold-tier DB replay)
- Add otel-up/otel-down Makefile targets; docker-compose.otel.yml + prometheus.dev.yml
- Update PHASE_BC_LOCAL_TODO.md: mark in-session items complete; document remaining network-blocked steps
- Minor fixes: channel_handler access-control, router plugin handler wiring, service span instrumentation
75 lines
1.9 KiB
Go
75 lines
1.9 KiB
Go
//go:build postgres
|
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: lockouts.sql
|
|
|
|
package pgdbgen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const cleanupExpiredLockouts = `-- name: CleanupExpiredLockouts :exec
|
|
DELETE FROM rate_lockouts WHERE expires_at <= $1
|
|
`
|
|
|
|
func (q *Queries) CleanupExpiredLockouts(ctx context.Context, expiresAt pgtype.Timestamptz) error {
|
|
_, err := q.db.Exec(ctx, cleanupExpiredLockouts, expiresAt)
|
|
return err
|
|
}
|
|
|
|
const deleteLockout = `-- name: DeleteLockout :exec
|
|
DELETE FROM rate_lockouts WHERE key = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteLockout(ctx context.Context, key string) error {
|
|
_, err := q.db.Exec(ctx, deleteLockout, key)
|
|
return err
|
|
}
|
|
|
|
const loadActiveLockouts = `-- name: LoadActiveLockouts :many
|
|
SELECT key, expires_at FROM rate_lockouts WHERE expires_at > $1
|
|
`
|
|
|
|
func (q *Queries) LoadActiveLockouts(ctx context.Context, expiresAt pgtype.Timestamptz) ([]RateLockout, error) {
|
|
rows, err := q.db.Query(ctx, loadActiveLockouts, expiresAt)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []RateLockout{}
|
|
for rows.Next() {
|
|
var i RateLockout
|
|
if err := rows.Scan(&i.Key, &i.ExpiresAt); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const upsertLockout = `-- name: UpsertLockout :exec
|
|
|
|
INSERT INTO rate_lockouts (key, expires_at) VALUES ($1, $2)
|
|
ON CONFLICT (key) DO UPDATE SET expires_at = EXCLUDED.expires_at
|
|
`
|
|
|
|
type UpsertLockoutParams struct {
|
|
Key string `json:"key"`
|
|
ExpiresAt pgtype.Timestamptz `json:"expiresAt"`
|
|
}
|
|
|
|
// PostgreSQL variants of the sqlite rate-lockout queries.
|
|
// `INSERT OR REPLACE` becomes `INSERT ... ON CONFLICT (key) DO UPDATE`.
|
|
func (q *Queries) UpsertLockout(ctx context.Context, arg UpsertLockoutParams) error {
|
|
_, err := q.db.Exec(ctx, upsertLockout, arg.Key, arg.ExpiresAt)
|
|
return err
|
|
}
|