mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
rename processing to processor
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import "github.com/jwetzell/showbridge-go/internal/processing"
|
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Modules []ModuleConfig `json:"modules"`
|
Modules []ModuleConfig `json:"modules"`
|
||||||
Routes []RouteConfig `json:"routes"`
|
Routes []RouteConfig `json:"routes"`
|
||||||
@@ -15,6 +13,11 @@ type ModuleConfig struct {
|
|||||||
|
|
||||||
type RouteConfig struct {
|
type RouteConfig struct {
|
||||||
Input string `json:"input"`
|
Input string `json:"input"`
|
||||||
Processors []processing.ProcessorConfig `json:"processors"`
|
Processors []ProcessorConfig `json:"processors"`
|
||||||
Output string `json:"output"`
|
Output string `json:"output"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ProcessorConfig struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
Params map[string]any `json:"params"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||||
"github.com/jwetzell/showbridge-go/internal/config"
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
"github.com/jwetzell/showbridge-go/internal/processing"
|
"github.com/jwetzell/showbridge-go/internal/processor"
|
||||||
"github.com/jwetzell/showbridge-go/internal/route"
|
"github.com/jwetzell/showbridge-go/internal/route"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ func (mc *MQTTClient) Run() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MQTTClient) Output(payload any) error {
|
func (mc *MQTTClient) Output(payload any) error {
|
||||||
payloadMessage, ok := payload.(processing.MQTTMessage)
|
payloadMessage, ok := payload.(processor.MQTTMessage)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("net.mqtt.client is only able to output a MQTTMessage")
|
return fmt.Errorf("net.mqtt.client is only able to output a MQTTMessage")
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
"github.com/jwetzell/showbridge-go/internal/config"
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
"github.com/jwetzell/showbridge-go/internal/processing"
|
"github.com/jwetzell/showbridge-go/internal/processor"
|
||||||
"github.com/jwetzell/showbridge-go/internal/route"
|
"github.com/jwetzell/showbridge-go/internal/route"
|
||||||
"github.com/nats-io/nats.go"
|
"github.com/nats-io/nats.go"
|
||||||
)
|
)
|
||||||
@@ -93,7 +93,7 @@ func (nc *NATSClient) Run() error {
|
|||||||
|
|
||||||
func (nc *NATSClient) Output(payload any) error {
|
func (nc *NATSClient) Output(payload any) error {
|
||||||
|
|
||||||
payloadMessage, ok := payload.(processing.NATSMessage)
|
payloadMessage, ok := payload.(processor.NATSMessage)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("net.nats.client is only able to output NATSMessage")
|
return fmt.Errorf("net.nats.client is only able to output NATSMessage")
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DebugLog struct {
|
type DebugLog struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dl *DebugLog) Process(ctx context.Context, payload any) (any, error) {
|
func (dl *DebugLog) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -22,7 +24,7 @@ func (dl *DebugLog) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "debug.log",
|
Type: "debug.log",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &DebugLog{config: config}, nil
|
return &DebugLog{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FloatParse struct {
|
type FloatParse struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fp *FloatParse) Process(ctx context.Context, payload any) (any, error) {
|
func (fp *FloatParse) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -32,7 +34,7 @@ func (fp *FloatParse) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "float.parse",
|
Type: "float.parse",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &FloatParse{config: config}, nil
|
return &FloatParse{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -8,10 +8,11 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
freeD "github.com/jwetzell/free-d-go"
|
freeD "github.com/jwetzell/free-d-go"
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FreeDCreate struct {
|
type FreeDCreate struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Id *template.Template
|
Id *template.Template
|
||||||
Pan *template.Template
|
Pan *template.Template
|
||||||
Tilt *template.Template
|
Tilt *template.Template
|
||||||
@@ -178,7 +179,7 @@ func (fc *FreeDCreate) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "freed.create",
|
Type: "freed.create",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
|
|
||||||
// TODO(jwetzell): make some params optional
|
// TODO(jwetzell): make some params optional
|
||||||
params := config.Params
|
params := config.Params
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -6,10 +6,11 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
freeD "github.com/jwetzell/free-d-go"
|
freeD "github.com/jwetzell/free-d-go"
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FreeDDecode struct {
|
type FreeDDecode struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fdd *FreeDDecode) Process(ctx context.Context, payload any) (any, error) {
|
func (fdd *FreeDDecode) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -33,7 +34,7 @@ func (fdd *FreeDDecode) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "freed.decode",
|
Type: "freed.decode",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &FreeDDecode{config: config}, nil
|
return &FreeDDecode{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
freeD "github.com/jwetzell/free-d-go"
|
freeD "github.com/jwetzell/free-d-go"
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FreeDEncode struct {
|
type FreeDEncode struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fde *FreeDEncode) Process(ctx context.Context, payload any) (any, error) {
|
func (fde *FreeDEncode) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -29,7 +30,7 @@ func (fde *FreeDEncode) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "freed.encode",
|
Type: "freed.encode",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &FreeDEncode{config: config}, nil
|
return &FreeDEncode{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -6,10 +6,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HTTPRequestCreate struct {
|
type HTTPRequestCreate struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Method string
|
Method string
|
||||||
URL *template.Template
|
URL *template.Template
|
||||||
}
|
}
|
||||||
@@ -42,7 +44,7 @@ func (hre *HTTPRequestCreate) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "http.request.create",
|
Type: "http.request.create",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
params := config.Params
|
params := config.Params
|
||||||
|
|
||||||
method, ok := params["method"]
|
method, ok := params["method"]
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HTTPRequestEncode struct {
|
type HTTPRequestEncode struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hre *HTTPRequestEncode) Process(ctx context.Context, payload any) (any, error) {
|
func (hre *HTTPRequestEncode) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -33,7 +35,7 @@ func (hre *HTTPRequestEncode) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "http.request.encode",
|
Type: "http.request.encode",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &HTTPRequestEncode{config: config}, nil
|
return &HTTPRequestEncode{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HTTPRequestFilter struct {
|
type HTTPRequestFilter struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Path *regexp.Regexp
|
Path *regexp.Regexp
|
||||||
Method string
|
Method string
|
||||||
}
|
}
|
||||||
@@ -41,7 +43,7 @@ func (hrf *HTTPRequestFilter) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "http.request.filter",
|
Type: "http.request.filter",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
params := config.Params
|
params := config.Params
|
||||||
path, ok := params["path"]
|
path, ok := params["path"]
|
||||||
|
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HTTPResponseEncode struct {
|
type HTTPResponseEncode struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hre *HTTPResponseEncode) Process(ctx context.Context, payload any) (any, error) {
|
func (hre *HTTPResponseEncode) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -34,7 +36,7 @@ func (hre *HTTPResponseEncode) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "http.response.encode",
|
Type: "http.response.encode",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &HTTPResponseEncode{config: config}, nil
|
return &HTTPResponseEncode{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IntParse struct {
|
type IntParse struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ip *IntParse) Process(ctx context.Context, payload any) (any, error) {
|
func (ip *IntParse) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -32,7 +34,7 @@ func (ip *IntParse) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "int.parse",
|
Type: "int.parse",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &IntParse{config: config}, nil
|
return &IntParse{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,16 +1,17 @@
|
|||||||
//go:build cgo
|
//go:build cgo
|
||||||
|
|
||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
"gitlab.com/gomidi/midi/v2"
|
"gitlab.com/gomidi/midi/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MIDIMessageDecode struct {
|
type MIDIMessageDecode struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mmd *MIDIMessageDecode) Process(ctx context.Context, payload any) (any, error) {
|
func (mmd *MIDIMessageDecode) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -32,7 +33,7 @@ func (mmd *MIDIMessageDecode) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "midi.message.decode",
|
Type: "midi.message.decode",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &MIDIMessageDecode{config: config}, nil
|
return &MIDIMessageDecode{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,16 +1,17 @@
|
|||||||
//go:build cgo
|
//go:build cgo
|
||||||
|
|
||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
"gitlab.com/gomidi/midi/v2"
|
"gitlab.com/gomidi/midi/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MIDIMessageEncode struct {
|
type MIDIMessageEncode struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mme *MIDIMessageEncode) Process(ctx context.Context, payload any) (any, error) {
|
func (mme *MIDIMessageEncode) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -30,7 +31,7 @@ func (mme *MIDIMessageEncode) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "midi.message.encode",
|
Type: "midi.message.encode",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &MIDIMessageEncode{config: config}, nil
|
return &MIDIMessageEncode{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MQTTMessage struct {
|
type MQTTMessage struct {
|
||||||
@@ -13,7 +15,7 @@ type MQTTMessage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MQTTMessageCreate struct {
|
type MQTTMessageCreate struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Topic string
|
Topic string
|
||||||
QoS byte
|
QoS byte
|
||||||
Retained bool
|
Retained bool
|
||||||
@@ -39,7 +41,7 @@ func (mmc *MQTTMessageCreate) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "mqtt.message.create",
|
Type: "mqtt.message.create",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
params := config.Params
|
params := config.Params
|
||||||
topic, ok := params["topic"]
|
topic, ok := params["topic"]
|
||||||
|
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MQTTMessageEncode struct {
|
type MQTTMessageEncode struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mme *MQTTMessageEncode) Process(ctx context.Context, payload any) (any, error) {
|
func (mme *MQTTMessageEncode) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -28,7 +29,7 @@ func (mme *MQTTMessageEncode) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "mqtt.message.encode",
|
Type: "mqtt.message.encode",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &MQTTMessageEncode{config: config}, nil
|
return &MQTTMessageEncode{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NATSMessage struct {
|
type NATSMessage struct {
|
||||||
@@ -13,7 +15,7 @@ type NATSMessage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type NATSMessageCreate struct {
|
type NATSMessageCreate struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Subject string
|
Subject string
|
||||||
Payload *template.Template
|
Payload *template.Template
|
||||||
}
|
}
|
||||||
@@ -44,7 +46,7 @@ func (nmc *NATSMessageCreate) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "nats.message.create",
|
Type: "nats.message.create",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
params := config.Params
|
params := config.Params
|
||||||
// TODO(jwetzell): support template for subject
|
// TODO(jwetzell): support template for subject
|
||||||
subject, ok := params["subject"]
|
subject, ok := params["subject"]
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
"github.com/nats-io/nats.go"
|
"github.com/nats-io/nats.go"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NATSMessageEncode struct {
|
type NATSMessageEncode struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nme *NATSMessageEncode) Process(ctx context.Context, payload any) (any, error) {
|
func (nme *NATSMessageEncode) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -28,7 +29,7 @@ func (nme *NATSMessageEncode) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "nats.message.encode",
|
Type: "nats.message.encode",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &NATSMessageEncode{config: config}, nil
|
return &NATSMessageEncode{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -9,10 +9,11 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/jwetzell/osc-go"
|
"github.com/jwetzell/osc-go"
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OSCMessageCreate struct {
|
type OSCMessageCreate struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Address *template.Template
|
Address *template.Template
|
||||||
Args []*template.Template
|
Args []*template.Template
|
||||||
Types string
|
Types string
|
||||||
@@ -76,7 +77,7 @@ func (o *OSCMessageCreate) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "osc.message.create",
|
Type: "osc.message.create",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
params := config.Params
|
params := config.Params
|
||||||
address, ok := params["address"]
|
address, ok := params["address"]
|
||||||
|
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
osc "github.com/jwetzell/osc-go"
|
osc "github.com/jwetzell/osc-go"
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OSCMessageDecode struct {
|
type OSCMessageDecode struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OSCMessageDecode) Process(ctx context.Context, payload any) (any, error) {
|
func (o *OSCMessageDecode) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -40,7 +41,7 @@ func (o *OSCMessageDecode) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "osc.message.decode",
|
Type: "osc.message.decode",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &OSCMessageDecode{config: config}, nil
|
return &OSCMessageDecode{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
osc "github.com/jwetzell/osc-go"
|
osc "github.com/jwetzell/osc-go"
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OSCMessageEncode struct {
|
type OSCMessageEncode struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OSCMessageEncode) Process(ctx context.Context, payload any) (any, error) {
|
func (o *OSCMessageEncode) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -29,7 +30,7 @@ func (o *OSCMessageEncode) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "osc.message.encode",
|
Type: "osc.message.encode",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &OSCMessageEncode{config: config}, nil
|
return &OSCMessageEncode{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -7,10 +7,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jwetzell/osc-go"
|
"github.com/jwetzell/osc-go"
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OSCMessageFilter struct {
|
type OSCMessageFilter struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Address *regexp.Regexp
|
Address *regexp.Regexp
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ func (o *OSCMessageFilter) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "osc.message.filter",
|
Type: "osc.message.filter",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
params := config.Params
|
params := config.Params
|
||||||
address, ok := params["address"]
|
address, ok := params["address"]
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -7,10 +7,11 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
osc "github.com/jwetzell/osc-go"
|
osc "github.com/jwetzell/osc-go"
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OSCMessageTransform struct {
|
type OSCMessageTransform struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Address *template.Template
|
Address *template.Template
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ func (o *OSCMessageTransform) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "osc.message.transform",
|
Type: "osc.message.transform",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
params := config.Params
|
params := config.Params
|
||||||
address, ok := params["address"]
|
address, ok := params["address"]
|
||||||
|
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Processor interface {
|
type Processor interface {
|
||||||
@@ -11,14 +13,9 @@ type Processor interface {
|
|||||||
Process(context.Context, any) (any, error)
|
Process(context.Context, any) (any, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProcessorConfig struct {
|
|
||||||
Type string `json:"type"`
|
|
||||||
Params map[string]any `json:"params"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProcessorRegistration struct {
|
type ProcessorRegistration struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
New func(ProcessorConfig) (Processor, error)
|
New func(config.ProcessorConfig) (Processor, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterProcessor(processor ProcessorRegistration) {
|
func RegisterProcessor(processor ProcessorRegistration) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -6,11 +6,12 @@ import (
|
|||||||
|
|
||||||
"github.com/expr-lang/expr"
|
"github.com/expr-lang/expr"
|
||||||
"github.com/expr-lang/expr/vm"
|
"github.com/expr-lang/expr/vm"
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NOTE(jwetzell): see language definition https://expr-lang.org/docs/language-definition
|
// NOTE(jwetzell): see language definition https://expr-lang.org/docs/language-definition
|
||||||
type ScriptExpr struct {
|
type ScriptExpr struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Program *vm.Program
|
Program *vm.Program
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ func (se *ScriptExpr) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "script.expr",
|
Type: "script.expr",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
params := config.Params
|
params := config.Params
|
||||||
|
|
||||||
expression, ok := params["expression"]
|
expression, ok := params["expression"]
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
"modernc.org/quickjs"
|
"modernc.org/quickjs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScriptJS struct {
|
type ScriptJS struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Program string
|
Program string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +68,7 @@ func (sj *ScriptJS) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "script.js",
|
Type: "script.js",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
params := config.Params
|
params := config.Params
|
||||||
|
|
||||||
program, ok := params["program"]
|
program, ok := params["program"]
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StringCreate struct {
|
type StringCreate struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Template *template.Template
|
Template *template.Template
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +34,7 @@ func (sc *StringCreate) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "string.create",
|
Type: "string.create",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
params := config.Params
|
params := config.Params
|
||||||
tmpl, ok := params["template"]
|
tmpl, ok := params["template"]
|
||||||
|
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StringDecode struct {
|
type StringDecode struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sd *StringDecode) Process(ctx context.Context, payload any) (any, error) {
|
func (sd *StringDecode) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -28,7 +30,7 @@ func (sd *StringDecode) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "string.decode",
|
Type: "string.decode",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &StringDecode{config: config}, nil
|
return &StringDecode{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
package processing_test
|
package processor_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/jwetzell/showbridge-go/internal/processing"
|
"github.com/jwetzell/showbridge-go/internal/processor"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGoodStringDecode(t *testing.T) {
|
func TestGoodStringDecode(t *testing.T) {
|
||||||
stringDecoder := processing.StringDecode{}
|
stringDecoder := processor.StringDecode{}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
processor processing.Processor
|
processor processor.Processor
|
||||||
name string
|
name string
|
||||||
payload any
|
payload any
|
||||||
expected string
|
expected string
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StringEncode struct {
|
type StringEncode struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (se *StringEncode) Process(ctx context.Context, payload any) (any, error) {
|
func (se *StringEncode) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -28,7 +30,7 @@ func (se *StringEncode) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "string.encode",
|
Type: "string.encode",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &StringEncode{config: config}, nil
|
return &StringEncode{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
package processing_test
|
package processor_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"slices"
|
"slices"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/jwetzell/showbridge-go/internal/processing"
|
"github.com/jwetzell/showbridge-go/internal/processor"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGoodStringEncode(t *testing.T) {
|
func TestGoodStringEncode(t *testing.T) {
|
||||||
stringEncoder := processing.StringEncode{}
|
stringEncoder := processor.StringEncode{}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
processor processing.Processor
|
processor processor.Processor
|
||||||
name string
|
name string
|
||||||
payload any
|
payload any
|
||||||
expected []byte
|
expected []byte
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StringFilter struct {
|
type StringFilter struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Pattern *regexp.Regexp
|
Pattern *regexp.Regexp
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +34,7 @@ func (se *StringFilter) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "string.filter",
|
Type: "string.filter",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
params := config.Params
|
params := config.Params
|
||||||
|
|
||||||
pattern, ok := params["pattern"]
|
pattern, ok := params["pattern"]
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StringSplit struct {
|
type StringSplit struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Separator string
|
Separator string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +32,7 @@ func (se *StringSplit) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "string.split",
|
Type: "string.split",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
params := config.Params
|
params := config.Params
|
||||||
|
|
||||||
separator, ok := params["separator"]
|
separator, ok := params["separator"]
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
package processing
|
package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UintParse struct {
|
type UintParse struct {
|
||||||
config ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (up *UintParse) Process(ctx context.Context, payload any) (any, error) {
|
func (up *UintParse) Process(ctx context.Context, payload any) (any, error) {
|
||||||
@@ -32,7 +34,7 @@ func (up *UintParse) Type() string {
|
|||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "uint.parse",
|
Type: "uint.parse",
|
||||||
New: func(config ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &UintParse{config: config}, nil
|
return &UintParse{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/jwetzell/showbridge-go/internal/config"
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
"github.com/jwetzell/showbridge-go/internal/processing"
|
"github.com/jwetzell/showbridge-go/internal/processor"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RouteError struct {
|
type RouteError struct {
|
||||||
@@ -33,16 +33,16 @@ type Route interface {
|
|||||||
|
|
||||||
type ProcessorRoute struct {
|
type ProcessorRoute struct {
|
||||||
input string
|
input string
|
||||||
processors []processing.Processor
|
processors []processor.Processor
|
||||||
output string
|
output string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRoute(config config.RouteConfig) (Route, error) {
|
func NewRoute(config config.RouteConfig) (Route, error) {
|
||||||
processors := []processing.Processor{}
|
processors := []processor.Processor{}
|
||||||
|
|
||||||
if len(config.Processors) > 0 {
|
if len(config.Processors) > 0 {
|
||||||
for _, processorDecl := range config.Processors {
|
for _, processorDecl := range config.Processors {
|
||||||
processorInfo, ok := processing.ProcessorRegistry[processorDecl.Type]
|
processorInfo, ok := processor.ProcessorRegistry[processorDecl.Type]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("problem loading processor registration for processor type: %s", processorDecl.Type)
|
return nil, fmt.Errorf("problem loading processor registration for processor type: %s", processorDecl.Type)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user