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
+27 -27
View File
@@ -12,33 +12,6 @@ import (
"github.com/jwetzell/showbridge-go/internal/config"
)
type FloatParse struct {
BitSize int
config config.ProcessorConfig
}
func (fp *FloatParse) 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("float.parse processor only accepts a string")
}
payloadFloat, err := strconv.ParseFloat(payloadString, fp.BitSize)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
wrappedPayload.Payload = payloadFloat
return wrappedPayload, nil
}
func (fp *FloatParse) Type() string {
return fp.config.Type
}
func init() {
RegisterProcessor(ProcessorRegistration{
Type: "float.parse",
@@ -70,3 +43,30 @@ func init() {
},
})
}
type FloatParse struct {
BitSize int
config config.ProcessorConfig
}
func (fp *FloatParse) 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("float.parse processor only accepts a string")
}
payloadFloat, err := strconv.ParseFloat(payloadString, fp.BitSize)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
wrappedPayload.Payload = payloadFloat
return wrappedPayload, nil
}
func (fp *FloatParse) Type() string {
return fp.config.Type
}