Moved broadly useful helper functions upstream into feedkit
This commit is contained in:
27
sinks/helpers.go
Normal file
27
sinks/helpers.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user