mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-08-18 04:33:56 +00:00
move init functions to top of file
This commit is contained in:
@@ -11,6 +11,33 @@ import (
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "struct.method.get",
|
||||
Title: "Get Struct Method",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"name": {
|
||||
Title: "Method Name",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"name"},
|
||||
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
nameString, err := params.GetString("name")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("struct.method.get name error: %w", err)
|
||||
}
|
||||
|
||||
return &StructMethodGet{config: config, Name: nameString}, nil
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
type StructMethodGet struct {
|
||||
config config.ProcessorConfig
|
||||
Name string
|
||||
@@ -61,30 +88,3 @@ func (smg *StructMethodGet) Process(ctx context.Context, wrappedPayload common.W
|
||||
func (smg *StructMethodGet) Type() string {
|
||||
return smg.config.Type
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "struct.method.get",
|
||||
Title: "Get Struct Method",
|
||||
ParamsSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"name": {
|
||||
Title: "Method Name",
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
Required: []string{"name"},
|
||||
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
|
||||
},
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
params := config.Params
|
||||
nameString, err := params.GetString("name")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("struct.method.get name error: %w", err)
|
||||
}
|
||||
|
||||
return &StructMethodGet{config: config, Name: nameString}, nil
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user