Scaffolds the server module and everything Phase 0 of PLAN.md calls for: a binary that boots, serves its discovery endpoints and nothing else yet. - config: one YAML file plus per-field WARP_* environment overrides, unknown fields rejected, validation that reports every problem at once - logging and metrics: slog, a Prometheus registry, per-route HTTP instrumentation labelled by pattern rather than path - httputil: the Matrix error envelope, error-returning handlers, CORS, request logging, panic recovery, and a router over http.ServeMux - endpoints: /_matrix/client/versions, /.well-known/matrix/client, /.well-known/matrix/server (gated), /healthz, /metrics, and M_UNRECOGNIZED for everything else - storage: driver registry, shared database/sql base, checksummed migration runner, sqlite and postgres drivers, pocketbase stub - settings: server_settings table behind a cached service, so the federation and registration switches change without a restart - federation: the gate that makes federation a runtime mode - cmd/warp: serve, migrate, generate-keys, version - Makefile, golangci-lint v2, GitHub Actions CI (Linux and Windows tests, race on Linux, storage tests against PostgreSQL, lint, boot smoke test), Dockerfile, example config and docs Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
80 lines
2.8 KiB
Go
80 lines
2.8 KiB
Go
// Package pocketbase is the placeholder for the PocketBase storage driver.
|
|
//
|
|
// The plan (PLAN.md section 4) is an appliance deployment: one binary that
|
|
// also brings admin auth, a filesystem abstraction for media (local or S3)
|
|
// and realtime for the admin panel. The event DAG is a poor fit for
|
|
// PocketBase's record model, so the roomserver and syncapi tables will use
|
|
// its underlying dbx connection directly rather than its collection API.
|
|
//
|
|
// Until that work starts (Phase 10) the driver is compiled in, registered
|
|
// and fails loudly, so that `database.driver: pocketbase` is a clear error
|
|
// instead of an unknown-driver one, and so the interface stays honest:
|
|
// every method the other drivers implement exists here too.
|
|
package pocketbase
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log/slog"
|
|
|
|
"github.com/dariuszjaniak/warp/server/internal/storage"
|
|
)
|
|
|
|
func init() {
|
|
storage.Register(storage.DriverPocketBase, Open)
|
|
}
|
|
|
|
// Database is the not-yet-implemented PocketBase driver.
|
|
type Database struct{}
|
|
|
|
// Open always fails with storage.ErrNotImplemented.
|
|
func Open(context.Context, storage.Config, *slog.Logger) (storage.Database, error) {
|
|
return nil, fmt.Errorf(
|
|
"pocketbase driver is not implemented yet (planned for Phase 10); use %q or %q: %w",
|
|
storage.DriverSQLite, storage.DriverPostgres, storage.ErrNotImplemented)
|
|
}
|
|
|
|
// Driver implements storage.Database.
|
|
func (*Database) Driver() string { return storage.DriverPocketBase }
|
|
|
|
// Ping implements storage.Database.
|
|
func (*Database) Ping(context.Context) error { return storage.ErrNotImplemented }
|
|
|
|
// Migrate implements storage.Database.
|
|
func (*Database) Migrate(context.Context) error { return storage.ErrNotImplemented }
|
|
|
|
// PendingMigrations implements storage.Database.
|
|
func (*Database) PendingMigrations(context.Context) ([]string, error) {
|
|
return nil, storage.ErrNotImplemented
|
|
}
|
|
|
|
// Settings implements storage.Database.
|
|
func (*Database) Settings() storage.SettingsStore { return notImplementedSettings{} }
|
|
|
|
// Close implements storage.Database.
|
|
func (*Database) Close() error { return nil }
|
|
|
|
// notImplementedSettings satisfies storage.SettingsStore by refusing every
|
|
// call, so a partially wired-up PocketBase deployment cannot silently lose
|
|
// an admin's federation switch.
|
|
type notImplementedSettings struct{}
|
|
|
|
func (notImplementedSettings) Get(context.Context, string) (string, bool, error) {
|
|
return "", false, storage.ErrNotImplemented
|
|
}
|
|
|
|
func (notImplementedSettings) GetAll(context.Context) (map[string]string, error) {
|
|
return nil, storage.ErrNotImplemented
|
|
}
|
|
|
|
func (notImplementedSettings) Set(context.Context, string, string) error {
|
|
return storage.ErrNotImplemented
|
|
}
|
|
|
|
func (notImplementedSettings) Delete(context.Context, string) error {
|
|
return storage.ErrNotImplemented
|
|
}
|
|
|
|
// Compile-time proof that the stub keeps up with the interface.
|
|
var _ storage.Database = (*Database)(nil)
|