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:
@@ -2,55 +2,19 @@ package sinks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/ejr/feedkit/config"
|
||||
"gitea.maximumdirect.net/ejr/feedkit/event"
|
||||
)
|
||||
|
||||
func TestRegisterPostgresSchemaForConfiguredSinksNilConfig(t *testing.T) {
|
||||
err := RegisterPostgresSchemaForConfiguredSinks(nil, testPostgresSchema())
|
||||
if err == nil {
|
||||
t.Fatalf("RegisterPostgresSchemaForConfiguredSinks(nil) expected error")
|
||||
func TestPostgresFactoryReturnsWorkingFactory(t *testing.T) {
|
||||
factory := PostgresFactory(testPostgresSchema())
|
||||
if factory == nil {
|
||||
t.Fatalf("PostgresFactory() returned nil")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "config is nil") {
|
||||
t.Fatalf("error = %q, want config is nil", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterPostgresSchemaForConfiguredSinksNonPostgresNoOp(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Sinks: []config.SinkConfig{
|
||||
{Name: uniqueSinkName("stdout"), Driver: "stdout"},
|
||||
{Name: uniqueSinkName("nats"), Driver: "nats"},
|
||||
},
|
||||
}
|
||||
|
||||
if err := RegisterPostgresSchemaForConfiguredSinks(cfg, testPostgresSchema()); err != nil {
|
||||
t.Fatalf("RegisterPostgresSchemaForConfiguredSinks(non-postgres) error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegisterPostgresSchemaForConfiguredSinksDuplicateRegistrationFails(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Sinks: []config.SinkConfig{
|
||||
{Name: uniqueSinkName("pg"), Driver: "postgres"},
|
||||
},
|
||||
}
|
||||
|
||||
if err := RegisterPostgresSchemaForConfiguredSinks(cfg, testPostgresSchema()); err != nil {
|
||||
t.Fatalf("first RegisterPostgresSchemaForConfiguredSinks() error = %v", err)
|
||||
}
|
||||
|
||||
err := RegisterPostgresSchemaForConfiguredSinks(cfg, testPostgresSchema())
|
||||
if err == nil {
|
||||
t.Fatalf("second RegisterPostgresSchemaForConfiguredSinks() expected duplicate error")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "already registered") {
|
||||
t.Fatalf("error = %q, want already registered", err)
|
||||
if _, err := factory(config.SinkConfig{}); err == nil {
|
||||
t.Fatalf("factory(config) expected parameter validation error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +44,3 @@ func testPostgresSchema() PostgresSchema {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func uniqueSinkName(prefix string) string {
|
||||
return fmt.Sprintf("%s_%d", prefix, time.Now().UnixNano())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user