don't export module/processor/framer registrations

This commit is contained in:
Joel Wetzell
2026-05-26 17:27:35 -05:00
parent 0ff212742a
commit 80f8152dfb
77 changed files with 299 additions and 258 deletions
+5 -5
View File
@@ -10,15 +10,15 @@ type Framer interface {
func GetFramer(framingType string) Framer { func GetFramer(framingType string) Framer {
switch framingType { switch framingType {
case "CR": case "CR":
return NewByteSeparatorFramer([]byte{'\r'}) return newByteSeparatorFramer([]byte{'\r'})
case "LF": case "LF":
return NewByteSeparatorFramer([]byte{'\n'}) return newByteSeparatorFramer([]byte{'\n'})
case "CRLF": case "CRLF":
return NewByteSeparatorFramer([]byte{'\r', '\n'}) return newByteSeparatorFramer([]byte{'\r', '\n'})
case "SLIP": case "SLIP":
return NewSlipFramer() return newSlipFramer()
case "RAW": case "RAW":
return NewRawFramer() return newRawFramer()
default: default:
return nil return nil
} }
+7 -7
View File
@@ -1,23 +1,23 @@
package framer package framer
type RawFramer struct{} type rawFramer struct{}
func NewRawFramer() *RawFramer { func newRawFramer() *rawFramer {
return &RawFramer{} return &rawFramer{}
} }
func (rf *RawFramer) Decode(data []byte) [][]byte { func (rf *rawFramer) Decode(data []byte) [][]byte {
return [][]byte{data} return [][]byte{data}
} }
func (rf *RawFramer) Encode(data []byte) []byte { func (rf *rawFramer) Encode(data []byte) []byte {
return data return data
} }
func (rf *RawFramer) Clear() { func (rf *rawFramer) Clear() {
// NOTE(jwetzell): no internal state to clear // NOTE(jwetzell): no internal state to clear
} }
func (rf *RawFramer) Buffer() []byte { func (rf *rawFramer) Buffer() []byte {
return []byte{} return []byte{}
} }
+7 -7
View File
@@ -4,16 +4,16 @@ import (
"bytes" "bytes"
) )
type ByteSeparatorFramer struct { type byteSeparatorFramer struct {
buffer []byte buffer []byte
separator []byte separator []byte
} }
func NewByteSeparatorFramer(separator []byte) *ByteSeparatorFramer { func newByteSeparatorFramer(separator []byte) *byteSeparatorFramer {
return &ByteSeparatorFramer{separator: separator, buffer: []byte{}} return &byteSeparatorFramer{separator: separator, buffer: []byte{}}
} }
func (bsf *ByteSeparatorFramer) Decode(data []byte) [][]byte { func (bsf *byteSeparatorFramer) Decode(data []byte) [][]byte {
messages := [][]byte{} messages := [][]byte{}
bsf.buffer = append(bsf.buffer, data...) bsf.buffer = append(bsf.buffer, data...)
@@ -28,14 +28,14 @@ func (bsf *ByteSeparatorFramer) Decode(data []byte) [][]byte {
return messages return messages
} }
func (bsf *ByteSeparatorFramer) Encode(data []byte) []byte { func (bsf *byteSeparatorFramer) Encode(data []byte) []byte {
return append(data, bsf.separator...) return append(data, bsf.separator...)
} }
func (bsf *ByteSeparatorFramer) Clear() { func (bsf *byteSeparatorFramer) Clear() {
bsf.buffer = []byte{} bsf.buffer = []byte{}
} }
func (bsf *ByteSeparatorFramer) Buffer() []byte { func (bsf *byteSeparatorFramer) Buffer() []byte {
return bsf.buffer return bsf.buffer
} }
+7 -7
View File
@@ -1,14 +1,14 @@
package framer package framer
type SlipFramer struct { type slipFramer struct {
buffer []byte buffer []byte
} }
func NewSlipFramer() *SlipFramer { func newSlipFramer() *slipFramer {
return &SlipFramer{buffer: []byte{}} return &slipFramer{buffer: []byte{}}
} }
func (sf *SlipFramer) Decode(data []byte) [][]byte { func (sf *slipFramer) Decode(data []byte) [][]byte {
messages := [][]byte{} messages := [][]byte{}
END := byte(0xc0) END := byte(0xc0)
@@ -49,7 +49,7 @@ func (sf *SlipFramer) Decode(data []byte) [][]byte {
return messages return messages
} }
func (sf *SlipFramer) Encode(data []byte) []byte { func (sf *slipFramer) Encode(data []byte) []byte {
END := byte(0xc0) END := byte(0xc0)
ESC := byte(0xdb) ESC := byte(0xdb)
ESC_END := byte(0xdc) ESC_END := byte(0xdc)
@@ -72,10 +72,10 @@ func (sf *SlipFramer) Encode(data []byte) []byte {
return encodedBytes return encodedBytes
} }
func (sf *SlipFramer) Clear() { func (sf *slipFramer) Clear() {
sf.buffer = []byte{} sf.buffer = []byte{}
} }
func (sf *SlipFramer) Buffer() []byte { func (sf *slipFramer) Buffer() []byte {
return sf.buffer return sf.buffer
} }
+24 -3
View File
@@ -30,15 +30,36 @@ func RegisterModule(mod ModuleRegistration) {
moduleRegistryMu.Lock() moduleRegistryMu.Lock()
defer moduleRegistryMu.Unlock() defer moduleRegistryMu.Unlock()
if _, ok := ModuleRegistry[string(mod.Type)]; ok { if _, ok := moduleRegistry[string(mod.Type)]; ok {
panic(fmt.Sprintf("module already registered: %s", mod.Type)) panic(fmt.Sprintf("module already registered: %s", mod.Type))
} }
ModuleRegistry[string(mod.Type)] = mod moduleRegistry[string(mod.Type)] = mod
}
type ModuleRegistry map[string]ModuleRegistration
func GetModuleRegistration(moduleType string) (ModuleRegistration, bool) {
moduleRegistryMu.RLock()
defer moduleRegistryMu.RUnlock()
mod, ok := moduleRegistry[moduleType]
return mod, ok
}
func GetModuleRegistrations() []ModuleRegistration {
moduleRegistryMu.RLock()
defer moduleRegistryMu.RUnlock()
registrations := make([]ModuleRegistration, 0, len(moduleRegistry))
for _, mod := range moduleRegistry {
registrations = append(registrations, mod)
}
return registrations
} }
var ( var (
moduleRegistryMu sync.RWMutex moduleRegistryMu sync.RWMutex
ModuleRegistry = make(map[string]ModuleRegistration) moduleRegistry = make(ModuleRegistry)
) )
func CreateLogger(config config.ModuleConfig) *slog.Logger { func CreateLogger(config config.ModuleConfig) *slog.Logger {
+3 -3
View File
@@ -9,7 +9,7 @@ import (
) )
func TestDbSqliteFromRegistry(t *testing.T) { func TestDbSqliteFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["db.sqlite"] registration, ok := module.GetModuleRegistration("db.sqlite")
if !ok { if !ok {
t.Fatalf("db.sqlite module not registered") t.Fatalf("db.sqlite module not registered")
} }
@@ -58,7 +58,7 @@ func TestGoodDbSqlite(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["db.sqlite"] registration, ok := module.GetModuleRegistration("db.sqlite")
if !ok { if !ok {
t.Fatalf("db.sqlite module not registered") t.Fatalf("db.sqlite module not registered")
} }
@@ -107,7 +107,7 @@ func TestBadDbSqlite(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["db.sqlite"] registration, ok := module.GetModuleRegistration("db.sqlite")
if !ok { if !ok {
t.Fatalf("db.sqlite module not registered") t.Fatalf("db.sqlite module not registered")
} }
+3 -3
View File
@@ -9,7 +9,7 @@ import (
) )
func TestHTTPServerFromRegistry(t *testing.T) { func TestHTTPServerFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["http.server"] registration, ok := module.GetModuleRegistration("http.server")
if !ok { if !ok {
t.Fatalf("http.server module not registered") t.Fatalf("http.server module not registered")
} }
@@ -52,7 +52,7 @@ func TestGoodHTTPServer(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["http.server"] registration, ok := module.GetModuleRegistration("http.server")
if !ok { if !ok {
t.Fatalf("http.server module not registered") t.Fatalf("http.server module not registered")
} }
@@ -102,7 +102,7 @@ func TestBadHTTPServer(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["http.server"] registration, ok := module.GetModuleRegistration("http.server")
if !ok { if !ok {
t.Fatalf("http.server module not registered") t.Fatalf("http.server module not registered")
} }
+2 -2
View File
@@ -8,7 +8,7 @@ import (
) )
func TestMIDIInputFromRegistry(t *testing.T) { func TestMIDIInputFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["midi.input"] registration, ok := module.GetModuleRegistration("midi.input")
if !ok { if !ok {
t.Fatalf("midi.input module not registered") t.Fatalf("midi.input module not registered")
} }
@@ -55,7 +55,7 @@ func TestBadMIDIInput(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["midi.input"] registration, ok := module.GetModuleRegistration("midi.input")
if !ok { if !ok {
t.Fatalf("midi.input module not registered") t.Fatalf("midi.input module not registered")
} }
+2 -2
View File
@@ -8,7 +8,7 @@ import (
) )
func TestMIDIOutputFromRegistry(t *testing.T) { func TestMIDIOutputFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["midi.output"] registration, ok := module.GetModuleRegistration("midi.output")
if !ok { if !ok {
t.Fatalf("midi.output module not registered") t.Fatalf("midi.output module not registered")
} }
@@ -55,7 +55,7 @@ func TestBadMIDIOutput(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["midi.output"] registration, ok := module.GetModuleRegistration("midi.output")
if !ok { if !ok {
t.Fatalf("midi.output module not registered") t.Fatalf("midi.output module not registered")
} }
+2 -2
View File
@@ -8,7 +8,7 @@ import (
) )
func TestMQTTClientFromRegistry(t *testing.T) { func TestMQTTClientFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["mqtt.client"] registration, ok := module.GetModuleRegistration("mqtt.client")
if !ok { if !ok {
t.Fatalf("mqtt.client module not registered") t.Fatalf("mqtt.client module not registered")
} }
@@ -98,7 +98,7 @@ func TestBadMQTTClient(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["mqtt.client"] registration, ok := module.GetModuleRegistration("mqtt.client")
if !ok { if !ok {
t.Fatalf("mqtt.client module not registered") t.Fatalf("mqtt.client module not registered")
} }
+2 -2
View File
@@ -8,7 +8,7 @@ import (
) )
func TestNATSClientFromRegistry(t *testing.T) { func TestNATSClientFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["nats.client"] registration, ok := module.GetModuleRegistration("nats.client")
if !ok { if !ok {
t.Fatalf("nats.client module not registered") t.Fatalf("nats.client module not registered")
} }
@@ -76,7 +76,7 @@ func TestBadNATSClient(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["nats.client"] registration, ok := module.GetModuleRegistration("nats.client")
if !ok { if !ok {
t.Fatalf("nats.client module not registered") t.Fatalf("nats.client module not registered")
} }
+3 -3
View File
@@ -9,7 +9,7 @@ import (
) )
func TestNATSServerFromRegistry(t *testing.T) { func TestNATSServerFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["nats.server"] registration, ok := module.GetModuleRegistration("nats.server")
if !ok { if !ok {
t.Fatalf("nats.server module not registered") t.Fatalf("nats.server module not registered")
} }
@@ -53,7 +53,7 @@ func TestGoodNATSServer(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["nats.server"] registration, ok := module.GetModuleRegistration("nats.server")
if !ok { if !ok {
t.Fatalf("nats.server module not registered") t.Fatalf("nats.server module not registered")
} }
@@ -100,7 +100,7 @@ func TestBadNATSServer(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["nats.server"] registration, ok := module.GetModuleRegistration("nats.server")
if !ok { if !ok {
t.Fatalf("nats.server module not registered") t.Fatalf("nats.server module not registered")
} }
+2 -2
View File
@@ -8,7 +8,7 @@ import (
) )
func TestPSNClientFromRegistry(t *testing.T) { func TestPSNClientFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["psn.client"] registration, ok := module.GetModuleRegistration("psn.client")
if !ok { if !ok {
t.Fatalf("psn.client module not registered") t.Fatalf("psn.client module not registered")
} }
@@ -41,7 +41,7 @@ func TestBadPSNClient(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["psn.client"] registration, ok := module.GetModuleRegistration("psn.client")
if !ok { if !ok {
t.Fatalf("psn.client module not registered") t.Fatalf("psn.client module not registered")
} }
+2 -2
View File
@@ -8,7 +8,7 @@ import (
) )
func TestRedisClientFromRegistry(t *testing.T) { func TestRedisClientFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["redis.client"] registration, ok := module.GetModuleRegistration("redis.client")
if !ok { if !ok {
t.Fatalf("redis.client module not registered") t.Fatalf("redis.client module not registered")
} }
@@ -76,7 +76,7 @@ func TestBadRedisClient(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["redis.client"] registration, ok := module.GetModuleRegistration("redis.client")
if !ok { if !ok {
t.Fatalf("redis.client module not registered") t.Fatalf("redis.client module not registered")
} }
+2 -2
View File
@@ -8,7 +8,7 @@ import (
) )
func TestSerialClientFromRegistry(t *testing.T) { func TestSerialClientFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["serial.client"] registration, ok := module.GetModuleRegistration("serial.client")
if !ok { if !ok {
t.Fatalf("serial.client module not registered") t.Fatalf("serial.client module not registered")
} }
@@ -85,7 +85,7 @@ func TestBadSerialClient(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["serial.client"] registration, ok := module.GetModuleRegistration("serial.client")
if !ok { if !ok {
t.Fatalf("serial.client module not registered") t.Fatalf("serial.client module not registered")
} }
+2 -2
View File
@@ -8,7 +8,7 @@ import (
) )
func TestSIPCallServerFromRegistry(t *testing.T) { func TestSIPCallServerFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["sip.call.server"] registration, ok := module.GetModuleRegistration("sip.call.server")
if !ok { if !ok {
t.Fatalf("sip.call.server module not registered") t.Fatalf("sip.call.server module not registered")
} }
@@ -70,7 +70,7 @@ func TestBadSIPCallServer(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["sip.call.server"] registration, ok := module.GetModuleRegistration("sip.call.server")
if !ok { if !ok {
t.Fatalf("sip.call.server module not registered") t.Fatalf("sip.call.server module not registered")
} }
+2 -2
View File
@@ -8,7 +8,7 @@ import (
) )
func TestSIPDTMFServerFromRegistry(t *testing.T) { func TestSIPDTMFServerFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["sip.dtmf.server"] registration, ok := module.GetModuleRegistration("sip.dtmf.server")
if !ok { if !ok {
t.Fatalf("sip.dtmf.server module not registered") t.Fatalf("sip.dtmf.server module not registered")
} }
@@ -89,7 +89,7 @@ func TestBadSIPDTMFServer(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["sip.dtmf.server"] registration, ok := module.GetModuleRegistration("sip.dtmf.server")
if !ok { if !ok {
t.Fatalf("sip.dtmf.server module not registered") t.Fatalf("sip.dtmf.server module not registered")
} }
+2 -2
View File
@@ -8,7 +8,7 @@ import (
) )
func TestTCPClientFromRegistry(t *testing.T) { func TestTCPClientFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["net.tcp.client"] registration, ok := module.GetModuleRegistration("net.tcp.client")
if !ok { if !ok {
t.Fatalf("net.tcp.client module not registered") t.Fatalf("net.tcp.client module not registered")
} }
@@ -77,7 +77,7 @@ func TestBadTCPClient(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["net.tcp.client"] registration, ok := module.GetModuleRegistration("net.tcp.client")
if !ok { if !ok {
t.Fatalf("net.tcp.client module not registered") t.Fatalf("net.tcp.client module not registered")
} }
+3 -3
View File
@@ -9,7 +9,7 @@ import (
) )
func TestTCPServerFromRegistry(t *testing.T) { func TestTCPServerFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["net.tcp.server"] registration, ok := module.GetModuleRegistration("net.tcp.server")
if !ok { if !ok {
t.Fatalf("net.tcp.server module not registered") t.Fatalf("net.tcp.server module not registered")
} }
@@ -54,7 +54,7 @@ func TestGoodTCPServer(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["net.tcp.server"] registration, ok := module.GetModuleRegistration("net.tcp.server")
if !ok { if !ok {
t.Fatalf("net.tcp.server module not registered") t.Fatalf("net.tcp.server module not registered")
} }
@@ -149,7 +149,7 @@ func TestBadTCPServer(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["net.tcp.server"] registration, ok := module.GetModuleRegistration("net.tcp.server")
if !ok { if !ok {
t.Fatalf("net.tcp.server module not registered") t.Fatalf("net.tcp.server module not registered")
} }
+3 -3
View File
@@ -9,7 +9,7 @@ import (
) )
func TestTimeIntervalFromRegistry(t *testing.T) { func TestTimeIntervalFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["time.interval"] registration, ok := module.GetModuleRegistration("time.interval")
if !ok { if !ok {
t.Fatalf("time.interval module not registered") t.Fatalf("time.interval module not registered")
} }
@@ -52,7 +52,7 @@ func TestGoodTimeInterval(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["time.interval"] registration, ok := module.GetModuleRegistration("time.interval")
if !ok { if !ok {
t.Fatalf("time.interval module not registered") t.Fatalf("time.interval module not registered")
} }
@@ -103,7 +103,7 @@ func TestBadTimeInterval(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["time.interval"] registration, ok := module.GetModuleRegistration("time.interval")
if !ok { if !ok {
t.Fatalf("time.interval module not registered") t.Fatalf("time.interval module not registered")
} }
+3 -3
View File
@@ -9,7 +9,7 @@ import (
) )
func TestTimeTimerFromRegistry(t *testing.T) { func TestTimeTimerFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["time.timer"] registration, ok := module.GetModuleRegistration("time.timer")
if !ok { if !ok {
t.Fatalf("time.timer module not registered") t.Fatalf("time.timer module not registered")
} }
@@ -52,7 +52,7 @@ func TestGoodTimeTimer(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["time.timer"] registration, ok := module.GetModuleRegistration("time.timer")
if !ok { if !ok {
t.Fatalf("time.timer module not registered") t.Fatalf("time.timer module not registered")
} }
@@ -103,7 +103,7 @@ func TestBadTimeTimer(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["time.timer"] registration, ok := module.GetModuleRegistration("time.timer")
if !ok { if !ok {
t.Fatalf("time.timer module not registered") t.Fatalf("time.timer module not registered")
} }
+3 -3
View File
@@ -9,7 +9,7 @@ import (
) )
func TestUDPClientFromRegistry(t *testing.T) { func TestUDPClientFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["net.udp.client"] registration, ok := module.GetModuleRegistration("net.udp.client")
if !ok { if !ok {
t.Fatalf("udp.client module not registered") t.Fatalf("udp.client module not registered")
} }
@@ -55,7 +55,7 @@ func TestGoodUDPClient(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["net.udp.client"] registration, ok := module.GetModuleRegistration("net.udp.client")
if !ok { if !ok {
t.Fatalf("net.udp.client module not registered") t.Fatalf("net.udp.client module not registered")
} }
@@ -125,7 +125,7 @@ func TestBadUDPClient(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["net.udp.client"] registration, ok := module.GetModuleRegistration("net.udp.client")
if !ok { if !ok {
t.Fatalf("net.udp.client module not registered") t.Fatalf("net.udp.client module not registered")
} }
+2 -2
View File
@@ -8,7 +8,7 @@ import (
) )
func TestUDPMulticastFromRegistry(t *testing.T) { func TestUDPMulticastFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["net.udp.multicast"] registration, ok := module.GetModuleRegistration("net.udp.multicast")
if !ok { if !ok {
t.Fatalf("udp.multicast module not registered") t.Fatalf("udp.multicast module not registered")
} }
@@ -84,7 +84,7 @@ func TestBadUDPMulticast(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["net.udp.multicast"] registration, ok := module.GetModuleRegistration("net.udp.multicast")
if !ok { if !ok {
t.Fatalf("net.udp.multicast module not registered") t.Fatalf("net.udp.multicast module not registered")
} }
+3 -3
View File
@@ -9,7 +9,7 @@ import (
) )
func TestUDPServerFromRegistry(t *testing.T) { func TestUDPServerFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["net.udp.server"] registration, ok := module.GetModuleRegistration("net.udp.server")
if !ok { if !ok {
t.Fatalf("net.udp.server module not registered") t.Fatalf("net.udp.server module not registered")
} }
@@ -52,7 +52,7 @@ func TestGoodUDPServer(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["net.udp.server"] registration, ok := module.GetModuleRegistration("net.udp.server")
if !ok { if !ok {
t.Fatalf("net.udp.server module not registered") t.Fatalf("net.udp.server module not registered")
} }
@@ -128,7 +128,7 @@ func TestBadUDPServer(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["net.udp.server"] registration, ok := module.GetModuleRegistration("net.udp.server")
if !ok { if !ok {
t.Fatalf("net.udp.server module not registered") t.Fatalf("net.udp.server module not registered")
} }
@@ -8,7 +8,7 @@ import (
) )
func TestWebSocketClientFromRegistry(t *testing.T) { func TestWebSocketClientFromRegistry(t *testing.T) {
registration, ok := module.ModuleRegistry["websocket.client"] registration, ok := module.GetModuleRegistration("websocket.client")
if !ok { if !ok {
t.Fatalf("websocket.client module not registered") t.Fatalf("websocket.client module not registered")
} }
@@ -64,7 +64,7 @@ func TestBadWebSocketClient(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := module.ModuleRegistry["websocket.client"] registration, ok := module.GetModuleRegistration("websocket.client")
if !ok { if !ok {
t.Fatalf("websocket.client module not registered") t.Fatalf("websocket.client module not registered")
} }
+23 -3
View File
@@ -35,13 +35,33 @@ func RegisterProcessor(processor ProcessorRegistration) {
processorRegistryMu.Lock() processorRegistryMu.Lock()
defer processorRegistryMu.Unlock() defer processorRegistryMu.Unlock()
if _, ok := ProcessorRegistry[string(processor.Type)]; ok { if _, ok := processorRegistry[string(processor.Type)]; ok {
panic(fmt.Sprintf("processor already registered: %s", processor.Type)) panic(fmt.Sprintf("processor already registered: %s", processor.Type))
} }
ProcessorRegistry[string(processor.Type)] = processor processorRegistry[string(processor.Type)] = processor
}
type ProcessorRegistry map[string]ProcessorRegistration
func GetProcessorRegistration(processorType string) (ProcessorRegistration, bool) {
processorRegistryMu.RLock()
defer processorRegistryMu.RUnlock()
processor, ok := processorRegistry[processorType]
return processor, ok
}
func GetProcessorRegistrations() []ProcessorRegistration {
processorRegistryMu.RLock()
defer processorRegistryMu.RUnlock()
registrations := make([]ProcessorRegistration, 0, len(processorRegistry))
for _, processor := range processorRegistry {
registrations = append(registrations, processor)
}
return registrations
} }
var ( var (
processorRegistryMu sync.RWMutex processorRegistryMu sync.RWMutex
ProcessorRegistry = make(map[string]ProcessorRegistration) processorRegistry = make(map[string]ProcessorRegistration)
) )
@@ -11,7 +11,7 @@ import (
) )
func TestArtnetPacketDecodeFromRegistry(t *testing.T) { func TestArtnetPacketDecodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["artnet.packet.decode"] registration, ok := processor.GetProcessorRegistration("artnet.packet.decode")
if !ok { if !ok {
t.Fatalf("artnet.packet.decode processor not registered") t.Fatalf("artnet.packet.decode processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestArtnetPacketEncodeFromRegistry(t *testing.T) { func TestArtnetPacketEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["artnet.packet.encode"] registration, ok := processor.GetProcessorRegistration("artnet.packet.encode")
if !ok { if !ok {
t.Fatalf("artnet.packet.encode processor not registered") t.Fatalf("artnet.packet.encode processor not registered")
} }
+5 -5
View File
@@ -12,7 +12,7 @@ import (
) )
func TestDbQueryFromRegistry(t *testing.T) { func TestDbQueryFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["db.query"] registration, ok := processor.GetProcessorRegistration("db.query")
if !ok { if !ok {
t.Fatalf("db.query processor not registered") t.Fatalf("db.query processor not registered")
} }
@@ -100,7 +100,7 @@ func TestGoodDbQuery(t *testing.T) {
} }
for _, testCase := range testCases { for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["db.query"] registration, ok := processor.GetProcessorRegistration("db.query")
if !ok { if !ok {
t.Fatalf("db.query processor not registered") t.Fatalf("db.query processor not registered")
} }
@@ -243,7 +243,7 @@ func TestBadDbQuery(t *testing.T) {
errorString: "db.query unable to find module with id: test", errorString: "db.query unable to find module with id: test",
}, },
{ {
name: "module not a DatabseModule", name: "module not a DatabaseModule",
payload: test.TestStruct{Data: "hello"}, payload: test.TestStruct{Data: "hello"},
params: map[string]any{ params: map[string]any{
"module": "test", "module": "test",
@@ -259,7 +259,7 @@ func TestBadDbQuery(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["db.query"] registration, ok := processor.GetProcessorRegistration("db.query")
if !ok { if !ok {
t.Fatalf("db.query processor not registered") t.Fatalf("db.query processor not registered")
} }
@@ -293,7 +293,7 @@ func TestBadDbQuery(t *testing.T) {
} }
func BenchmarkDbQuery(b *testing.B) { func BenchmarkDbQuery(b *testing.B) {
registration, ok := processor.ProcessorRegistry["db.query"] registration, ok := processor.GetProcessorRegistration("db.query")
if !ok { if !ok {
b.Fatalf("db.query processor not registered") b.Fatalf("db.query processor not registered")
} }
+4 -4
View File
@@ -10,7 +10,7 @@ import (
) )
func TestDebugLogFromRegistry(t *testing.T) { func TestDebugLogFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["debug.log"] registration, ok := processor.GetProcessorRegistration("debug.log")
if !ok { if !ok {
t.Fatalf("debug.log processor not registered") t.Fatalf("debug.log processor not registered")
} }
@@ -52,7 +52,7 @@ func TestGoodDebugLog(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["debug.log"] registration, ok := processor.GetProcessorRegistration("debug.log")
if !ok { if !ok {
t.Fatalf("debug.log processor not registered") t.Fatalf("debug.log processor not registered")
} }
@@ -89,7 +89,7 @@ func TestBadDebugLog(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["debug.log"] registration, ok := processor.GetProcessorRegistration("debug.log")
if !ok { if !ok {
t.Fatalf("debug.log processor not registered") t.Fatalf("debug.log processor not registered")
} }
@@ -120,7 +120,7 @@ func TestBadDebugLog(t *testing.T) {
} }
func BenchmarkDebugLog(b *testing.B) { func BenchmarkDebugLog(b *testing.B) {
registration, ok := processor.ProcessorRegistry["debug.log"] registration, ok := processor.GetProcessorRegistration("debug.log")
if !ok { if !ok {
b.Fatalf("debug.log processor not registered") b.Fatalf("debug.log processor not registered")
} }
@@ -10,7 +10,7 @@ import (
) )
func TestFilterChangeFromRegistry(t *testing.T) { func TestFilterChangeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["filter.change"] registration, ok := processor.GetProcessorRegistration("filter.change")
if !ok { if !ok {
t.Fatalf("filter.change processor not registered") t.Fatalf("filter.change processor not registered")
} }
@@ -58,7 +58,7 @@ func TestGoodFilterChange(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["filter.change"] registration, ok := processor.GetProcessorRegistration("filter.change")
if !ok { if !ok {
t.Fatalf("filter.change processor not registered") t.Fatalf("filter.change processor not registered")
} }
@@ -95,7 +95,7 @@ func TestBadFilterChange(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["filter.change"] registration, ok := processor.GetProcessorRegistration("filter.change")
if !ok { if !ok {
t.Fatalf("filter.change processor not registered") t.Fatalf("filter.change processor not registered")
} }
@@ -126,7 +126,7 @@ func TestBadFilterChange(t *testing.T) {
} }
func BenchmarkFilterChange(b *testing.B) { func BenchmarkFilterChange(b *testing.B) {
registration, ok := processor.ProcessorRegistry["filter.change"] registration, ok := processor.GetProcessorRegistration("filter.change")
if !ok { if !ok {
b.Fatalf("filter.change processor not registered") b.Fatalf("filter.change processor not registered")
} }
+4 -4
View File
@@ -10,7 +10,7 @@ import (
) )
func TestFilterExprFromRegistry(t *testing.T) { func TestFilterExprFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["filter.expr"] registration, ok := processor.GetProcessorRegistration("filter.expr")
if !ok { if !ok {
t.Fatalf("filter.expr processor not registered") t.Fatalf("filter.expr processor not registered")
} }
@@ -71,7 +71,7 @@ func TestGoodFilterExpr(t *testing.T) {
for _, testCase := range testCases { for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["filter.expr"] registration, ok := processor.GetProcessorRegistration("filter.expr")
if !ok { if !ok {
t.Fatalf("filter.expr processor not registered") t.Fatalf("filter.expr processor not registered")
} }
@@ -144,7 +144,7 @@ func TestBadFilterExpr(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["filter.expr"] registration, ok := processor.GetProcessorRegistration("filter.expr")
if !ok { if !ok {
t.Fatalf("filter.expr processor not registered") t.Fatalf("filter.expr processor not registered")
} }
@@ -173,7 +173,7 @@ func TestBadFilterExpr(t *testing.T) {
} }
func BenchmarkFilterExpr(b *testing.B) { func BenchmarkFilterExpr(b *testing.B) {
registration, ok := processor.ProcessorRegistry["filter.expr"] registration, ok := processor.GetProcessorRegistration("filter.expr")
if !ok { if !ok {
b.Fatalf("filter.expr processor not registered") b.Fatalf("filter.expr processor not registered")
} }
+3 -3
View File
@@ -10,7 +10,7 @@ import (
) )
func TestFilterRateFromRegistry(t *testing.T) { func TestFilterRateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["filter.rate"] registration, ok := processor.GetProcessorRegistration("filter.rate")
if !ok { if !ok {
t.Fatalf("filter.rate processor not registered") t.Fatalf("filter.rate processor not registered")
} }
@@ -40,7 +40,7 @@ func TestGoodFilterRate(t *testing.T) {
for _, testCase := range testCases { for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["filter.rate"] registration, ok := processor.GetProcessorRegistration("filter.rate")
if !ok { if !ok {
t.Fatalf("filter.rate processor not registered") t.Fatalf("filter.rate processor not registered")
} }
@@ -87,7 +87,7 @@ func TestBadFilterRate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["filter.rate"] registration, ok := processor.GetProcessorRegistration("filter.rate")
if !ok { if !ok {
t.Fatalf("filter.rate processor not registered") t.Fatalf("filter.rate processor not registered")
} }
+4 -4
View File
@@ -10,7 +10,7 @@ import (
) )
func TestFilterRegexFromRegistry(t *testing.T) { func TestFilterRegexFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["filter.regex"] registration, ok := processor.GetProcessorRegistration("filter.regex")
if !ok { if !ok {
t.Fatalf("filter.regex processor not registered") t.Fatalf("filter.regex processor not registered")
} }
@@ -77,7 +77,7 @@ func TestGoodFilterRegex(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["filter.regex"] registration, ok := processor.GetProcessorRegistration("filter.regex")
if !ok { if !ok {
t.Fatalf("filter.regex processor not registered") t.Fatalf("filter.regex processor not registered")
} }
@@ -145,7 +145,7 @@ func TestBadFilterRegex(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["filter.regex"] registration, ok := processor.GetProcessorRegistration("filter.regex")
if !ok { if !ok {
t.Fatalf("filter.regex processor not registered") t.Fatalf("filter.regex processor not registered")
} }
@@ -176,7 +176,7 @@ func TestBadFilterRegex(t *testing.T) {
} }
func BenchmarkFilterRegex(b *testing.B) { func BenchmarkFilterRegex(b *testing.B) {
registration, ok := processor.ProcessorRegistry["filter.regex"] registration, ok := processor.GetProcessorRegistration("filter.regex")
if !ok { if !ok {
b.Fatalf("filter.regex processor not registered") b.Fatalf("filter.regex processor not registered")
} }
+4 -4
View File
@@ -10,7 +10,7 @@ import (
) )
func TestFloatParseFromRegistry(t *testing.T) { func TestFloatParseFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["float.parse"] registration, ok := processor.GetProcessorRegistration("float.parse")
if !ok { if !ok {
t.Fatalf("float.parse processor not registered") t.Fatalf("float.parse processor not registered")
} }
@@ -63,7 +63,7 @@ func TestGoodFloatParse(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["float.parse"] registration, ok := processor.GetProcessorRegistration("float.parse")
if !ok { if !ok {
t.Fatalf("float.parse processor not registered") t.Fatalf("float.parse processor not registered")
} }
@@ -136,7 +136,7 @@ func TestBadFloatParse(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["float.parse"] registration, ok := processor.GetProcessorRegistration("float.parse")
if !ok { if !ok {
t.Fatalf("float.parse processor not registered") t.Fatalf("float.parse processor not registered")
} }
@@ -167,7 +167,7 @@ func TestBadFloatParse(t *testing.T) {
} }
func BenchmarkFloatParse(b *testing.B) { func BenchmarkFloatParse(b *testing.B) {
registration, ok := processor.ProcessorRegistry["float.parse"] registration, ok := processor.GetProcessorRegistration("float.parse")
if !ok { if !ok {
b.Fatalf("float.parse processor not registered") b.Fatalf("float.parse processor not registered")
} }
+4 -4
View File
@@ -9,7 +9,7 @@ import (
) )
func TestFloatRandomFromRegistry(t *testing.T) { func TestFloatRandomFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["float.random"] registration, ok := processor.GetProcessorRegistration("float.random")
if !ok { if !ok {
t.Fatalf("float.random processor not registered") t.Fatalf("float.random processor not registered")
} }
@@ -57,7 +57,7 @@ func TestGoodFloatRandom(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["float.random"] registration, ok := processor.GetProcessorRegistration("float.random")
if !ok { if !ok {
t.Fatalf("float.random processor not registered") t.Fatalf("float.random processor not registered")
} }
@@ -155,7 +155,7 @@ func TestBadFloatRandom(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["float.random"] registration, ok := processor.GetProcessorRegistration("float.random")
if !ok { if !ok {
t.Fatalf("float.random processor not registered") t.Fatalf("float.random processor not registered")
} }
@@ -186,7 +186,7 @@ func TestBadFloatRandom(t *testing.T) {
} }
func BenchmarkFloatRandom(b *testing.B) { func BenchmarkFloatRandom(b *testing.B) {
registration, ok := processor.ProcessorRegistry["float.random"] registration, ok := processor.GetProcessorRegistration("float.random")
if !ok { if !ok {
b.Fatalf("float.random processor not registered") b.Fatalf("float.random processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestFreeDCreateFromRegistry(t *testing.T) { func TestFreeDCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["freed.create"] registration, ok := processor.GetProcessorRegistration("freed.create")
if !ok { if !ok {
t.Fatalf("freed.create processor not registered") t.Fatalf("freed.create processor not registered")
} }
@@ -89,7 +89,7 @@ func TestGoodFreeDCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["freed.create"] registration, ok := processor.GetProcessorRegistration("freed.create")
if !ok { if !ok {
t.Fatalf("freed.create processor not registered") t.Fatalf("freed.create processor not registered")
} }
@@ -848,7 +848,7 @@ func TestBadFreeDCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["freed.create"] registration, ok := processor.GetProcessorRegistration("freed.create")
if !ok { if !ok {
t.Fatalf("freed.create processor not registered") t.Fatalf("freed.create processor not registered")
} }
@@ -879,7 +879,7 @@ func TestBadFreeDCreate(t *testing.T) {
} }
func BenchmarkFreeDCreate(b *testing.B) { func BenchmarkFreeDCreate(b *testing.B) {
registration, ok := processor.ProcessorRegistry["freed.create"] registration, ok := processor.GetProcessorRegistration("freed.create")
if !ok { if !ok {
b.Fatalf("freed.create processor not registered") b.Fatalf("freed.create processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestFreeDDecodeFromRegistry(t *testing.T) { func TestFreeDDecodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["freed.decode"] registration, ok := processor.GetProcessorRegistration("freed.decode")
if !ok { if !ok {
t.Fatalf("freed.decode processor not registered") t.Fatalf("freed.decode processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestFreeDEncodeFromRegistry(t *testing.T) { func TestFreeDEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["freed.encode"] registration, ok := processor.GetProcessorRegistration("freed.encode")
if !ok { if !ok {
t.Fatalf("freed.encode processor not registered") t.Fatalf("freed.encode processor not registered")
} }
@@ -10,7 +10,7 @@ import (
) )
func TestHTTPRequestCreateFromRegistry(t *testing.T) { func TestHTTPRequestCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["http.request.do"] registration, ok := processor.GetProcessorRegistration("http.request.do")
if !ok { if !ok {
t.Fatalf("http.request.do processor not registered") t.Fatalf("http.request.do processor not registered")
} }
@@ -44,7 +44,7 @@ func TestGoodHTTPRequestDo(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["http.request.do"] registration, ok := processor.GetProcessorRegistration("http.request.do")
if !ok { if !ok {
t.Fatalf("http.request.do processor not registered") t.Fatalf("http.request.do processor not registered")
} }
@@ -132,7 +132,7 @@ func TestBadHTTPRequestDo(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["http.request.do"] registration, ok := processor.GetProcessorRegistration("http.request.do")
if !ok { if !ok {
t.Fatalf("http.request.do processor not registered") t.Fatalf("http.request.do processor not registered")
} }
@@ -10,7 +10,7 @@ import (
) )
func TestHTTPResponseCreateFromRegistry(t *testing.T) { func TestHTTPResponseCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["http.response.create"] registration, ok := processor.GetProcessorRegistration("http.response.create")
if !ok { if !ok {
t.Fatalf("http.response.create processor not registered") t.Fatalf("http.response.create processor not registered")
} }
@@ -54,7 +54,7 @@ func TestGoodHTTPResponseCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["http.response.create"] registration, ok := processor.GetProcessorRegistration("http.response.create")
if !ok { if !ok {
t.Fatalf("http.response.create processor not registered") t.Fatalf("http.response.create processor not registered")
} }
@@ -128,7 +128,7 @@ func TestBadHTTPResponseCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["http.response.create"] registration, ok := processor.GetProcessorRegistration("http.response.create")
if !ok { if !ok {
t.Fatalf("http.response.create processor not registered") t.Fatalf("http.response.create processor not registered")
} }
@@ -159,7 +159,7 @@ func TestBadHTTPResponseCreate(t *testing.T) {
} }
func BenchmarkHTTPResponseCreate(b *testing.B) { func BenchmarkHTTPResponseCreate(b *testing.B) {
registration, ok := processor.ProcessorRegistry["http.response.create"] registration, ok := processor.GetProcessorRegistration("http.response.create")
if !ok { if !ok {
b.Fatalf("http.response.create processor not registered") b.Fatalf("http.response.create processor not registered")
} }
+4 -4
View File
@@ -10,7 +10,7 @@ import (
) )
func TestIntParseFromRegistry(t *testing.T) { func TestIntParseFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["int.parse"] registration, ok := processor.GetProcessorRegistration("int.parse")
if !ok { if !ok {
t.Fatalf("int.parse processor not registered") t.Fatalf("int.parse processor not registered")
} }
@@ -84,7 +84,7 @@ func TestGoodIntParse(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["int.parse"] registration, ok := processor.GetProcessorRegistration("int.parse")
if !ok { if !ok {
t.Fatalf("int.parse processor not registered") t.Fatalf("int.parse processor not registered")
} }
@@ -170,7 +170,7 @@ func TestBadIntParse(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["int.parse"] registration, ok := processor.GetProcessorRegistration("int.parse")
if !ok { if !ok {
t.Fatalf("int.parse processor not registered") t.Fatalf("int.parse processor not registered")
} }
@@ -201,7 +201,7 @@ func TestBadIntParse(t *testing.T) {
} }
func BenchmarkIntParse(b *testing.B) { func BenchmarkIntParse(b *testing.B) {
registration, ok := processor.ProcessorRegistry["int.parse"] registration, ok := processor.GetProcessorRegistration("int.parse")
if !ok { if !ok {
b.Fatalf("int.parse processor not registered") b.Fatalf("int.parse processor not registered")
} }
+5 -5
View File
@@ -9,7 +9,7 @@ import (
) )
func TestIntRandomFromRegistry(t *testing.T) { func TestIntRandomFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["int.random"] registration, ok := processor.GetProcessorRegistration("int.random")
if !ok { if !ok {
t.Fatalf("int.random processor not registered") t.Fatalf("int.random processor not registered")
} }
@@ -32,7 +32,7 @@ func TestIntRandomFromRegistry(t *testing.T) {
} }
func TestIntRandomGoodConfig(t *testing.T) { func TestIntRandomGoodConfig(t *testing.T) {
registration, ok := processor.ProcessorRegistry["int.random"] registration, ok := processor.GetProcessorRegistration("int.random")
if !ok { if !ok {
t.Fatalf("int.random processor not registered") t.Fatalf("int.random processor not registered")
} }
@@ -84,7 +84,7 @@ func TestGoodIntRandom(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["int.random"] registration, ok := processor.GetProcessorRegistration("int.random")
if !ok { if !ok {
t.Fatalf("int.random processor not registered") t.Fatalf("int.random processor not registered")
} }
@@ -166,7 +166,7 @@ func TestBadIntRandom(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["int.random"] registration, ok := processor.GetProcessorRegistration("int.random")
if !ok { if !ok {
t.Fatalf("int.random processor not registered") t.Fatalf("int.random processor not registered")
} }
@@ -197,7 +197,7 @@ func TestBadIntRandom(t *testing.T) {
} }
func BenchmarkIntRandom(b *testing.B) { func BenchmarkIntRandom(b *testing.B) {
registration, ok := processor.ProcessorRegistry["int.random"] registration, ok := processor.GetProcessorRegistration("int.random")
if !ok { if !ok {
b.Fatalf("int.random processor not registered") b.Fatalf("int.random processor not registered")
} }
+4 -4
View File
@@ -9,7 +9,7 @@ import (
) )
func TestIntScaleFromRegistry(t *testing.T) { func TestIntScaleFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["int.scale"] registration, ok := processor.GetProcessorRegistration("int.scale")
if !ok { if !ok {
t.Fatalf("int.scale processor not registered") t.Fatalf("int.scale processor not registered")
} }
@@ -55,7 +55,7 @@ func TestGoodIntScale(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["int.scale"] registration, ok := processor.GetProcessorRegistration("int.scale")
if !ok { if !ok {
t.Fatalf("int.scale processor not registered") t.Fatalf("int.scale processor not registered")
} }
@@ -140,7 +140,7 @@ func TestBadIntScale(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["int.scale"] registration, ok := processor.GetProcessorRegistration("int.scale")
if !ok { if !ok {
t.Fatalf("int.scale processor not registered") t.Fatalf("int.scale processor not registered")
} }
@@ -171,7 +171,7 @@ func TestBadIntScale(t *testing.T) {
} }
func BenchmarkIntScale(b *testing.B) { func BenchmarkIntScale(b *testing.B) {
registration, ok := processor.ProcessorRegistry["int.scale"] registration, ok := processor.GetProcessorRegistration("int.scale")
if !ok { if !ok {
b.Fatalf("int.scale processor not registered") b.Fatalf("int.scale processor not registered")
} }
+2 -2
View File
@@ -11,7 +11,7 @@ import (
) )
func TestJsonDecodeFromRegistry(t *testing.T) { func TestJsonDecodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["json.decode"] registration, ok := processor.GetProcessorRegistration("json.decode")
if !ok { if !ok {
t.Fatalf("json.decode processor not registered") t.Fatalf("json.decode processor not registered")
} }
@@ -127,7 +127,7 @@ func TestBadJsonDecode(t *testing.T) {
} }
func BenchmarkJsonDecode(b *testing.B) { func BenchmarkJsonDecode(b *testing.B) {
registration, ok := processor.ProcessorRegistry["json.decode"] registration, ok := processor.GetProcessorRegistration("json.decode")
if !ok { if !ok {
b.Fatalf("json.decode processor not registered") b.Fatalf("json.decode processor not registered")
} }
+2 -2
View File
@@ -12,7 +12,7 @@ import (
) )
func TestJsonEncodeFromRegistry(t *testing.T) { func TestJsonEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["json.encode"] registration, ok := processor.GetProcessorRegistration("json.encode")
if !ok { if !ok {
t.Fatalf("json.encode processor not registered") t.Fatalf("json.encode processor not registered")
} }
@@ -116,7 +116,7 @@ func TestBadJsonEncode(t *testing.T) {
} }
func BenchmarkJsonEncode(b *testing.B) { func BenchmarkJsonEncode(b *testing.B) {
registration, ok := processor.ProcessorRegistry["json.encode"] registration, ok := processor.GetProcessorRegistration("json.encode")
if !ok { if !ok {
b.Fatalf("json.encode processor not registered") b.Fatalf("json.encode processor not registered")
} }
+4 -4
View File
@@ -11,7 +11,7 @@ import (
) )
func TestKvGetFromRegistry(t *testing.T) { func TestKvGetFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["kv.get"] registration, ok := processor.GetProcessorRegistration("kv.get")
if !ok { if !ok {
t.Fatalf("kv.get processor not registered") t.Fatalf("kv.get processor not registered")
} }
@@ -75,7 +75,7 @@ func TestGoodKvGet(t *testing.T) {
} }
for _, testCase := range testCases { for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["kv.get"] registration, ok := processor.GetProcessorRegistration("kv.get")
if !ok { if !ok {
t.Fatalf("kv.get processor not registered") t.Fatalf("kv.get processor not registered")
} }
@@ -198,7 +198,7 @@ func TestBadKvGet(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["kv.get"] registration, ok := processor.GetProcessorRegistration("kv.get")
if !ok { if !ok {
t.Fatalf("kv.get processor not registered") t.Fatalf("kv.get processor not registered")
} }
@@ -229,7 +229,7 @@ func TestBadKvGet(t *testing.T) {
} }
func BenchmarkKvGet(b *testing.B) { func BenchmarkKvGet(b *testing.B) {
registration, ok := processor.ProcessorRegistry["kv.get"] registration, ok := processor.GetProcessorRegistration("kv.get")
if !ok { if !ok {
b.Fatalf("kv.get processor not registered") b.Fatalf("kv.get processor not registered")
} }
+4 -4
View File
@@ -11,7 +11,7 @@ import (
) )
func TestKvSetFromRegistry(t *testing.T) { func TestKvSetFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["kv.set"] registration, ok := processor.GetProcessorRegistration("kv.set")
if !ok { if !ok {
t.Fatalf("kv.set processor not registered") t.Fatalf("kv.set processor not registered")
} }
@@ -69,7 +69,7 @@ func TestGoodKvSet(t *testing.T) {
} }
for _, testCase := range testCases { for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["kv.set"] registration, ok := processor.GetProcessorRegistration("kv.set")
if !ok { if !ok {
t.Fatalf("kv.set processor not registered") t.Fatalf("kv.set processor not registered")
} }
@@ -192,7 +192,7 @@ func TestBadKvSet(t *testing.T) {
for _, testCase := range testCases { for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["kv.set"] registration, ok := processor.GetProcessorRegistration("kv.set")
if !ok { if !ok {
t.Fatalf("kv.set processor not registered") t.Fatalf("kv.set processor not registered")
} }
@@ -223,7 +223,7 @@ func TestBadKvSet(t *testing.T) {
} }
func BenchmarkKvSet(b *testing.B) { func BenchmarkKvSet(b *testing.B) {
registration, ok := processor.ProcessorRegistry["kv.set"] registration, ok := processor.GetProcessorRegistration("kv.set")
if !ok { if !ok {
b.Fatalf("kv.set processor not registered") b.Fatalf("kv.set processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestMIDIControlChangeCreateFromRegistry(t *testing.T) { func TestMIDIControlChangeCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.control_change.create"] registration, ok := processor.GetProcessorRegistration("midi.control_change.create")
if !ok { if !ok {
t.Fatalf("midi.control_change.create processor not registered") t.Fatalf("midi.control_change.create processor not registered")
} }
@@ -57,7 +57,7 @@ func TestGoodMIDIControlChangeCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.control_change.create"] registration, ok := processor.GetProcessorRegistration("midi.control_change.create")
if !ok { if !ok {
t.Fatalf("midi.control_change.create processor not registered") t.Fatalf("midi.control_change.create processor not registered")
} }
@@ -130,7 +130,7 @@ func TestBadMIDIControlChangeCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.control_change.create"] registration, ok := processor.GetProcessorRegistration("midi.control_change.create")
if !ok { if !ok {
t.Fatalf("midi.control_change.create processor not registered") t.Fatalf("midi.control_change.create processor not registered")
} }
@@ -161,7 +161,7 @@ func TestBadMIDIControlChangeCreate(t *testing.T) {
} }
func BenchmarkMIDIControlChangeCreate(b *testing.B) { func BenchmarkMIDIControlChangeCreate(b *testing.B) {
registration, ok := processor.ProcessorRegistry["midi.control_change.create"] registration, ok := processor.GetProcessorRegistration("midi.control_change.create")
if !ok { if !ok {
b.Fatalf("midi.control_change.create processor not registered") b.Fatalf("midi.control_change.create processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestMIDIMessageDecodeFromRegistry(t *testing.T) { func TestMIDIMessageDecodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.message.decode"] registration, ok := processor.GetProcessorRegistration("midi.message.decode")
if !ok { if !ok {
t.Fatalf("midi.message.decode processor not registered") t.Fatalf("midi.message.decode processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestMIDIMessageEncodeFromRegistry(t *testing.T) { func TestMIDIMessageEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.message.encode"] registration, ok := processor.GetProcessorRegistration("midi.message.encode")
if !ok { if !ok {
t.Fatalf("midi.message.encode processor not registered") t.Fatalf("midi.message.encode processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestMIDIMessageUnpackFromRegistry(t *testing.T) { func TestMIDIMessageUnpackFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.message.unpack"] registration, ok := processor.GetProcessorRegistration("midi.message.unpack")
if !ok { if !ok {
t.Fatalf("midi.message.unpack processor not registered") t.Fatalf("midi.message.unpack processor not registered")
} }
@@ -121,7 +121,7 @@ func TestBadMIDIMessageUnpack(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.message.unpack"] registration, ok := processor.GetProcessorRegistration("midi.message.unpack")
if !ok { if !ok {
t.Fatalf("midi.message.unpack processor not registered") t.Fatalf("midi.message.unpack processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestMIDINoteOffCreteaFromRegistry(t *testing.T) { func TestMIDINoteOffCreteaFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.note_off.create"] registration, ok := processor.GetProcessorRegistration("midi.note_off.create")
if !ok { if !ok {
t.Fatalf("midi.note_off.create processor not registered") t.Fatalf("midi.note_off.create processor not registered")
} }
@@ -56,7 +56,7 @@ func TestGoodMIDINoteOffCretea(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.note_off.create"] registration, ok := processor.GetProcessorRegistration("midi.note_off.create")
if !ok { if !ok {
t.Fatalf("midi.note_off.create processor not registered") t.Fatalf("midi.note_off.create processor not registered")
} }
@@ -129,7 +129,7 @@ func TestBadMIDINoteOffCretea(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.note_off.create"] registration, ok := processor.GetProcessorRegistration("midi.note_off.create")
if !ok { if !ok {
t.Fatalf("midi.note_off.create processor not registered") t.Fatalf("midi.note_off.create processor not registered")
} }
@@ -160,7 +160,7 @@ func TestBadMIDINoteOffCretea(t *testing.T) {
} }
func BenchmarkMIDINoteOffCreate(b *testing.B) { func BenchmarkMIDINoteOffCreate(b *testing.B) {
registration, ok := processor.ProcessorRegistry["midi.note_off.create"] registration, ok := processor.GetProcessorRegistration("midi.note_off.create")
if !ok { if !ok {
b.Fatalf("midi.note_off.create processor not registered") b.Fatalf("midi.note_off.create processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestMIDINoteOnCreateFromRegistry(t *testing.T) { func TestMIDINoteOnCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.note_on.create"] registration, ok := processor.GetProcessorRegistration("midi.note_on.create")
if !ok { if !ok {
t.Fatalf("midi.note_on.create processor not registered") t.Fatalf("midi.note_on.create processor not registered")
} }
@@ -56,7 +56,7 @@ func TestGoodMIDINoteOnCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.note_on.create"] registration, ok := processor.GetProcessorRegistration("midi.note_on.create")
if !ok { if !ok {
t.Fatalf("midi.note_on.create processor not registered") t.Fatalf("midi.note_on.create processor not registered")
} }
@@ -126,7 +126,7 @@ func TestBadMIDINoteOnCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.note_on.create"] registration, ok := processor.GetProcessorRegistration("midi.note_on.create")
if !ok { if !ok {
t.Fatalf("midi.note_on.create processor not registered") t.Fatalf("midi.note_on.create processor not registered")
} }
@@ -157,7 +157,7 @@ func TestBadMIDINoteOnCreate(t *testing.T) {
} }
func BenchmarkMIDINoteOnCreate(b *testing.B) { func BenchmarkMIDINoteOnCreate(b *testing.B) {
registration, ok := processor.ProcessorRegistry["midi.note_on.create"] registration, ok := processor.GetProcessorRegistration("midi.note_on.create")
if !ok { if !ok {
b.Fatalf("midi.note_on.create processor not registered") b.Fatalf("midi.note_on.create processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestMIDIProgramChangeCreateFromRegistry(t *testing.T) { func TestMIDIProgramChangeCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.program_change.create"] registration, ok := processor.GetProcessorRegistration("midi.program_change.create")
if !ok { if !ok {
t.Fatalf("midi.program_change.create processor not registered") t.Fatalf("midi.program_change.create processor not registered")
} }
@@ -55,7 +55,7 @@ func TestGoodMIDIProgramChangeCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.program_change.create"] registration, ok := processor.GetProcessorRegistration("midi.program_change.create")
if !ok { if !ok {
t.Fatalf("midi.program_change.create processor not registered") t.Fatalf("midi.program_change.create processor not registered")
} }
@@ -116,7 +116,7 @@ func TestBadMIDIProgramChangeCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.program_change.create"] registration, ok := processor.GetProcessorRegistration("midi.program_change.create")
if !ok { if !ok {
t.Fatalf("midi.program_change.create processor not registered") t.Fatalf("midi.program_change.create processor not registered")
} }
@@ -147,7 +147,7 @@ func TestBadMIDIProgramChangeCreate(t *testing.T) {
} }
func BenchmarkMIDIProgramChangeCreate(b *testing.B) { func BenchmarkMIDIProgramChangeCreate(b *testing.B) {
registration, ok := processor.ProcessorRegistry["midi.program_change.create"] registration, ok := processor.GetProcessorRegistration("midi.program_change.create")
if !ok { if !ok {
b.Fatalf("midi.program_change.create processor not registered") b.Fatalf("midi.program_change.create processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestModuleOutputFromRegistry(t *testing.T) { func TestModuleOutputFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["module.output"] registration, ok := processor.GetProcessorRegistration("module.output")
if !ok { if !ok {
t.Fatalf("module.output processor not registered") t.Fatalf("module.output processor not registered")
} }
@@ -37,9 +37,9 @@ func TestModuleOutputFromRegistry(t *testing.T) {
router := test.GetNewTestRouter() router := test.GetNewTestRouter()
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{ got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
InputHandler: router.HandleInput, InputHandler: router.HandleInput,
Modules: map[string]common.Module{"test": &test.TestOutputModule{}}, Modules: map[string]common.Module{"test": &test.TestOutputModule{}},
Payload: payload, Payload: payload,
}) })
if err != nil { if err != nil {
t.Fatalf("module.output processing failed: %s", err) t.Fatalf("module.output processing failed: %s", err)
@@ -62,7 +62,7 @@ func TestGoodModuleOutput(t *testing.T) {
for _, testCase := range testCases { for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["module.output"] registration, ok := processor.GetProcessorRegistration("module.output")
if !ok { if !ok {
t.Fatalf("module.output processor not registered") t.Fatalf("module.output processor not registered")
} }
@@ -126,7 +126,7 @@ func TestBadModuleOutput(t *testing.T) {
for _, testCase := range testCases { for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["module.output"] registration, ok := processor.GetProcessorRegistration("module.output")
if !ok { if !ok {
t.Fatalf("module.output processor not registered") t.Fatalf("module.output processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestOSCMessageCreateFromRegistry(t *testing.T) { func TestOSCMessageCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["osc.message.create"] registration, ok := processor.GetProcessorRegistration("osc.message.create")
if !ok { if !ok {
t.Fatalf("osc.message.create processor not registered") t.Fatalf("osc.message.create processor not registered")
} }
@@ -146,7 +146,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["osc.message.create"] registration, ok := processor.GetProcessorRegistration("osc.message.create")
if !ok { if !ok {
t.Fatalf("osc.message.create processor not registered") t.Fatalf("osc.message.create processor not registered")
} }
@@ -371,7 +371,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["osc.message.create"] registration, ok := processor.GetProcessorRegistration("osc.message.create")
if !ok { if !ok {
t.Fatalf("osc.message.create processor not registered") t.Fatalf("osc.message.create processor not registered")
} }
@@ -402,7 +402,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
} }
func BenchmarkOSCMessageCreate(b *testing.B) { func BenchmarkOSCMessageCreate(b *testing.B) {
registration, ok := processor.ProcessorRegistry["osc.message.create"] registration, ok := processor.GetProcessorRegistration("osc.message.create")
if !ok { if !ok {
b.Fatalf("osc.message.create processor not registered") b.Fatalf("osc.message.create processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestOSCMessageDecodeFromRegistry(t *testing.T) { func TestOSCMessageDecodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["osc.message.decode"] registration, ok := processor.GetProcessorRegistration("osc.message.decode")
if !ok { if !ok {
t.Fatalf("osc.message.decode processor not registered") t.Fatalf("osc.message.decode processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestOSCMessageEncodeFromRegistry(t *testing.T) { func TestOSCMessageEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["osc.message.encode"] registration, ok := processor.GetProcessorRegistration("osc.message.encode")
if !ok { if !ok {
t.Fatalf("osc.message.encode processor not registered") t.Fatalf("osc.message.encode processor not registered")
} }
@@ -12,7 +12,7 @@ import (
) )
func TestPubSubPublishFromRegistry(t *testing.T) { func TestPubSubPublishFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["pubsub.publish"] registration, ok := processor.GetProcessorRegistration("pubsub.publish")
if !ok { if !ok {
t.Fatalf("pubsub.publish processor not registered") t.Fatalf("pubsub.publish processor not registered")
} }
@@ -70,7 +70,7 @@ func TestGoodPubSubPublish(t *testing.T) {
} }
for _, testCase := range testCases { for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["pubsub.publish"] registration, ok := processor.GetProcessorRegistration("pubsub.publish")
if !ok { if !ok {
t.Fatalf("pubsub.publish processor not registered") t.Fatalf("pubsub.publish processor not registered")
} }
@@ -217,7 +217,7 @@ func TestBadPubSubPublish(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["pubsub.publish"] registration, ok := processor.GetProcessorRegistration("pubsub.publish")
if !ok { if !ok {
t.Fatalf("pubsub.publish processor not registered") t.Fatalf("pubsub.publish processor not registered")
} }
+16 -16
View File
@@ -11,7 +11,7 @@ import (
) )
func TestRouterInputFromRegistry(t *testing.T) { func TestRouterInputFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["router.input"] registration, ok := processor.GetProcessorRegistration("router.input")
if !ok { if !ok {
t.Fatalf("router.input processor not registered") t.Fatalf("router.input processor not registered")
} }
@@ -35,8 +35,8 @@ func TestRouterInputFromRegistry(t *testing.T) {
expected := "test" expected := "test"
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{ got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
InputHandler: test.GetNewTestRouter().HandleInput, InputHandler: test.GetNewTestRouter().HandleInput,
Payload: payload, Payload: payload,
}) })
if err != nil { if err != nil {
t.Fatalf("router.input processing failed: %s", err) t.Fatalf("router.input processing failed: %s", err)
@@ -59,7 +59,7 @@ func TestGoodRouterInput(t *testing.T) {
for _, testCase := range testCases { for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["router.input"] registration, ok := processor.GetProcessorRegistration("router.input")
if !ok { if !ok {
t.Fatalf("router.input processor not registered") t.Fatalf("router.input processor not registered")
} }
@@ -95,36 +95,36 @@ func TestBadRouterInput(t *testing.T) {
errorString string errorString string
}{ }{
{ {
name: "no source param", name: "no source param",
params: map[string]any{}, params: map[string]any{},
payload: "test", payload: "test",
inputHandler: router.HandleInput, inputHandler: router.HandleInput,
errorString: "router.input source error: not found", errorString: "router.input source error: not found",
}, },
{ {
name: "non-string source", name: "non-string source",
params: map[string]any{ params: map[string]any{
"source": 123, "source": 123,
}, },
payload: "test", payload: "test",
inputHandler: router.HandleInput, inputHandler: router.HandleInput,
errorString: "router.input source error: not a string", errorString: "router.input source error: not a string",
}, },
{ {
name: "router not found in context", name: "router not found in context",
params: map[string]any{ params: map[string]any{
"source": "test", "source": "test",
}, },
payload: "test", payload: "test",
inputHandler: nil, inputHandler: nil,
errorString: "router.input no input handler found", errorString: "router.input no input handler found",
}, },
} }
for _, testCase := range testCases { for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["router.input"] registration, ok := processor.GetProcessorRegistration("router.input")
if !ok { if !ok {
t.Fatalf("router.input processor not registered") t.Fatalf("router.input processor not registered")
} }
+4 -4
View File
@@ -9,7 +9,7 @@ import (
) )
func TestScriptExprFromRegistry(t *testing.T) { func TestScriptExprFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["script.expr"] registration, ok := processor.GetProcessorRegistration("script.expr")
if !ok { if !ok {
t.Fatalf("script.expr processor not registered") t.Fatalf("script.expr processor not registered")
} }
@@ -62,7 +62,7 @@ func TestGoodScriptExpr(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["script.expr"] registration, ok := processor.GetProcessorRegistration("script.expr")
if !ok { if !ok {
t.Fatalf("script.expr processor not registered") t.Fatalf("script.expr processor not registered")
} }
@@ -117,7 +117,7 @@ func TestBadScriptExpr(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["script.expr"] registration, ok := processor.GetProcessorRegistration("script.expr")
if !ok { if !ok {
t.Fatalf("script.expr processor not registered") t.Fatalf("script.expr processor not registered")
} }
@@ -148,7 +148,7 @@ func TestBadScriptExpr(t *testing.T) {
} }
func BenchmarkScriptExpr(b *testing.B) { func BenchmarkScriptExpr(b *testing.B) {
registration, ok := processor.ProcessorRegistry["script.expr"] registration, ok := processor.GetProcessorRegistration("script.expr")
if !ok { if !ok {
b.Fatalf("script.expr processor not registered") b.Fatalf("script.expr processor not registered")
} }
+6 -6
View File
@@ -10,7 +10,7 @@ import (
) )
func TestScriptJSFromRegistry(t *testing.T) { func TestScriptJSFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["script.js"] registration, ok := processor.GetProcessorRegistration("script.js")
if !ok { if !ok {
t.Fatalf("script.js processor not registered") t.Fatalf("script.js processor not registered")
} }
@@ -45,7 +45,7 @@ func TestScriptJSFromRegistry(t *testing.T) {
} }
func TestScriptJSNoProgram(t *testing.T) { func TestScriptJSNoProgram(t *testing.T) {
registration, ok := processor.ProcessorRegistry["script.js"] registration, ok := processor.GetProcessorRegistration("script.js")
if !ok { if !ok {
t.Fatalf("script.js processor not registered") t.Fatalf("script.js processor not registered")
} }
@@ -61,7 +61,7 @@ func TestScriptJSNoProgram(t *testing.T) {
} }
func TestScriptJSBadConfigWrongProgramType(t *testing.T) { func TestScriptJSBadConfigWrongProgramType(t *testing.T) {
registration, ok := processor.ProcessorRegistry["script.js"] registration, ok := processor.GetProcessorRegistration("script.js")
if !ok { if !ok {
t.Fatalf("script.js processor not registered") t.Fatalf("script.js processor not registered")
} }
@@ -151,7 +151,7 @@ func TestGoodScriptJS(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["script.js"] registration, ok := processor.GetProcessorRegistration("script.js")
if !ok { if !ok {
t.Fatalf("script.js processor not registered") t.Fatalf("script.js processor not registered")
} }
@@ -199,7 +199,7 @@ func TestBadScriptJS(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["script.js"] registration, ok := processor.GetProcessorRegistration("script.js")
if !ok { if !ok {
t.Fatalf("script.js processor not registered") t.Fatalf("script.js processor not registered")
} }
@@ -230,7 +230,7 @@ func TestBadScriptJS(t *testing.T) {
} }
func BenchmarkScriptJS(b *testing.B) { func BenchmarkScriptJS(b *testing.B) {
registration, ok := processor.ProcessorRegistry["script.js"] registration, ok := processor.GetProcessorRegistration("script.js")
if !ok { if !ok {
b.Fatalf("script.js processor not registered") b.Fatalf("script.js processor not registered")
} }
+4 -4
View File
@@ -11,7 +11,7 @@ import (
) )
func TestScriptWASMFromRegistry(t *testing.T) { func TestScriptWASMFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["script.wasm"] registration, ok := processor.GetProcessorRegistration("script.wasm")
if !ok { if !ok {
t.Fatalf("script.wasm processor not registered") t.Fatalf("script.wasm processor not registered")
} }
@@ -60,7 +60,7 @@ func TestGoodScriptWASM(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["script.wasm"] registration, ok := processor.GetProcessorRegistration("script.wasm")
if !ok { if !ok {
t.Fatalf("script.wasm processor not registered") t.Fatalf("script.wasm processor not registered")
} }
@@ -160,7 +160,7 @@ func TestBadScriptWASM(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["script.wasm"] registration, ok := processor.GetProcessorRegistration("script.wasm")
if !ok { if !ok {
t.Fatalf("script.wasm processor not registered") t.Fatalf("script.wasm processor not registered")
} }
@@ -191,7 +191,7 @@ func TestBadScriptWASM(t *testing.T) {
} }
func BenchmarkScriptWASM(b *testing.B) { func BenchmarkScriptWASM(b *testing.B) {
registration, ok := processor.ProcessorRegistry["script.wasm"] registration, ok := processor.GetProcessorRegistration("script.wasm")
if !ok { if !ok {
b.Fatalf("script.wasm processor not registered") b.Fatalf("script.wasm processor not registered")
} }
@@ -10,7 +10,7 @@ import (
) )
func TestSipResponseAudioCreateFromRegistry(t *testing.T) { func TestSipResponseAudioCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["sip.response.audio.create"] registration, ok := processor.GetProcessorRegistration("sip.response.audio.create")
if !ok { if !ok {
t.Fatalf("sip.response.audio.create processor not registered") t.Fatalf("sip.response.audio.create processor not registered")
} }
@@ -76,7 +76,7 @@ func TestGoodSipResponseAudioCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["sip.response.audio.create"] registration, ok := processor.GetProcessorRegistration("sip.response.audio.create")
if !ok { if !ok {
t.Fatalf("sip.response.audio.create processor not registered") t.Fatalf("sip.response.audio.create processor not registered")
} }
@@ -183,7 +183,7 @@ func TestBadSipResponseAudioCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["sip.response.audio.create"] registration, ok := processor.GetProcessorRegistration("sip.response.audio.create")
if !ok { if !ok {
t.Fatalf("sip.response.audio.create processor not registered") t.Fatalf("sip.response.audio.create processor not registered")
} }
@@ -214,7 +214,7 @@ func TestBadSipResponseAudioCreate(t *testing.T) {
} }
func BenchmarkSipResponseAudioCreate(b *testing.B) { func BenchmarkSipResponseAudioCreate(b *testing.B) {
registration, ok := processor.ProcessorRegistry["sip.response.audio.create"] registration, ok := processor.GetProcessorRegistration("sip.response.audio.create")
if !ok { if !ok {
b.Fatalf("sip.response.audio.create processor not registered") b.Fatalf("sip.response.audio.create processor not registered")
} }
@@ -10,7 +10,7 @@ import (
) )
func TestSipResponseDTMFCreateFromRegistry(t *testing.T) { func TestSipResponseDTMFCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["sip.response.dtmf.create"] registration, ok := processor.GetProcessorRegistration("sip.response.dtmf.create")
if !ok { if !ok {
t.Fatalf("sip.response.dtmf.create processor not registered") t.Fatalf("sip.response.dtmf.create processor not registered")
} }
@@ -74,7 +74,7 @@ func TestGoodSipResponseDTMFCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["sip.response.dtmf.create"] registration, ok := processor.GetProcessorRegistration("sip.response.dtmf.create")
if !ok { if !ok {
t.Fatalf("sip.response.dtmf.create processor not registered") t.Fatalf("sip.response.dtmf.create processor not registered")
} }
@@ -191,7 +191,7 @@ func TestBadSipResponseDTMFCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["sip.response.dtmf.create"] registration, ok := processor.GetProcessorRegistration("sip.response.dtmf.create")
if !ok { if !ok {
t.Fatalf("sip.response.dtmf.create processor not registered") t.Fatalf("sip.response.dtmf.create processor not registered")
} }
@@ -222,7 +222,7 @@ func TestBadSipResponseDTMFCreate(t *testing.T) {
} }
func BenchmarkSipResponseDTMFCreate(b *testing.B) { func BenchmarkSipResponseDTMFCreate(b *testing.B) {
registration, ok := processor.ProcessorRegistry["sip.response.dtmf.create"] registration, ok := processor.GetProcessorRegistration("sip.response.dtmf.create")
if !ok { if !ok {
b.Fatalf("sip.response.dtmf.create processor not registered") b.Fatalf("sip.response.dtmf.create processor not registered")
} }
@@ -10,7 +10,7 @@ import (
) )
func TestStringCreateFromRegistry(t *testing.T) { func TestStringCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["string.create"] registration, ok := processor.GetProcessorRegistration("string.create")
if !ok { if !ok {
t.Fatalf("string.create processor not registered") t.Fatalf("string.create processor not registered")
} }
@@ -84,7 +84,7 @@ func TestGoodStringCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["string.create"] registration, ok := processor.GetProcessorRegistration("string.create")
if !ok { if !ok {
t.Fatalf("string.create processor not registered") t.Fatalf("string.create processor not registered")
} }
@@ -157,7 +157,7 @@ func TestBadStringCreate(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["string.create"] registration, ok := processor.GetProcessorRegistration("string.create")
if !ok { if !ok {
t.Fatalf("string.create processor not registered") t.Fatalf("string.create processor not registered")
} }
@@ -188,7 +188,7 @@ func TestBadStringCreate(t *testing.T) {
} }
func BenchmarkStringCreate(b *testing.B) { func BenchmarkStringCreate(b *testing.B) {
registration, ok := processor.ProcessorRegistry["string.create"] registration, ok := processor.GetProcessorRegistration("string.create")
if !ok { if !ok {
b.Fatalf("string.create processor not registered") b.Fatalf("string.create processor not registered")
} }
@@ -10,7 +10,7 @@ import (
) )
func TestStringDecodeFromRegistry(t *testing.T) { func TestStringDecodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["string.decode"] registration, ok := processor.GetProcessorRegistration("string.decode")
if !ok { if !ok {
t.Fatalf("string.decode processor not registered") t.Fatalf("string.decode processor not registered")
} }
@@ -101,7 +101,7 @@ func TestBadStringDecode(t *testing.T) {
} }
func BenchmarkStringDecode(b *testing.B) { func BenchmarkStringDecode(b *testing.B) {
registration, ok := processor.ProcessorRegistry["string.decode"] registration, ok := processor.GetProcessorRegistration("string.decode")
if !ok { if !ok {
b.Fatalf("string.decode processor not registered") b.Fatalf("string.decode processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestStringEncodeFromRegistry(t *testing.T) { func TestStringEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["string.encode"] registration, ok := processor.GetProcessorRegistration("string.encode")
if !ok { if !ok {
t.Fatalf("string.encode processor not registered") t.Fatalf("string.encode processor not registered")
} }
@@ -107,7 +107,7 @@ func TestBadStringEncode(t *testing.T) {
} }
func BenchmarkStringEncode(b *testing.B) { func BenchmarkStringEncode(b *testing.B) {
registration, ok := processor.ProcessorRegistry["string.encode"] registration, ok := processor.GetProcessorRegistration("string.encode")
if !ok { if !ok {
b.Fatalf("string.encode processor not registered") b.Fatalf("string.encode processor not registered")
} }
+4 -4
View File
@@ -11,7 +11,7 @@ import (
) )
func TestStringSplitFromRegistry(t *testing.T) { func TestStringSplitFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["string.split"] registration, ok := processor.GetProcessorRegistration("string.split")
if !ok { if !ok {
t.Fatalf("string.split processor not registered") t.Fatalf("string.split processor not registered")
} }
@@ -66,7 +66,7 @@ func TestGoodStringSplit(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["string.split"] registration, ok := processor.GetProcessorRegistration("string.split")
if !ok { if !ok {
t.Fatalf("string.split processor not registered") t.Fatalf("string.split processor not registered")
} }
@@ -126,7 +126,7 @@ func TestBadStringSplit(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["string.split"] registration, ok := processor.GetProcessorRegistration("string.split")
if !ok { if !ok {
t.Fatalf("string.split processor not registered") t.Fatalf("string.split processor not registered")
} }
@@ -156,7 +156,7 @@ func TestBadStringSplit(t *testing.T) {
} }
func BenchmarkStringSplit(b *testing.B) { func BenchmarkStringSplit(b *testing.B) {
registration, ok := processor.ProcessorRegistry["string.split"] registration, ok := processor.GetProcessorRegistration("string.split")
if !ok { if !ok {
b.Fatalf("string.split processor not registered") b.Fatalf("string.split processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestStructFieldGetFromRegistry(t *testing.T) { func TestStructFieldGetFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["struct.field.get"] registration, ok := processor.GetProcessorRegistration("struct.field.get")
if !ok { if !ok {
t.Fatalf("struct.field.get processor not registered") t.Fatalf("struct.field.get processor not registered")
} }
@@ -93,7 +93,7 @@ func TestGoodStructFieldGet(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["struct.field.get"] registration, ok := processor.GetProcessorRegistration("struct.field.get")
if !ok { if !ok {
t.Fatalf("struct.field.get processor not registered") t.Fatalf("struct.field.get processor not registered")
} }
@@ -162,7 +162,7 @@ func TestBadStructFieldGet(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["struct.field.get"] registration, ok := processor.GetProcessorRegistration("struct.field.get")
if !ok { if !ok {
t.Fatalf("struct.field.get processor not registered") t.Fatalf("struct.field.get processor not registered")
} }
@@ -193,7 +193,7 @@ func TestBadStructFieldGet(t *testing.T) {
} }
func BenchmarkStructFieldGet(b *testing.B) { func BenchmarkStructFieldGet(b *testing.B) {
registration, ok := processor.ProcessorRegistry["struct.field.get"] registration, ok := processor.GetProcessorRegistration("struct.field.get")
if !ok { if !ok {
b.Fatalf("struct.field.get processor not registered") b.Fatalf("struct.field.get processor not registered")
} }
@@ -11,7 +11,7 @@ import (
) )
func TestStructMethodGetFromRegistry(t *testing.T) { func TestStructMethodGetFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["struct.method.get"] registration, ok := processor.GetProcessorRegistration("struct.method.get")
if !ok { if !ok {
t.Fatalf("struct.method.get processor not registered") t.Fatalf("struct.method.get processor not registered")
} }
@@ -118,7 +118,7 @@ func TestGoodStructMethodGet(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["struct.method.get"] registration, ok := processor.GetProcessorRegistration("struct.method.get")
if !ok { if !ok {
t.Fatalf("struct.method.get processor not registered") t.Fatalf("struct.method.get processor not registered")
} }
@@ -187,7 +187,7 @@ func TestBadStructMethodGet(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["struct.method.get"] registration, ok := processor.GetProcessorRegistration("struct.method.get")
if !ok { if !ok {
t.Fatalf("struct.method.get processor not registered") t.Fatalf("struct.method.get processor not registered")
} }
@@ -218,7 +218,7 @@ func TestBadStructMethodGet(t *testing.T) {
} }
func BenchmarkStructMethodGet(b *testing.B) { func BenchmarkStructMethodGet(b *testing.B) {
registration, ok := processor.ProcessorRegistry["struct.method.get"] registration, ok := processor.GetProcessorRegistration("struct.method.get")
if !ok { if !ok {
b.Fatalf("struct.method.get processor not registered") b.Fatalf("struct.method.get processor not registered")
} }
+3 -3
View File
@@ -9,7 +9,7 @@ import (
) )
func TestTimeSleepFromRegistry(t *testing.T) { func TestTimeSleepFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["time.sleep"] registration, ok := processor.GetProcessorRegistration("time.sleep")
if !ok { if !ok {
t.Fatalf("time.sleep processor not registered") t.Fatalf("time.sleep processor not registered")
} }
@@ -45,7 +45,7 @@ func TestGoodTimeSleep(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["time.sleep"] registration, ok := processor.GetProcessorRegistration("time.sleep")
if !ok { if !ok {
t.Fatalf("time.sleep processor not registered") t.Fatalf("time.sleep processor not registered")
} }
@@ -97,7 +97,7 @@ func TestBadTimeSleep(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["time.sleep"] registration, ok := processor.GetProcessorRegistration("time.sleep")
if !ok { if !ok {
t.Fatalf("time.sleep processor not registered") t.Fatalf("time.sleep processor not registered")
} }
+1 -1
View File
@@ -19,7 +19,7 @@ func NewRoute(config config.RouteConfig) (*Route, error) {
if len(config.Processors) > 0 { if len(config.Processors) > 0 {
for _, processorDecl := range config.Processors { for _, processorDecl := range config.Processors {
processorInfo, ok := processor.ProcessorRegistry[processorDecl.Type] processorInfo, ok := processor.GetProcessorRegistration(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)
} }
+1 -1
View File
@@ -19,7 +19,7 @@ func GetModulesSchema() *jsonschema.Schema {
} }
moduleDefinitionSchemas := []*jsonschema.Schema{} moduleDefinitionSchemas := []*jsonschema.Schema{}
for _, mod := range module.ModuleRegistry { for _, mod := range module.GetModuleRegistrations() {
moduleSchema := &jsonschema.Schema{ moduleSchema := &jsonschema.Schema{
ID: mod.Type, ID: mod.Type,
Type: "object", Type: "object",
+1 -1
View File
@@ -19,7 +19,7 @@ func GetProcessorsSchema() *jsonschema.Schema {
} }
processorDefinitionSchemas := []*jsonschema.Schema{} processorDefinitionSchemas := []*jsonschema.Schema{}
for _, proc := range processor.ProcessorRegistry { for _, proc := range processor.GetProcessorRegistrations() {
processorSchema := &jsonschema.Schema{ processorSchema := &jsonschema.Schema{
ID: proc.Type, ID: proc.Type,
Type: "object", Type: "object",
+7 -7
View File
@@ -36,7 +36,7 @@ func (r *Router) addModule(moduleDecl config.ModuleConfig) error {
if moduleDecl.Id == "" { if moduleDecl.Id == "" {
return errors.New("module id cannot be empty") return errors.New("module id cannot be empty")
} }
moduleInfo, ok := module.ModuleRegistry[moduleDecl.Type] moduleRegistration, ok := module.GetModuleRegistration(moduleDecl.Type)
if !ok { if !ok {
return errors.New("module type not defined") return errors.New("module type not defined")
} }
@@ -46,7 +46,7 @@ func (r *Router) addModule(moduleDecl config.ModuleConfig) error {
return errors.New("module id already exists") return errors.New("module id already exists")
} }
moduleInstance, err := moduleInfo.New(moduleDecl) moduleInstance, err := moduleRegistration.New(moduleDecl)
if err != nil { if err != nil {
return err return err
} }
@@ -208,11 +208,11 @@ func (r *Router) HandleInput(ctx context.Context, sourceId string, payload any)
routeFound.Store(true) routeFound.Store(true)
_, err := routeInstance.ProcessPayload(ctx, common.WrappedPayload{ _, err := routeInstance.ProcessPayload(ctx, common.WrappedPayload{
Payload: payload, Payload: payload,
Source: sourceId, Source: sourceId,
Modules: r.ModuleInstances, Modules: r.ModuleInstances,
InputHandler: r.HandleInput, InputHandler: r.HandleInput,
End: false, End: false,
}) })
if err != nil { if err != nil {
if routeIOErrors == nil { if routeIOErrors == nil {