Files
William Gill 12bf35caf8 anchorage v1.0 initial tree
Greenfield Go multi-tenant IPFS Pinning Service wire-compatible with the
IPFS Pinning Services API spec. Paired 1:1 with Kubo over localhost RPC,
clustered via embedded NATS JetStream, Postgres source-of-truth with
RLS-enforced tenancy, Fiber + huma v2 for the HTTP surface, Authentik
OIDC for session login with kid-rotated HS256 JWT API tokens.

Feature-complete against the 22-milestone build plan, including the
ship-it v1.0 gap items:

  * admin CLIs: drain/uncordon, maintenance, mint-token, rotate-key,
    prune-denylist, rebalance --dry-run, cache-stats, cluster-presences
  * TTL leader election via NATS KV, fence tokens, JetStream dedup
  * rebalancer (plan/apply split), reconciler, requeue sweeper
  * ristretto caches with NATS-backed cross-node invalidation
    (placements live-nodes + token denylist)
  * maintenance watchdog for stuck cluster-pause flag
  * Prometheus /metrics with CIDR ACL, HTTP/pin/scheduler/cache gauges
  * rate limiting: session (10/min) + anonymous global (120/min)
  * integration tests: rebalance, refcount multi-org, RLS belt
  * goreleaser (tar + deb/rpm/apk + Alpine Docker) targeting Gitea

Stack: Cobra/Viper, Fiber v2 + huma v2, embedded NATS JetStream,
pgx/sqlc/golang-migrate, ristretto, TypeID, prometheus/client_golang,
testcontainers-go.
2026-04-16 18:13:36 -05:00

129 lines
2.5 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: orgs.sql
package sqlc
import (
"context"
"anchorage/internal/pkg/ids"
)
const createOrg = `-- name: CreateOrg :one
INSERT INTO orgs (id, slug, name)
VALUES ($1, $2, $3)
RETURNING id, slug, name, created_at, updated_at
`
type CreateOrgParams struct {
ID ids.OrgID
Slug string
Name string
}
func (q *Queries) CreateOrg(ctx context.Context, arg CreateOrgParams) (Org, error) {
row := q.db.QueryRow(ctx, createOrg, arg.ID, arg.Slug, arg.Name)
var i Org
err := row.Scan(
&i.ID,
&i.Slug,
&i.Name,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getOrgByID = `-- name: GetOrgByID :one
SELECT id, slug, name, created_at, updated_at FROM orgs WHERE id = $1
`
func (q *Queries) GetOrgByID(ctx context.Context, id ids.OrgID) (Org, error) {
row := q.db.QueryRow(ctx, getOrgByID, id)
var i Org
err := row.Scan(
&i.ID,
&i.Slug,
&i.Name,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getOrgBySlug = `-- name: GetOrgBySlug :one
SELECT id, slug, name, created_at, updated_at FROM orgs WHERE slug = $1
`
func (q *Queries) GetOrgBySlug(ctx context.Context, slug string) (Org, error) {
row := q.db.QueryRow(ctx, getOrgBySlug, slug)
var i Org
err := row.Scan(
&i.ID,
&i.Slug,
&i.Name,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const listOrgs = `-- name: ListOrgs :many
SELECT id, slug, name, created_at, updated_at FROM orgs ORDER BY id DESC LIMIT $1 OFFSET $2
`
type ListOrgsParams struct {
Limit int32
Offset int32
}
func (q *Queries) ListOrgs(ctx context.Context, arg ListOrgsParams) ([]Org, error) {
rows, err := q.db.Query(ctx, listOrgs, arg.Limit, arg.Offset)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Org
for rows.Next() {
var i Org
if err := rows.Scan(
&i.ID,
&i.Slug,
&i.Name,
&i.CreatedAt,
&i.UpdatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const updateOrgName = `-- name: UpdateOrgName :one
UPDATE orgs SET name = $2 WHERE id = $1 RETURNING id, slug, name, created_at, updated_at
`
type UpdateOrgNameParams struct {
ID ids.OrgID
Name string
}
func (q *Queries) UpdateOrgName(ctx context.Context, arg UpdateOrgNameParams) (Org, error) {
row := q.db.QueryRow(ctx, updateOrgName, arg.ID, arg.Name)
var i Org
err := row.Scan(
&i.ID,
&i.Slug,
&i.Name,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}