2026-03-28 11:29:09 -05:00
|
|
|
package sinks
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"gitea.maximumdirect.net/ejr/feedkit/config"
|
|
|
|
|
)
|
|
|
|
|
|
2026-03-28 13:02:37 -05:00
|
|
|
// requireStringParam returns a non-empty string sink param.
|
|
|
|
|
//
|
|
|
|
|
// This helper is intentionally local to sinks rather than config so
|
|
|
|
|
// driver-specific validation stays close to the adapters that use it.
|
|
|
|
|
func requireStringParam(cfg config.SinkConfig, key string) (string, error) {
|
|
|
|
|
v, ok := cfg.Params[key]
|
|
|
|
|
if !ok {
|
|
|
|
|
return "", fmt.Errorf("sink %q: params.%s is required", cfg.Name, key)
|
|
|
|
|
}
|
|
|
|
|
s, ok := v.(string)
|
|
|
|
|
if !ok {
|
|
|
|
|
return "", fmt.Errorf("sink %q: params.%s must be a string", cfg.Name, key)
|
|
|
|
|
}
|
|
|
|
|
if strings.TrimSpace(s) == "" {
|
|
|
|
|
return "", fmt.Errorf("sink %q: params.%s cannot be empty", cfg.Name, key)
|
|
|
|
|
}
|
|
|
|
|
return s, nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-28 13:52:48 -05:00
|
|
|
// PostgresFactory returns a sink factory that builds the built-in Postgres sink
|
|
|
|
|
// using the provided downstream schema definition.
|
|
|
|
|
func PostgresFactory(schema PostgresSchema) Factory {
|
|
|
|
|
return func(cfg config.SinkConfig) (Sink, error) {
|
|
|
|
|
return NewPostgresSinkFromConfig(cfg, schema)
|
2026-03-28 11:29:09 -05:00
|
|
|
}
|
|
|
|
|
}
|