Moved broadly useful helper functions upstream into feedkit

This commit is contained in:
2026-03-28 11:29:09 -05:00
parent 4910440756
commit 3ef93faf69
6 changed files with 591 additions and 0 deletions

27
sinks/helpers.go Normal file
View File

@@ -0,0 +1,27 @@
package sinks
import (
"fmt"
"strings"
"gitea.maximumdirect.net/ejr/feedkit/config"
)
// RegisterPostgresSchemaForConfiguredSinks registers one Postgres schema for each
// configured sink using driver=postgres.
func RegisterPostgresSchemaForConfiguredSinks(cfg *config.Config, schema PostgresSchema) error {
if cfg == nil {
return fmt.Errorf("register postgres schemas: config is nil")
}
for i, sk := range cfg.Sinks {
if !strings.EqualFold(strings.TrimSpace(sk.Driver), "postgres") {
continue
}
if err := RegisterPostgresSchema(sk.Name, schema); err != nil {
return fmt.Errorf("register postgres schema for sinks[%d] name=%q: %w", i, sk.Name, err)
}
}
return nil
}