mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-08-12 01:43:40 +00:00
move init functions to top of file
This commit is contained in:
@@ -11,29 +11,6 @@ import (
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
|
||||
type StringSplit struct {
|
||||
config config.ProcessorConfig
|
||||
Separator string
|
||||
}
|
||||
|
||||
func (ss *StringSplit) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||
payload := wrappedPayload.Payload
|
||||
payloadString, ok := common.GetAnyAs[string](payload)
|
||||
|
||||
if !ok {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("string.split only accepts a string")
|
||||
}
|
||||
|
||||
wrappedPayload.Payload = strings.Split(payloadString, ss.Separator)
|
||||
|
||||
return wrappedPayload, nil
|
||||
}
|
||||
|
||||
func (ss *StringSplit) Type() string {
|
||||
return ss.config.Type
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "string.split",
|
||||
@@ -61,3 +38,26 @@ func init() {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
type StringSplit struct {
|
||||
config config.ProcessorConfig
|
||||
Separator string
|
||||
}
|
||||
|
||||
func (ss *StringSplit) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||
payload := wrappedPayload.Payload
|
||||
payloadString, ok := common.GetAnyAs[string](payload)
|
||||
|
||||
if !ok {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("string.split only accepts a string")
|
||||
}
|
||||
|
||||
wrappedPayload.Payload = strings.Split(payloadString, ss.Separator)
|
||||
|
||||
return wrappedPayload, nil
|
||||
}
|
||||
|
||||
func (ss *StringSplit) Type() string {
|
||||
return ss.config.Type
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user