move init functions to top of file

This commit is contained in:
Joel Wetzell
2026-05-22 17:45:03 -05:00
parent fb3c775765
commit 4323a21015
67 changed files with 1706 additions and 1706 deletions
+45 -45
View File
@@ -13,6 +13,51 @@ import (
"github.com/jwetzell/showbridge-go/internal/config"
)
func init() {
RegisterProcessor(ProcessorRegistration{
Type: "pubsub.publish",
Title: "Publish to Pub/Sub Topic",
ParamsSchema: &jsonschema.Schema{
Type: "object",
Properties: map[string]*jsonschema.Schema{
"module": {
Title: "Module ID",
Type: "string",
Description: "ID of the module to publish to",
},
"topic": {
Title: "Topic",
Type: "string",
Description: "Topic to publish to",
},
},
Required: []string{"module", "topic"},
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params
moduleIdString, err := params.GetString("module")
if err != nil {
return nil, fmt.Errorf("pubsub.publish module error: %w", err)
}
topicString, err := params.GetString("topic")
if err != nil {
return nil, fmt.Errorf("pubsub.publish topic error: %w", err)
}
topicTemplate, err := template.New("topic").Parse(topicString)
if err != nil {
return nil, err
}
return &PubSubPublish{config: config, ModuleId: moduleIdString, Topic: topicTemplate, logger: slog.Default().With("component", "processor", "type", config.Type)}, nil
},
})
}
type PubSubPublish struct {
config config.ProcessorConfig
ModuleId string
@@ -62,48 +107,3 @@ func (psp *PubSubPublish) Process(ctx context.Context, wrappedPayload common.Wra
func (psp *PubSubPublish) Type() string {
return psp.config.Type
}
func init() {
RegisterProcessor(ProcessorRegistration{
Type: "pubsub.publish",
Title: "Publish to Pub/Sub Topic",
ParamsSchema: &jsonschema.Schema{
Type: "object",
Properties: map[string]*jsonschema.Schema{
"module": {
Title: "Module ID",
Type: "string",
Description: "ID of the module to publish to",
},
"topic": {
Title: "Topic",
Type: "string",
Description: "Topic to publish to",
},
},
Required: []string{"module", "topic"},
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params
moduleIdString, err := params.GetString("module")
if err != nil {
return nil, fmt.Errorf("pubsub.publish module error: %w", err)
}
topicString, err := params.GetString("topic")
if err != nil {
return nil, fmt.Errorf("pubsub.publish topic error: %w", err)
}
topicTemplate, err := template.New("topic").Parse(topicString)
if err != nil {
return nil, err
}
return &PubSubPublish{config: config, ModuleId: moduleIdString, Topic: topicTemplate, logger: slog.Default().With("component", "processor", "type", config.Type)}, nil
},
})
}