mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-08-21 22:18:57 +00:00
move init functions to top of file
This commit is contained in:
@@ -11,36 +11,6 @@ import (
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
)
|
||||
|
||||
type RouterInput struct {
|
||||
config config.ProcessorConfig
|
||||
SourceId string
|
||||
logger *slog.Logger
|
||||
}
|
||||
|
||||
func (ri *RouterInput) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||
|
||||
payload := wrappedPayload.Payload
|
||||
if wrappedPayload.InputHandler == nil {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("router.input no input handler found")
|
||||
}
|
||||
|
||||
_, err := wrappedPayload.InputHandler(ctx, ri.SourceId, payload)
|
||||
|
||||
if err != nil {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("router.input failed to send input")
|
||||
}
|
||||
|
||||
wrappedPayload.Payload = payload
|
||||
|
||||
return wrappedPayload, nil
|
||||
}
|
||||
|
||||
func (ri *RouterInput) Type() string {
|
||||
return ri.config.Type
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "router.input",
|
||||
@@ -71,3 +41,33 @@ func init() {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
type RouterInput struct {
|
||||
config config.ProcessorConfig
|
||||
SourceId string
|
||||
logger *slog.Logger
|
||||
}
|
||||
|
||||
func (ri *RouterInput) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||
|
||||
payload := wrappedPayload.Payload
|
||||
if wrappedPayload.InputHandler == nil {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("router.input no input handler found")
|
||||
}
|
||||
|
||||
_, err := wrappedPayload.InputHandler(ctx, ri.SourceId, payload)
|
||||
|
||||
if err != nil {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("router.input failed to send input")
|
||||
}
|
||||
|
||||
wrappedPayload.Payload = payload
|
||||
|
||||
return wrappedPayload, nil
|
||||
}
|
||||
|
||||
func (ri *RouterInput) Type() string {
|
||||
return ri.config.Type
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user