657fca325e
Adds opt-in extension package internal/automc/ that: - Subscribes to Postgres notifications on a 'servers' table and pushes route changes into server.Routes (no file I/O, no fsnotify). - Provides a WakerFunc that POSTs to a configurable HTTP control plane (server-manager) and polls until state=running. When AUTOMC_DSN is unset, Wire() is a no-op and the binary behaves exactly like upstream itzg/mc-router. Single patch site in main.go (import + 4-line call) keeps upstream rebases trivial. See docs/AUTOMC.md for env vars and the expected DB schema/trigger.
25 lines
596 B
Go
25 lines
596 B
Go
// Package automc wires automc-specific extensions onto upstream mc-router.
|
|
//
|
|
// All behavior is opt-in via env vars; when AUTOMC_DSN is unset, Wire is a no-op
|
|
// and the binary behaves exactly like upstream itzg/mc-router.
|
|
package automc
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func Wire(ctx context.Context) error {
|
|
dsn := os.Getenv("AUTOMC_DSN")
|
|
if dsn == "" {
|
|
return nil
|
|
}
|
|
waker := newWakerConfig(os.Getenv("AUTOMC_WAKER_URL"), os.Getenv("AUTOMC_WAKER_TOKEN"))
|
|
s := newSyncer(dsn, waker)
|
|
go s.run(ctx)
|
|
logrus.Info("automc: pg route sync started")
|
|
return nil
|
|
}
|