28 lines
695 B
Go
28 lines
695 B
Go
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
|
|
}
|