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
+31 -31
View File
@@ -12,37 +12,6 @@ import (
"github.com/jwetzell/showbridge-go/internal/config"
)
type ScriptWASM struct {
config config.ProcessorConfig
Program *extism.Plugin
Function string
}
func (sw *ScriptWASM) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
payload := wrappedPayload.Payload
payloadBytes, ok := common.GetAnyAsByteSlice(payload)
if !ok {
wrappedPayload.End = true
return wrappedPayload, fmt.Errorf("script.wasm can only process a byte array")
}
_, output, err := sw.Program.Call(sw.Function, payloadBytes)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
wrappedPayload.Payload = output
return wrappedPayload, nil
}
func (sw *ScriptWASM) Type() string {
return sw.config.Type
}
func init() {
RegisterProcessor(ProcessorRegistration{
Type: "script.wasm",
@@ -120,3 +89,34 @@ func init() {
},
})
}
type ScriptWASM struct {
config config.ProcessorConfig
Program *extism.Plugin
Function string
}
func (sw *ScriptWASM) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
payload := wrappedPayload.Payload
payloadBytes, ok := common.GetAnyAsByteSlice(payload)
if !ok {
wrappedPayload.End = true
return wrappedPayload, fmt.Errorf("script.wasm can only process a byte array")
}
_, output, err := sw.Program.Call(sw.Function, payloadBytes)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
wrappedPayload.Payload = output
return wrappedPayload, nil
}
func (sw *ScriptWASM) Type() string {
return sw.config.Type
}