Refactor feedkit boundaries ahead of v1
Remove global Postgres schema registration in favor of explicit schema-aware sink factory wiring, and update weatherfeeder to register the Postgres sink explicitly. Add optional per-source HTTP timeout and response body limit overrides while keeping feedkit defaults. Remove remaining legacy source/config compatibility surfaces, including singular kind support and old source registry/type aliases, and migrate weatherfeeder sources to plural `Kinds()` metadata. Clean up related docs, tests, and sample config to match the new Postgres, HTTP, and NATS configuration model.
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/ejr/feedkit/event"
|
||||
@@ -72,51 +71,6 @@ type postgresTableCompiled struct {
|
||||
indexes []PostgresIndex
|
||||
}
|
||||
|
||||
var (
|
||||
postgresSchemaRegistryMu sync.RWMutex
|
||||
postgresSchemaRegistry = map[string]postgresSchemaCompiled{}
|
||||
)
|
||||
|
||||
// RegisterPostgresSchema registers one downstream schema by sink name.
|
||||
//
|
||||
// This should be called by downstream daemon wiring code before sink
|
||||
// construction. Duplicate sink-name registrations are rejected.
|
||||
func RegisterPostgresSchema(sinkName string, schema PostgresSchema) error {
|
||||
sinkName = strings.TrimSpace(sinkName)
|
||||
if sinkName == "" {
|
||||
return fmt.Errorf("postgres schema: sink name cannot be empty")
|
||||
}
|
||||
|
||||
compiled, err := compilePostgresSchema(schema)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
postgresSchemaRegistryMu.Lock()
|
||||
defer postgresSchemaRegistryMu.Unlock()
|
||||
|
||||
if _, exists := postgresSchemaRegistry[sinkName]; exists {
|
||||
return fmt.Errorf("postgres schema: sink %q already registered", sinkName)
|
||||
}
|
||||
|
||||
postgresSchemaRegistry[sinkName] = compiled
|
||||
return nil
|
||||
}
|
||||
|
||||
func MustRegisterPostgresSchema(sinkName string, schema PostgresSchema) {
|
||||
if err := RegisterPostgresSchema(sinkName, schema); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func lookupPostgresSchema(sinkName string) (postgresSchemaCompiled, bool) {
|
||||
postgresSchemaRegistryMu.RLock()
|
||||
defer postgresSchemaRegistryMu.RUnlock()
|
||||
|
||||
s, ok := postgresSchemaRegistry[sinkName]
|
||||
return s, ok
|
||||
}
|
||||
|
||||
func compilePostgresSchema(schema PostgresSchema) (postgresSchemaCompiled, error) {
|
||||
if schema.MapEvent == nil {
|
||||
return postgresSchemaCompiled{}, fmt.Errorf("postgres schema: map function is required")
|
||||
|
||||
Reference in New Issue
Block a user