mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 05:15:47 +00:00
remove nats message encode
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
package processor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
type NATSMessageEncode struct {
|
||||
config config.ProcessorConfig
|
||||
}
|
||||
|
||||
func (nme *NATSMessageEncode) Process(ctx context.Context, payload any) (any, error) {
|
||||
payloadMessage, ok := payload.(*nats.Msg)
|
||||
|
||||
if !ok {
|
||||
return nil, errors.New("nats.message.encode processor only accepts a nats.Msg")
|
||||
}
|
||||
|
||||
return payloadMessage.Data, nil
|
||||
}
|
||||
|
||||
func (nme *NATSMessageEncode) Type() string {
|
||||
return nme.config.Type
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterProcessor(ProcessorRegistration{
|
||||
Type: "nats.message.encode",
|
||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||
return &NATSMessageEncode{config: config}, nil
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package processor_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
"github.com/jwetzell/showbridge-go/internal/processor"
|
||||
)
|
||||
|
||||
func TestNATSMessageEncodeFromRegistry(t *testing.T) {
|
||||
registration, ok := processor.ProcessorRegistry["nats.message.encode"]
|
||||
if !ok {
|
||||
t.Fatalf("nats.message.encode processor not registered")
|
||||
}
|
||||
|
||||
processorInstance, err := registration.New(config.ProcessorConfig{
|
||||
Type: "nats.message.encode",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create nats.message.encode processor: %s", err)
|
||||
}
|
||||
|
||||
if processorInstance.Type() != "nats.message.encode" {
|
||||
t.Fatalf("nats.message.encode processor has wrong type: %s", processorInstance.Type())
|
||||
}
|
||||
}
|
||||
@@ -514,17 +514,6 @@
|
||||
"required": ["type", "params"],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"const": "nats.message.encode"
|
||||
}
|
||||
},
|
||||
"required": ["type"],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
Reference in New Issue
Block a user