diff --git a/internal/framer/framer.go b/internal/framer/framer.go index 39b9453..5e38eb9 100644 --- a/internal/framer/framer.go +++ b/internal/framer/framer.go @@ -10,15 +10,15 @@ type Framer interface { func GetFramer(framingType string) Framer { switch framingType { case "CR": - return NewByteSeparatorFramer([]byte{'\r'}) + return newByteSeparatorFramer([]byte{'\r'}) case "LF": - return NewByteSeparatorFramer([]byte{'\n'}) + return newByteSeparatorFramer([]byte{'\n'}) case "CRLF": - return NewByteSeparatorFramer([]byte{'\r', '\n'}) + return newByteSeparatorFramer([]byte{'\r', '\n'}) case "SLIP": - return NewSlipFramer() + return newSlipFramer() case "RAW": - return NewRawFramer() + return newRawFramer() default: return nil } diff --git a/internal/framer/raw.go b/internal/framer/raw.go index 6c42974..cfa57a5 100644 --- a/internal/framer/raw.go +++ b/internal/framer/raw.go @@ -1,23 +1,23 @@ package framer -type RawFramer struct{} +type rawFramer struct{} -func NewRawFramer() *RawFramer { - return &RawFramer{} +func newRawFramer() *rawFramer { + return &rawFramer{} } -func (rf *RawFramer) Decode(data []byte) [][]byte { +func (rf *rawFramer) Decode(data []byte) [][]byte { return [][]byte{data} } -func (rf *RawFramer) Encode(data []byte) []byte { +func (rf *rawFramer) Encode(data []byte) []byte { return data } -func (rf *RawFramer) Clear() { +func (rf *rawFramer) Clear() { // NOTE(jwetzell): no internal state to clear } -func (rf *RawFramer) Buffer() []byte { +func (rf *rawFramer) Buffer() []byte { return []byte{} } diff --git a/internal/framer/separator.go b/internal/framer/separator.go index fb5f9b7..85c0741 100644 --- a/internal/framer/separator.go +++ b/internal/framer/separator.go @@ -4,16 +4,16 @@ import ( "bytes" ) -type ByteSeparatorFramer struct { +type byteSeparatorFramer struct { buffer []byte separator []byte } -func NewByteSeparatorFramer(separator []byte) *ByteSeparatorFramer { - return &ByteSeparatorFramer{separator: separator, buffer: []byte{}} +func newByteSeparatorFramer(separator []byte) *byteSeparatorFramer { + return &byteSeparatorFramer{separator: separator, buffer: []byte{}} } -func (bsf *ByteSeparatorFramer) Decode(data []byte) [][]byte { +func (bsf *byteSeparatorFramer) Decode(data []byte) [][]byte { messages := [][]byte{} bsf.buffer = append(bsf.buffer, data...) @@ -28,14 +28,14 @@ func (bsf *ByteSeparatorFramer) Decode(data []byte) [][]byte { return messages } -func (bsf *ByteSeparatorFramer) Encode(data []byte) []byte { +func (bsf *byteSeparatorFramer) Encode(data []byte) []byte { return append(data, bsf.separator...) } -func (bsf *ByteSeparatorFramer) Clear() { +func (bsf *byteSeparatorFramer) Clear() { bsf.buffer = []byte{} } -func (bsf *ByteSeparatorFramer) Buffer() []byte { +func (bsf *byteSeparatorFramer) Buffer() []byte { return bsf.buffer } diff --git a/internal/framer/slip.go b/internal/framer/slip.go index fecf12c..76ee6b5 100644 --- a/internal/framer/slip.go +++ b/internal/framer/slip.go @@ -1,14 +1,14 @@ package framer -type SlipFramer struct { +type slipFramer struct { buffer []byte } -func NewSlipFramer() *SlipFramer { - return &SlipFramer{buffer: []byte{}} +func newSlipFramer() *slipFramer { + return &slipFramer{buffer: []byte{}} } -func (sf *SlipFramer) Decode(data []byte) [][]byte { +func (sf *slipFramer) Decode(data []byte) [][]byte { messages := [][]byte{} END := byte(0xc0) @@ -49,7 +49,7 @@ func (sf *SlipFramer) Decode(data []byte) [][]byte { return messages } -func (sf *SlipFramer) Encode(data []byte) []byte { +func (sf *slipFramer) Encode(data []byte) []byte { END := byte(0xc0) ESC := byte(0xdb) ESC_END := byte(0xdc) @@ -72,10 +72,10 @@ func (sf *SlipFramer) Encode(data []byte) []byte { return encodedBytes } -func (sf *SlipFramer) Clear() { +func (sf *slipFramer) Clear() { sf.buffer = []byte{} } -func (sf *SlipFramer) Buffer() []byte { +func (sf *slipFramer) Buffer() []byte { return sf.buffer } diff --git a/internal/module/module.go b/internal/module/module.go index 6c2d00c..35c2761 100644 --- a/internal/module/module.go +++ b/internal/module/module.go @@ -30,15 +30,36 @@ func RegisterModule(mod ModuleRegistration) { moduleRegistryMu.Lock() 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)) } - 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 ( moduleRegistryMu sync.RWMutex - ModuleRegistry = make(map[string]ModuleRegistration) + moduleRegistry = make(ModuleRegistry) ) func CreateLogger(config config.ModuleConfig) *slog.Logger { diff --git a/internal/module/test/db-sqlite_test.go b/internal/module/test/db-sqlite_test.go index 5a2453d..b15f0e6 100644 --- a/internal/module/test/db-sqlite_test.go +++ b/internal/module/test/db-sqlite_test.go @@ -9,7 +9,7 @@ import ( ) func TestDbSqliteFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["db.sqlite"] + registration, ok := module.GetModuleRegistration("db.sqlite") if !ok { t.Fatalf("db.sqlite module not registered") } @@ -58,7 +58,7 @@ func TestGoodDbSqlite(t *testing.T) { for _, test := range testCases { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["db.sqlite"] + registration, ok := module.GetModuleRegistration("db.sqlite") if !ok { t.Fatalf("db.sqlite module not registered") } @@ -107,7 +107,7 @@ func TestBadDbSqlite(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["db.sqlite"] + registration, ok := module.GetModuleRegistration("db.sqlite") if !ok { t.Fatalf("db.sqlite module not registered") } diff --git a/internal/module/test/http-server_test.go b/internal/module/test/http-server_test.go index 4ac9871..48b2020 100644 --- a/internal/module/test/http-server_test.go +++ b/internal/module/test/http-server_test.go @@ -9,7 +9,7 @@ import ( ) func TestHTTPServerFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["http.server"] + registration, ok := module.GetModuleRegistration("http.server") if !ok { t.Fatalf("http.server module not registered") } @@ -52,7 +52,7 @@ func TestGoodHTTPServer(t *testing.T) { for _, test := range testCases { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["http.server"] + registration, ok := module.GetModuleRegistration("http.server") if !ok { t.Fatalf("http.server module not registered") } @@ -102,7 +102,7 @@ func TestBadHTTPServer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["http.server"] + registration, ok := module.GetModuleRegistration("http.server") if !ok { t.Fatalf("http.server module not registered") } diff --git a/internal/module/test/midi-input_test.go b/internal/module/test/midi-input_test.go index 69f2c43..9c2c876 100644 --- a/internal/module/test/midi-input_test.go +++ b/internal/module/test/midi-input_test.go @@ -8,7 +8,7 @@ import ( ) func TestMIDIInputFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["midi.input"] + registration, ok := module.GetModuleRegistration("midi.input") if !ok { t.Fatalf("midi.input module not registered") } @@ -55,7 +55,7 @@ func TestBadMIDIInput(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["midi.input"] + registration, ok := module.GetModuleRegistration("midi.input") if !ok { t.Fatalf("midi.input module not registered") } diff --git a/internal/module/test/midi-output_test.go b/internal/module/test/midi-output_test.go index 17a1d4e..088921c 100644 --- a/internal/module/test/midi-output_test.go +++ b/internal/module/test/midi-output_test.go @@ -8,7 +8,7 @@ import ( ) func TestMIDIOutputFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["midi.output"] + registration, ok := module.GetModuleRegistration("midi.output") if !ok { t.Fatalf("midi.output module not registered") } @@ -55,7 +55,7 @@ func TestBadMIDIOutput(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["midi.output"] + registration, ok := module.GetModuleRegistration("midi.output") if !ok { t.Fatalf("midi.output module not registered") } diff --git a/internal/module/test/mqtt-client_test.go b/internal/module/test/mqtt-client_test.go index 2d83a83..6c3e285 100644 --- a/internal/module/test/mqtt-client_test.go +++ b/internal/module/test/mqtt-client_test.go @@ -8,7 +8,7 @@ import ( ) func TestMQTTClientFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["mqtt.client"] + registration, ok := module.GetModuleRegistration("mqtt.client") if !ok { t.Fatalf("mqtt.client module not registered") } @@ -98,7 +98,7 @@ func TestBadMQTTClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["mqtt.client"] + registration, ok := module.GetModuleRegistration("mqtt.client") if !ok { t.Fatalf("mqtt.client module not registered") } diff --git a/internal/module/test/nats-client_test.go b/internal/module/test/nats-client_test.go index 04c004d..9344b00 100644 --- a/internal/module/test/nats-client_test.go +++ b/internal/module/test/nats-client_test.go @@ -8,7 +8,7 @@ import ( ) func TestNATSClientFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["nats.client"] + registration, ok := module.GetModuleRegistration("nats.client") if !ok { t.Fatalf("nats.client module not registered") } @@ -76,7 +76,7 @@ func TestBadNATSClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["nats.client"] + registration, ok := module.GetModuleRegistration("nats.client") if !ok { t.Fatalf("nats.client module not registered") } diff --git a/internal/module/test/nats-server_test.go b/internal/module/test/nats-server_test.go index 6c9ef9d..b5dae86 100644 --- a/internal/module/test/nats-server_test.go +++ b/internal/module/test/nats-server_test.go @@ -9,7 +9,7 @@ import ( ) func TestNATSServerFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["nats.server"] + registration, ok := module.GetModuleRegistration("nats.server") if !ok { t.Fatalf("nats.server module not registered") } @@ -53,7 +53,7 @@ func TestGoodNATSServer(t *testing.T) { for _, test := range testCases { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["nats.server"] + registration, ok := module.GetModuleRegistration("nats.server") if !ok { t.Fatalf("nats.server module not registered") } @@ -100,7 +100,7 @@ func TestBadNATSServer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["nats.server"] + registration, ok := module.GetModuleRegistration("nats.server") if !ok { t.Fatalf("nats.server module not registered") } diff --git a/internal/module/test/psn-client_test.go b/internal/module/test/psn-client_test.go index 6ad74a1..3d87adc 100644 --- a/internal/module/test/psn-client_test.go +++ b/internal/module/test/psn-client_test.go @@ -8,7 +8,7 @@ import ( ) func TestPSNClientFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["psn.client"] + registration, ok := module.GetModuleRegistration("psn.client") if !ok { t.Fatalf("psn.client module not registered") } @@ -41,7 +41,7 @@ func TestBadPSNClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["psn.client"] + registration, ok := module.GetModuleRegistration("psn.client") if !ok { t.Fatalf("psn.client module not registered") } diff --git a/internal/module/test/redis-client_test.go b/internal/module/test/redis-client_test.go index 040454c..277a5aa 100644 --- a/internal/module/test/redis-client_test.go +++ b/internal/module/test/redis-client_test.go @@ -8,7 +8,7 @@ import ( ) func TestRedisClientFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["redis.client"] + registration, ok := module.GetModuleRegistration("redis.client") if !ok { t.Fatalf("redis.client module not registered") } @@ -76,7 +76,7 @@ func TestBadRedisClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["redis.client"] + registration, ok := module.GetModuleRegistration("redis.client") if !ok { t.Fatalf("redis.client module not registered") } diff --git a/internal/module/test/serial-client_test.go b/internal/module/test/serial-client_test.go index 8c7627e..3d542d2 100644 --- a/internal/module/test/serial-client_test.go +++ b/internal/module/test/serial-client_test.go @@ -8,7 +8,7 @@ import ( ) func TestSerialClientFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["serial.client"] + registration, ok := module.GetModuleRegistration("serial.client") if !ok { t.Fatalf("serial.client module not registered") } @@ -85,7 +85,7 @@ func TestBadSerialClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["serial.client"] + registration, ok := module.GetModuleRegistration("serial.client") if !ok { t.Fatalf("serial.client module not registered") } diff --git a/internal/module/test/sip-call-server_test.go b/internal/module/test/sip-call-server_test.go index bbb8fa0..4c94c47 100644 --- a/internal/module/test/sip-call-server_test.go +++ b/internal/module/test/sip-call-server_test.go @@ -8,7 +8,7 @@ import ( ) func TestSIPCallServerFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["sip.call.server"] + registration, ok := module.GetModuleRegistration("sip.call.server") if !ok { t.Fatalf("sip.call.server module not registered") } @@ -70,7 +70,7 @@ func TestBadSIPCallServer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["sip.call.server"] + registration, ok := module.GetModuleRegistration("sip.call.server") if !ok { t.Fatalf("sip.call.server module not registered") } diff --git a/internal/module/test/sip-dtmf-server_test.go b/internal/module/test/sip-dtmf-server_test.go index 0b328c3..fcbdcb9 100644 --- a/internal/module/test/sip-dtmf-server_test.go +++ b/internal/module/test/sip-dtmf-server_test.go @@ -8,7 +8,7 @@ import ( ) func TestSIPDTMFServerFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["sip.dtmf.server"] + registration, ok := module.GetModuleRegistration("sip.dtmf.server") if !ok { t.Fatalf("sip.dtmf.server module not registered") } @@ -89,7 +89,7 @@ func TestBadSIPDTMFServer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["sip.dtmf.server"] + registration, ok := module.GetModuleRegistration("sip.dtmf.server") if !ok { t.Fatalf("sip.dtmf.server module not registered") } diff --git a/internal/module/test/tcp-client_test.go b/internal/module/test/tcp-client_test.go index 56a0d86..a7d3d50 100644 --- a/internal/module/test/tcp-client_test.go +++ b/internal/module/test/tcp-client_test.go @@ -8,7 +8,7 @@ import ( ) func TestTCPClientFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["net.tcp.client"] + registration, ok := module.GetModuleRegistration("net.tcp.client") if !ok { t.Fatalf("net.tcp.client module not registered") } @@ -77,7 +77,7 @@ func TestBadTCPClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["net.tcp.client"] + registration, ok := module.GetModuleRegistration("net.tcp.client") if !ok { t.Fatalf("net.tcp.client module not registered") } diff --git a/internal/module/test/tcp-server_test.go b/internal/module/test/tcp-server_test.go index e82f15f..cf1c1cb 100644 --- a/internal/module/test/tcp-server_test.go +++ b/internal/module/test/tcp-server_test.go @@ -9,7 +9,7 @@ import ( ) func TestTCPServerFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["net.tcp.server"] + registration, ok := module.GetModuleRegistration("net.tcp.server") if !ok { t.Fatalf("net.tcp.server module not registered") } @@ -54,7 +54,7 @@ func TestGoodTCPServer(t *testing.T) { for _, test := range testCases { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["net.tcp.server"] + registration, ok := module.GetModuleRegistration("net.tcp.server") if !ok { t.Fatalf("net.tcp.server module not registered") } @@ -149,7 +149,7 @@ func TestBadTCPServer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["net.tcp.server"] + registration, ok := module.GetModuleRegistration("net.tcp.server") if !ok { t.Fatalf("net.tcp.server module not registered") } diff --git a/internal/module/test/time-interval_test.go b/internal/module/test/time-interval_test.go index 794df1b..4366094 100644 --- a/internal/module/test/time-interval_test.go +++ b/internal/module/test/time-interval_test.go @@ -9,7 +9,7 @@ import ( ) func TestTimeIntervalFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["time.interval"] + registration, ok := module.GetModuleRegistration("time.interval") if !ok { t.Fatalf("time.interval module not registered") } @@ -52,7 +52,7 @@ func TestGoodTimeInterval(t *testing.T) { for _, test := range testCases { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["time.interval"] + registration, ok := module.GetModuleRegistration("time.interval") if !ok { t.Fatalf("time.interval module not registered") } @@ -103,7 +103,7 @@ func TestBadTimeInterval(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["time.interval"] + registration, ok := module.GetModuleRegistration("time.interval") if !ok { t.Fatalf("time.interval module not registered") } diff --git a/internal/module/test/time-timer_test.go b/internal/module/test/time-timer_test.go index b09674f..0536a79 100644 --- a/internal/module/test/time-timer_test.go +++ b/internal/module/test/time-timer_test.go @@ -9,7 +9,7 @@ import ( ) func TestTimeTimerFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["time.timer"] + registration, ok := module.GetModuleRegistration("time.timer") if !ok { t.Fatalf("time.timer module not registered") } @@ -52,7 +52,7 @@ func TestGoodTimeTimer(t *testing.T) { for _, test := range testCases { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["time.timer"] + registration, ok := module.GetModuleRegistration("time.timer") if !ok { t.Fatalf("time.timer module not registered") } @@ -103,7 +103,7 @@ func TestBadTimeTimer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["time.timer"] + registration, ok := module.GetModuleRegistration("time.timer") if !ok { t.Fatalf("time.timer module not registered") } diff --git a/internal/module/test/udp-client_test.go b/internal/module/test/udp-client_test.go index fb3035a..5cbebe4 100644 --- a/internal/module/test/udp-client_test.go +++ b/internal/module/test/udp-client_test.go @@ -9,7 +9,7 @@ import ( ) func TestUDPClientFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["net.udp.client"] + registration, ok := module.GetModuleRegistration("net.udp.client") if !ok { t.Fatalf("udp.client module not registered") } @@ -55,7 +55,7 @@ func TestGoodUDPClient(t *testing.T) { for _, test := range testCases { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["net.udp.client"] + registration, ok := module.GetModuleRegistration("net.udp.client") if !ok { t.Fatalf("net.udp.client module not registered") } @@ -125,7 +125,7 @@ func TestBadUDPClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["net.udp.client"] + registration, ok := module.GetModuleRegistration("net.udp.client") if !ok { t.Fatalf("net.udp.client module not registered") } diff --git a/internal/module/test/udp-multicast_test.go b/internal/module/test/udp-multicast_test.go index 9699e52..05ccb27 100644 --- a/internal/module/test/udp-multicast_test.go +++ b/internal/module/test/udp-multicast_test.go @@ -8,7 +8,7 @@ import ( ) func TestUDPMulticastFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["net.udp.multicast"] + registration, ok := module.GetModuleRegistration("net.udp.multicast") if !ok { t.Fatalf("udp.multicast module not registered") } @@ -84,7 +84,7 @@ func TestBadUDPMulticast(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["net.udp.multicast"] + registration, ok := module.GetModuleRegistration("net.udp.multicast") if !ok { t.Fatalf("net.udp.multicast module not registered") } diff --git a/internal/module/test/udp-server_test.go b/internal/module/test/udp-server_test.go index 127a0e1..aa2bfef 100644 --- a/internal/module/test/udp-server_test.go +++ b/internal/module/test/udp-server_test.go @@ -9,7 +9,7 @@ import ( ) func TestUDPServerFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["net.udp.server"] + registration, ok := module.GetModuleRegistration("net.udp.server") if !ok { t.Fatalf("net.udp.server module not registered") } @@ -52,7 +52,7 @@ func TestGoodUDPServer(t *testing.T) { for _, test := range testCases { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["net.udp.server"] + registration, ok := module.GetModuleRegistration("net.udp.server") if !ok { t.Fatalf("net.udp.server module not registered") } @@ -128,7 +128,7 @@ func TestBadUDPServer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["net.udp.server"] + registration, ok := module.GetModuleRegistration("net.udp.server") if !ok { t.Fatalf("net.udp.server module not registered") } diff --git a/internal/module/test/websocket-client_test.go b/internal/module/test/websocket-client_test.go index ff0dce2..d7a1d18 100644 --- a/internal/module/test/websocket-client_test.go +++ b/internal/module/test/websocket-client_test.go @@ -8,7 +8,7 @@ import ( ) func TestWebSocketClientFromRegistry(t *testing.T) { - registration, ok := module.ModuleRegistry["websocket.client"] + registration, ok := module.GetModuleRegistration("websocket.client") if !ok { t.Fatalf("websocket.client module not registered") } @@ -64,7 +64,7 @@ func TestBadWebSocketClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := module.ModuleRegistry["websocket.client"] + registration, ok := module.GetModuleRegistration("websocket.client") if !ok { t.Fatalf("websocket.client module not registered") } diff --git a/internal/processor/processor.go b/internal/processor/processor.go index 7c8e0fd..73d7ca0 100644 --- a/internal/processor/processor.go +++ b/internal/processor/processor.go @@ -35,13 +35,33 @@ func RegisterProcessor(processor ProcessorRegistration) { processorRegistryMu.Lock() 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)) } - 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 ( processorRegistryMu sync.RWMutex - ProcessorRegistry = make(map[string]ProcessorRegistration) + processorRegistry = make(map[string]ProcessorRegistration) ) diff --git a/internal/processor/test/artnet-packet-decode_test.go b/internal/processor/test/artnet-packet-decode_test.go index c89b4f7..a381f8a 100644 --- a/internal/processor/test/artnet-packet-decode_test.go +++ b/internal/processor/test/artnet-packet-decode_test.go @@ -11,7 +11,7 @@ import ( ) func TestArtnetPacketDecodeFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["artnet.packet.decode"] + registration, ok := processor.GetProcessorRegistration("artnet.packet.decode") if !ok { t.Fatalf("artnet.packet.decode processor not registered") } diff --git a/internal/processor/test/artnet-packet-encode_test.go b/internal/processor/test/artnet-packet-encode_test.go index 5795e04..9b154b6 100644 --- a/internal/processor/test/artnet-packet-encode_test.go +++ b/internal/processor/test/artnet-packet-encode_test.go @@ -11,7 +11,7 @@ import ( ) func TestArtnetPacketEncodeFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["artnet.packet.encode"] + registration, ok := processor.GetProcessorRegistration("artnet.packet.encode") if !ok { t.Fatalf("artnet.packet.encode processor not registered") } diff --git a/internal/processor/test/db-query_test.go b/internal/processor/test/db-query_test.go index 9aa2fc4..3b73cd0 100644 --- a/internal/processor/test/db-query_test.go +++ b/internal/processor/test/db-query_test.go @@ -12,7 +12,7 @@ import ( ) func TestDbQueryFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["db.query"] + registration, ok := processor.GetProcessorRegistration("db.query") if !ok { t.Fatalf("db.query processor not registered") } @@ -100,7 +100,7 @@ func TestGoodDbQuery(t *testing.T) { } for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["db.query"] + registration, ok := processor.GetProcessorRegistration("db.query") if !ok { 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", }, { - name: "module not a DatabseModule", + name: "module not a DatabaseModule", payload: test.TestStruct{Data: "hello"}, params: map[string]any{ "module": "test", @@ -259,7 +259,7 @@ func TestBadDbQuery(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["db.query"] + registration, ok := processor.GetProcessorRegistration("db.query") if !ok { t.Fatalf("db.query processor not registered") } @@ -293,7 +293,7 @@ func TestBadDbQuery(t *testing.T) { } func BenchmarkDbQuery(b *testing.B) { - registration, ok := processor.ProcessorRegistry["db.query"] + registration, ok := processor.GetProcessorRegistration("db.query") if !ok { b.Fatalf("db.query processor not registered") } diff --git a/internal/processor/test/debug-log_test.go b/internal/processor/test/debug-log_test.go index 04718e7..eb7a81d 100644 --- a/internal/processor/test/debug-log_test.go +++ b/internal/processor/test/debug-log_test.go @@ -10,7 +10,7 @@ import ( ) func TestDebugLogFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["debug.log"] + registration, ok := processor.GetProcessorRegistration("debug.log") if !ok { t.Fatalf("debug.log processor not registered") } @@ -52,7 +52,7 @@ func TestGoodDebugLog(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["debug.log"] + registration, ok := processor.GetProcessorRegistration("debug.log") if !ok { t.Fatalf("debug.log processor not registered") } @@ -89,7 +89,7 @@ func TestBadDebugLog(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["debug.log"] + registration, ok := processor.GetProcessorRegistration("debug.log") if !ok { t.Fatalf("debug.log processor not registered") } @@ -120,7 +120,7 @@ func TestBadDebugLog(t *testing.T) { } func BenchmarkDebugLog(b *testing.B) { - registration, ok := processor.ProcessorRegistry["debug.log"] + registration, ok := processor.GetProcessorRegistration("debug.log") if !ok { b.Fatalf("debug.log processor not registered") } diff --git a/internal/processor/test/filter-change_test.go b/internal/processor/test/filter-change_test.go index 5045a5d..98573fb 100644 --- a/internal/processor/test/filter-change_test.go +++ b/internal/processor/test/filter-change_test.go @@ -10,7 +10,7 @@ import ( ) func TestFilterChangeFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["filter.change"] + registration, ok := processor.GetProcessorRegistration("filter.change") if !ok { t.Fatalf("filter.change processor not registered") } @@ -58,7 +58,7 @@ func TestGoodFilterChange(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["filter.change"] + registration, ok := processor.GetProcessorRegistration("filter.change") if !ok { t.Fatalf("filter.change processor not registered") } @@ -95,7 +95,7 @@ func TestBadFilterChange(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["filter.change"] + registration, ok := processor.GetProcessorRegistration("filter.change") if !ok { t.Fatalf("filter.change processor not registered") } @@ -126,7 +126,7 @@ func TestBadFilterChange(t *testing.T) { } func BenchmarkFilterChange(b *testing.B) { - registration, ok := processor.ProcessorRegistry["filter.change"] + registration, ok := processor.GetProcessorRegistration("filter.change") if !ok { b.Fatalf("filter.change processor not registered") } diff --git a/internal/processor/test/filter-expr_test.go b/internal/processor/test/filter-expr_test.go index 89b0cd4..64e7737 100644 --- a/internal/processor/test/filter-expr_test.go +++ b/internal/processor/test/filter-expr_test.go @@ -10,7 +10,7 @@ import ( ) func TestFilterExprFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["filter.expr"] + registration, ok := processor.GetProcessorRegistration("filter.expr") if !ok { t.Fatalf("filter.expr processor not registered") } @@ -71,7 +71,7 @@ func TestGoodFilterExpr(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["filter.expr"] + registration, ok := processor.GetProcessorRegistration("filter.expr") if !ok { t.Fatalf("filter.expr processor not registered") } @@ -144,7 +144,7 @@ func TestBadFilterExpr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["filter.expr"] + registration, ok := processor.GetProcessorRegistration("filter.expr") if !ok { t.Fatalf("filter.expr processor not registered") } @@ -173,7 +173,7 @@ func TestBadFilterExpr(t *testing.T) { } func BenchmarkFilterExpr(b *testing.B) { - registration, ok := processor.ProcessorRegistry["filter.expr"] + registration, ok := processor.GetProcessorRegistration("filter.expr") if !ok { b.Fatalf("filter.expr processor not registered") } diff --git a/internal/processor/test/filter-rate_test.go b/internal/processor/test/filter-rate_test.go index 0e28fd0..63585a8 100644 --- a/internal/processor/test/filter-rate_test.go +++ b/internal/processor/test/filter-rate_test.go @@ -10,7 +10,7 @@ import ( ) func TestFilterRateFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["filter.rate"] + registration, ok := processor.GetProcessorRegistration("filter.rate") if !ok { t.Fatalf("filter.rate processor not registered") } @@ -40,7 +40,7 @@ func TestGoodFilterRate(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["filter.rate"] + registration, ok := processor.GetProcessorRegistration("filter.rate") if !ok { t.Fatalf("filter.rate processor not registered") } @@ -87,7 +87,7 @@ func TestBadFilterRate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["filter.rate"] + registration, ok := processor.GetProcessorRegistration("filter.rate") if !ok { t.Fatalf("filter.rate processor not registered") } diff --git a/internal/processor/test/filter-regex_test.go b/internal/processor/test/filter-regex_test.go index 1e99f54..e026576 100644 --- a/internal/processor/test/filter-regex_test.go +++ b/internal/processor/test/filter-regex_test.go @@ -10,7 +10,7 @@ import ( ) func TestFilterRegexFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["filter.regex"] + registration, ok := processor.GetProcessorRegistration("filter.regex") if !ok { t.Fatalf("filter.regex processor not registered") } @@ -77,7 +77,7 @@ func TestGoodFilterRegex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["filter.regex"] + registration, ok := processor.GetProcessorRegistration("filter.regex") if !ok { t.Fatalf("filter.regex processor not registered") } @@ -145,7 +145,7 @@ func TestBadFilterRegex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["filter.regex"] + registration, ok := processor.GetProcessorRegistration("filter.regex") if !ok { t.Fatalf("filter.regex processor not registered") } @@ -176,7 +176,7 @@ func TestBadFilterRegex(t *testing.T) { } func BenchmarkFilterRegex(b *testing.B) { - registration, ok := processor.ProcessorRegistry["filter.regex"] + registration, ok := processor.GetProcessorRegistration("filter.regex") if !ok { b.Fatalf("filter.regex processor not registered") } diff --git a/internal/processor/test/float-parse_test.go b/internal/processor/test/float-parse_test.go index 6057b62..4fcc53d 100644 --- a/internal/processor/test/float-parse_test.go +++ b/internal/processor/test/float-parse_test.go @@ -10,7 +10,7 @@ import ( ) func TestFloatParseFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["float.parse"] + registration, ok := processor.GetProcessorRegistration("float.parse") if !ok { t.Fatalf("float.parse processor not registered") } @@ -63,7 +63,7 @@ func TestGoodFloatParse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["float.parse"] + registration, ok := processor.GetProcessorRegistration("float.parse") if !ok { t.Fatalf("float.parse processor not registered") } @@ -136,7 +136,7 @@ func TestBadFloatParse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["float.parse"] + registration, ok := processor.GetProcessorRegistration("float.parse") if !ok { t.Fatalf("float.parse processor not registered") } @@ -167,7 +167,7 @@ func TestBadFloatParse(t *testing.T) { } func BenchmarkFloatParse(b *testing.B) { - registration, ok := processor.ProcessorRegistry["float.parse"] + registration, ok := processor.GetProcessorRegistration("float.parse") if !ok { b.Fatalf("float.parse processor not registered") } diff --git a/internal/processor/test/float-random_test.go b/internal/processor/test/float-random_test.go index 874f102..b3faec5 100644 --- a/internal/processor/test/float-random_test.go +++ b/internal/processor/test/float-random_test.go @@ -9,7 +9,7 @@ import ( ) func TestFloatRandomFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["float.random"] + registration, ok := processor.GetProcessorRegistration("float.random") if !ok { t.Fatalf("float.random processor not registered") } @@ -57,7 +57,7 @@ func TestGoodFloatRandom(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["float.random"] + registration, ok := processor.GetProcessorRegistration("float.random") if !ok { t.Fatalf("float.random processor not registered") } @@ -155,7 +155,7 @@ func TestBadFloatRandom(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["float.random"] + registration, ok := processor.GetProcessorRegistration("float.random") if !ok { t.Fatalf("float.random processor not registered") } @@ -186,7 +186,7 @@ func TestBadFloatRandom(t *testing.T) { } func BenchmarkFloatRandom(b *testing.B) { - registration, ok := processor.ProcessorRegistry["float.random"] + registration, ok := processor.GetProcessorRegistration("float.random") if !ok { b.Fatalf("float.random processor not registered") } diff --git a/internal/processor/test/free-d-create_test.go b/internal/processor/test/free-d-create_test.go index 9391a46..09b1a58 100644 --- a/internal/processor/test/free-d-create_test.go +++ b/internal/processor/test/free-d-create_test.go @@ -11,7 +11,7 @@ import ( ) func TestFreeDCreateFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["freed.create"] + registration, ok := processor.GetProcessorRegistration("freed.create") if !ok { t.Fatalf("freed.create processor not registered") } @@ -89,7 +89,7 @@ func TestGoodFreeDCreate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["freed.create"] + registration, ok := processor.GetProcessorRegistration("freed.create") if !ok { t.Fatalf("freed.create processor not registered") } @@ -848,7 +848,7 @@ func TestBadFreeDCreate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["freed.create"] + registration, ok := processor.GetProcessorRegistration("freed.create") if !ok { t.Fatalf("freed.create processor not registered") } @@ -879,7 +879,7 @@ func TestBadFreeDCreate(t *testing.T) { } func BenchmarkFreeDCreate(b *testing.B) { - registration, ok := processor.ProcessorRegistry["freed.create"] + registration, ok := processor.GetProcessorRegistration("freed.create") if !ok { b.Fatalf("freed.create processor not registered") } diff --git a/internal/processor/test/free-d-decode_test.go b/internal/processor/test/free-d-decode_test.go index e9e6797..6144e0b 100644 --- a/internal/processor/test/free-d-decode_test.go +++ b/internal/processor/test/free-d-decode_test.go @@ -11,7 +11,7 @@ import ( ) func TestFreeDDecodeFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["freed.decode"] + registration, ok := processor.GetProcessorRegistration("freed.decode") if !ok { t.Fatalf("freed.decode processor not registered") } diff --git a/internal/processor/test/free-d-encode_test.go b/internal/processor/test/free-d-encode_test.go index 7c861c5..b3c09c0 100644 --- a/internal/processor/test/free-d-encode_test.go +++ b/internal/processor/test/free-d-encode_test.go @@ -11,7 +11,7 @@ import ( ) func TestFreeDEncodeFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["freed.encode"] + registration, ok := processor.GetProcessorRegistration("freed.encode") if !ok { t.Fatalf("freed.encode processor not registered") } diff --git a/internal/processor/test/http-request-do_test.go b/internal/processor/test/http-request-do_test.go index c56b732..e509fa0 100644 --- a/internal/processor/test/http-request-do_test.go +++ b/internal/processor/test/http-request-do_test.go @@ -10,7 +10,7 @@ import ( ) func TestHTTPRequestCreateFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["http.request.do"] + registration, ok := processor.GetProcessorRegistration("http.request.do") if !ok { t.Fatalf("http.request.do processor not registered") } @@ -44,7 +44,7 @@ func TestGoodHTTPRequestDo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["http.request.do"] + registration, ok := processor.GetProcessorRegistration("http.request.do") if !ok { t.Fatalf("http.request.do processor not registered") } @@ -132,7 +132,7 @@ func TestBadHTTPRequestDo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["http.request.do"] + registration, ok := processor.GetProcessorRegistration("http.request.do") if !ok { t.Fatalf("http.request.do processor not registered") } diff --git a/internal/processor/test/http-response-create_test.go b/internal/processor/test/http-response-create_test.go index d7e69d6..157fd89 100644 --- a/internal/processor/test/http-response-create_test.go +++ b/internal/processor/test/http-response-create_test.go @@ -10,7 +10,7 @@ import ( ) func TestHTTPResponseCreateFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["http.response.create"] + registration, ok := processor.GetProcessorRegistration("http.response.create") if !ok { t.Fatalf("http.response.create processor not registered") } @@ -54,7 +54,7 @@ func TestGoodHTTPResponseCreate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["http.response.create"] + registration, ok := processor.GetProcessorRegistration("http.response.create") if !ok { t.Fatalf("http.response.create processor not registered") } @@ -128,7 +128,7 @@ func TestBadHTTPResponseCreate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["http.response.create"] + registration, ok := processor.GetProcessorRegistration("http.response.create") if !ok { t.Fatalf("http.response.create processor not registered") } @@ -159,7 +159,7 @@ func TestBadHTTPResponseCreate(t *testing.T) { } func BenchmarkHTTPResponseCreate(b *testing.B) { - registration, ok := processor.ProcessorRegistry["http.response.create"] + registration, ok := processor.GetProcessorRegistration("http.response.create") if !ok { b.Fatalf("http.response.create processor not registered") } diff --git a/internal/processor/test/int-parse_test.go b/internal/processor/test/int-parse_test.go index 8304564..9b64f54 100644 --- a/internal/processor/test/int-parse_test.go +++ b/internal/processor/test/int-parse_test.go @@ -10,7 +10,7 @@ import ( ) func TestIntParseFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["int.parse"] + registration, ok := processor.GetProcessorRegistration("int.parse") if !ok { t.Fatalf("int.parse processor not registered") } @@ -84,7 +84,7 @@ func TestGoodIntParse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["int.parse"] + registration, ok := processor.GetProcessorRegistration("int.parse") if !ok { t.Fatalf("int.parse processor not registered") } @@ -170,7 +170,7 @@ func TestBadIntParse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["int.parse"] + registration, ok := processor.GetProcessorRegistration("int.parse") if !ok { t.Fatalf("int.parse processor not registered") } @@ -201,7 +201,7 @@ func TestBadIntParse(t *testing.T) { } func BenchmarkIntParse(b *testing.B) { - registration, ok := processor.ProcessorRegistry["int.parse"] + registration, ok := processor.GetProcessorRegistration("int.parse") if !ok { b.Fatalf("int.parse processor not registered") } diff --git a/internal/processor/test/int-random_test.go b/internal/processor/test/int-random_test.go index 69dea7a..2297541 100644 --- a/internal/processor/test/int-random_test.go +++ b/internal/processor/test/int-random_test.go @@ -9,7 +9,7 @@ import ( ) func TestIntRandomFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["int.random"] + registration, ok := processor.GetProcessorRegistration("int.random") if !ok { t.Fatalf("int.random processor not registered") } @@ -32,7 +32,7 @@ func TestIntRandomFromRegistry(t *testing.T) { } func TestIntRandomGoodConfig(t *testing.T) { - registration, ok := processor.ProcessorRegistry["int.random"] + registration, ok := processor.GetProcessorRegistration("int.random") if !ok { t.Fatalf("int.random processor not registered") } @@ -84,7 +84,7 @@ func TestGoodIntRandom(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["int.random"] + registration, ok := processor.GetProcessorRegistration("int.random") if !ok { t.Fatalf("int.random processor not registered") } @@ -166,7 +166,7 @@ func TestBadIntRandom(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["int.random"] + registration, ok := processor.GetProcessorRegistration("int.random") if !ok { t.Fatalf("int.random processor not registered") } @@ -197,7 +197,7 @@ func TestBadIntRandom(t *testing.T) { } func BenchmarkIntRandom(b *testing.B) { - registration, ok := processor.ProcessorRegistry["int.random"] + registration, ok := processor.GetProcessorRegistration("int.random") if !ok { b.Fatalf("int.random processor not registered") } diff --git a/internal/processor/test/int-scale_test.go b/internal/processor/test/int-scale_test.go index 0b9a5c6..f4b57cd 100644 --- a/internal/processor/test/int-scale_test.go +++ b/internal/processor/test/int-scale_test.go @@ -9,7 +9,7 @@ import ( ) func TestIntScaleFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["int.scale"] + registration, ok := processor.GetProcessorRegistration("int.scale") if !ok { t.Fatalf("int.scale processor not registered") } @@ -55,7 +55,7 @@ func TestGoodIntScale(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["int.scale"] + registration, ok := processor.GetProcessorRegistration("int.scale") if !ok { t.Fatalf("int.scale processor not registered") } @@ -140,7 +140,7 @@ func TestBadIntScale(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["int.scale"] + registration, ok := processor.GetProcessorRegistration("int.scale") if !ok { t.Fatalf("int.scale processor not registered") } @@ -171,7 +171,7 @@ func TestBadIntScale(t *testing.T) { } func BenchmarkIntScale(b *testing.B) { - registration, ok := processor.ProcessorRegistry["int.scale"] + registration, ok := processor.GetProcessorRegistration("int.scale") if !ok { b.Fatalf("int.scale processor not registered") } diff --git a/internal/processor/test/json-decode_test.go b/internal/processor/test/json-decode_test.go index 24e7612..f355263 100644 --- a/internal/processor/test/json-decode_test.go +++ b/internal/processor/test/json-decode_test.go @@ -11,7 +11,7 @@ import ( ) func TestJsonDecodeFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["json.decode"] + registration, ok := processor.GetProcessorRegistration("json.decode") if !ok { t.Fatalf("json.decode processor not registered") } @@ -127,7 +127,7 @@ func TestBadJsonDecode(t *testing.T) { } func BenchmarkJsonDecode(b *testing.B) { - registration, ok := processor.ProcessorRegistry["json.decode"] + registration, ok := processor.GetProcessorRegistration("json.decode") if !ok { b.Fatalf("json.decode processor not registered") } diff --git a/internal/processor/test/json-encode_test.go b/internal/processor/test/json-encode_test.go index 943d003..f07eb71 100644 --- a/internal/processor/test/json-encode_test.go +++ b/internal/processor/test/json-encode_test.go @@ -12,7 +12,7 @@ import ( ) func TestJsonEncodeFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["json.encode"] + registration, ok := processor.GetProcessorRegistration("json.encode") if !ok { t.Fatalf("json.encode processor not registered") } @@ -116,7 +116,7 @@ func TestBadJsonEncode(t *testing.T) { } func BenchmarkJsonEncode(b *testing.B) { - registration, ok := processor.ProcessorRegistry["json.encode"] + registration, ok := processor.GetProcessorRegistration("json.encode") if !ok { b.Fatalf("json.encode processor not registered") } diff --git a/internal/processor/test/kv-get_test.go b/internal/processor/test/kv-get_test.go index 314f871..3b81698 100644 --- a/internal/processor/test/kv-get_test.go +++ b/internal/processor/test/kv-get_test.go @@ -11,7 +11,7 @@ import ( ) func TestKvGetFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["kv.get"] + registration, ok := processor.GetProcessorRegistration("kv.get") if !ok { t.Fatalf("kv.get processor not registered") } @@ -75,7 +75,7 @@ func TestGoodKvGet(t *testing.T) { } for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["kv.get"] + registration, ok := processor.GetProcessorRegistration("kv.get") if !ok { t.Fatalf("kv.get processor not registered") } @@ -198,7 +198,7 @@ func TestBadKvGet(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["kv.get"] + registration, ok := processor.GetProcessorRegistration("kv.get") if !ok { t.Fatalf("kv.get processor not registered") } @@ -229,7 +229,7 @@ func TestBadKvGet(t *testing.T) { } func BenchmarkKvGet(b *testing.B) { - registration, ok := processor.ProcessorRegistry["kv.get"] + registration, ok := processor.GetProcessorRegistration("kv.get") if !ok { b.Fatalf("kv.get processor not registered") } diff --git a/internal/processor/test/kv-set_test.go b/internal/processor/test/kv-set_test.go index e758d63..51304ba 100644 --- a/internal/processor/test/kv-set_test.go +++ b/internal/processor/test/kv-set_test.go @@ -11,7 +11,7 @@ import ( ) func TestKvSetFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["kv.set"] + registration, ok := processor.GetProcessorRegistration("kv.set") if !ok { t.Fatalf("kv.set processor not registered") } @@ -69,7 +69,7 @@ func TestGoodKvSet(t *testing.T) { } for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["kv.set"] + registration, ok := processor.GetProcessorRegistration("kv.set") if !ok { t.Fatalf("kv.set processor not registered") } @@ -192,7 +192,7 @@ func TestBadKvSet(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["kv.set"] + registration, ok := processor.GetProcessorRegistration("kv.set") if !ok { t.Fatalf("kv.set processor not registered") } @@ -223,7 +223,7 @@ func TestBadKvSet(t *testing.T) { } func BenchmarkKvSet(b *testing.B) { - registration, ok := processor.ProcessorRegistry["kv.set"] + registration, ok := processor.GetProcessorRegistration("kv.set") if !ok { b.Fatalf("kv.set processor not registered") } diff --git a/internal/processor/test/midi-control_change-create_test.go b/internal/processor/test/midi-control_change-create_test.go index f6505cb..13f414a 100644 --- a/internal/processor/test/midi-control_change-create_test.go +++ b/internal/processor/test/midi-control_change-create_test.go @@ -11,7 +11,7 @@ import ( ) func TestMIDIControlChangeCreateFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["midi.control_change.create"] + registration, ok := processor.GetProcessorRegistration("midi.control_change.create") if !ok { t.Fatalf("midi.control_change.create processor not registered") } @@ -57,7 +57,7 @@ func TestGoodMIDIControlChangeCreate(t *testing.T) { for _, test := range tests { 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 { t.Fatalf("midi.control_change.create processor not registered") } @@ -130,7 +130,7 @@ func TestBadMIDIControlChangeCreate(t *testing.T) { for _, test := range tests { 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 { t.Fatalf("midi.control_change.create processor not registered") } @@ -161,7 +161,7 @@ func TestBadMIDIControlChangeCreate(t *testing.T) { } func BenchmarkMIDIControlChangeCreate(b *testing.B) { - registration, ok := processor.ProcessorRegistry["midi.control_change.create"] + registration, ok := processor.GetProcessorRegistration("midi.control_change.create") if !ok { b.Fatalf("midi.control_change.create processor not registered") } diff --git a/internal/processor/test/midi-message-decode_test.go b/internal/processor/test/midi-message-decode_test.go index a52546b..f45adba 100644 --- a/internal/processor/test/midi-message-decode_test.go +++ b/internal/processor/test/midi-message-decode_test.go @@ -11,7 +11,7 @@ import ( ) func TestMIDIMessageDecodeFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["midi.message.decode"] + registration, ok := processor.GetProcessorRegistration("midi.message.decode") if !ok { t.Fatalf("midi.message.decode processor not registered") } diff --git a/internal/processor/test/midi-message-encode_test.go b/internal/processor/test/midi-message-encode_test.go index d076c60..5dc3cc4 100644 --- a/internal/processor/test/midi-message-encode_test.go +++ b/internal/processor/test/midi-message-encode_test.go @@ -11,7 +11,7 @@ import ( ) func TestMIDIMessageEncodeFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["midi.message.encode"] + registration, ok := processor.GetProcessorRegistration("midi.message.encode") if !ok { t.Fatalf("midi.message.encode processor not registered") } diff --git a/internal/processor/test/midi-message-unpack_test.go b/internal/processor/test/midi-message-unpack_test.go index bb82be1..536e6b5 100644 --- a/internal/processor/test/midi-message-unpack_test.go +++ b/internal/processor/test/midi-message-unpack_test.go @@ -11,7 +11,7 @@ import ( ) func TestMIDIMessageUnpackFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["midi.message.unpack"] + registration, ok := processor.GetProcessorRegistration("midi.message.unpack") if !ok { t.Fatalf("midi.message.unpack processor not registered") } @@ -121,7 +121,7 @@ func TestBadMIDIMessageUnpack(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["midi.message.unpack"] + registration, ok := processor.GetProcessorRegistration("midi.message.unpack") if !ok { t.Fatalf("midi.message.unpack processor not registered") } diff --git a/internal/processor/test/midi-note_off-create_test.go b/internal/processor/test/midi-note_off-create_test.go index f159a17..b0f0f56 100644 --- a/internal/processor/test/midi-note_off-create_test.go +++ b/internal/processor/test/midi-note_off-create_test.go @@ -11,7 +11,7 @@ import ( ) func TestMIDINoteOffCreteaFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["midi.note_off.create"] + registration, ok := processor.GetProcessorRegistration("midi.note_off.create") if !ok { t.Fatalf("midi.note_off.create processor not registered") } @@ -56,7 +56,7 @@ func TestGoodMIDINoteOffCretea(t *testing.T) { for _, test := range tests { 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 { t.Fatalf("midi.note_off.create processor not registered") } @@ -129,7 +129,7 @@ func TestBadMIDINoteOffCretea(t *testing.T) { for _, test := range tests { 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 { t.Fatalf("midi.note_off.create processor not registered") } @@ -160,7 +160,7 @@ func TestBadMIDINoteOffCretea(t *testing.T) { } func BenchmarkMIDINoteOffCreate(b *testing.B) { - registration, ok := processor.ProcessorRegistry["midi.note_off.create"] + registration, ok := processor.GetProcessorRegistration("midi.note_off.create") if !ok { b.Fatalf("midi.note_off.create processor not registered") } diff --git a/internal/processor/test/midi-note_on-create_test.go b/internal/processor/test/midi-note_on-create_test.go index 8269763..f7cc456 100644 --- a/internal/processor/test/midi-note_on-create_test.go +++ b/internal/processor/test/midi-note_on-create_test.go @@ -11,7 +11,7 @@ import ( ) func TestMIDINoteOnCreateFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["midi.note_on.create"] + registration, ok := processor.GetProcessorRegistration("midi.note_on.create") if !ok { t.Fatalf("midi.note_on.create processor not registered") } @@ -56,7 +56,7 @@ func TestGoodMIDINoteOnCreate(t *testing.T) { for _, test := range tests { 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 { t.Fatalf("midi.note_on.create processor not registered") } @@ -126,7 +126,7 @@ func TestBadMIDINoteOnCreate(t *testing.T) { for _, test := range tests { 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 { t.Fatalf("midi.note_on.create processor not registered") } @@ -157,7 +157,7 @@ func TestBadMIDINoteOnCreate(t *testing.T) { } func BenchmarkMIDINoteOnCreate(b *testing.B) { - registration, ok := processor.ProcessorRegistry["midi.note_on.create"] + registration, ok := processor.GetProcessorRegistration("midi.note_on.create") if !ok { b.Fatalf("midi.note_on.create processor not registered") } diff --git a/internal/processor/test/midi-program_change-create_test.go b/internal/processor/test/midi-program_change-create_test.go index a90c748..b51ede1 100644 --- a/internal/processor/test/midi-program_change-create_test.go +++ b/internal/processor/test/midi-program_change-create_test.go @@ -11,7 +11,7 @@ import ( ) func TestMIDIProgramChangeCreateFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["midi.program_change.create"] + registration, ok := processor.GetProcessorRegistration("midi.program_change.create") if !ok { t.Fatalf("midi.program_change.create processor not registered") } @@ -55,7 +55,7 @@ func TestGoodMIDIProgramChangeCreate(t *testing.T) { for _, test := range tests { 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 { t.Fatalf("midi.program_change.create processor not registered") } @@ -116,7 +116,7 @@ func TestBadMIDIProgramChangeCreate(t *testing.T) { for _, test := range tests { 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 { t.Fatalf("midi.program_change.create processor not registered") } @@ -147,7 +147,7 @@ func TestBadMIDIProgramChangeCreate(t *testing.T) { } func BenchmarkMIDIProgramChangeCreate(b *testing.B) { - registration, ok := processor.ProcessorRegistry["midi.program_change.create"] + registration, ok := processor.GetProcessorRegistration("midi.program_change.create") if !ok { b.Fatalf("midi.program_change.create processor not registered") } diff --git a/internal/processor/test/module-output_test.go b/internal/processor/test/module-output_test.go index b35908d..28e25b5 100644 --- a/internal/processor/test/module-output_test.go +++ b/internal/processor/test/module-output_test.go @@ -11,7 +11,7 @@ import ( ) func TestModuleOutputFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["module.output"] + registration, ok := processor.GetProcessorRegistration("module.output") if !ok { t.Fatalf("module.output processor not registered") } @@ -37,9 +37,9 @@ func TestModuleOutputFromRegistry(t *testing.T) { router := test.GetNewTestRouter() got, err := processorInstance.Process(t.Context(), common.WrappedPayload{ - InputHandler: router.HandleInput, - Modules: map[string]common.Module{"test": &test.TestOutputModule{}}, - Payload: payload, + InputHandler: router.HandleInput, + Modules: map[string]common.Module{"test": &test.TestOutputModule{}}, + Payload: payload, }) if err != nil { t.Fatalf("module.output processing failed: %s", err) @@ -62,7 +62,7 @@ func TestGoodModuleOutput(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["module.output"] + registration, ok := processor.GetProcessorRegistration("module.output") if !ok { t.Fatalf("module.output processor not registered") } @@ -126,7 +126,7 @@ func TestBadModuleOutput(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["module.output"] + registration, ok := processor.GetProcessorRegistration("module.output") if !ok { t.Fatalf("module.output processor not registered") } diff --git a/internal/processor/test/osc-message-create_test.go b/internal/processor/test/osc-message-create_test.go index 23ac36a..d35eda4 100644 --- a/internal/processor/test/osc-message-create_test.go +++ b/internal/processor/test/osc-message-create_test.go @@ -11,7 +11,7 @@ import ( ) func TestOSCMessageCreateFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["osc.message.create"] + registration, ok := processor.GetProcessorRegistration("osc.message.create") if !ok { t.Fatalf("osc.message.create processor not registered") } @@ -146,7 +146,7 @@ func TestGoodOSCMessageCreate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["osc.message.create"] + registration, ok := processor.GetProcessorRegistration("osc.message.create") if !ok { t.Fatalf("osc.message.create processor not registered") } @@ -371,7 +371,7 @@ func TestBadOSCMessageCreate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["osc.message.create"] + registration, ok := processor.GetProcessorRegistration("osc.message.create") if !ok { t.Fatalf("osc.message.create processor not registered") } @@ -402,7 +402,7 @@ func TestBadOSCMessageCreate(t *testing.T) { } func BenchmarkOSCMessageCreate(b *testing.B) { - registration, ok := processor.ProcessorRegistry["osc.message.create"] + registration, ok := processor.GetProcessorRegistration("osc.message.create") if !ok { b.Fatalf("osc.message.create processor not registered") } diff --git a/internal/processor/test/osc-message-decode_test.go b/internal/processor/test/osc-message-decode_test.go index ebbaaed..61735b1 100644 --- a/internal/processor/test/osc-message-decode_test.go +++ b/internal/processor/test/osc-message-decode_test.go @@ -11,7 +11,7 @@ import ( ) func TestOSCMessageDecodeFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["osc.message.decode"] + registration, ok := processor.GetProcessorRegistration("osc.message.decode") if !ok { t.Fatalf("osc.message.decode processor not registered") } diff --git a/internal/processor/test/osc-message-encode_test.go b/internal/processor/test/osc-message-encode_test.go index 9a89141..43cee77 100644 --- a/internal/processor/test/osc-message-encode_test.go +++ b/internal/processor/test/osc-message-encode_test.go @@ -11,7 +11,7 @@ import ( ) func TestOSCMessageEncodeFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["osc.message.encode"] + registration, ok := processor.GetProcessorRegistration("osc.message.encode") if !ok { t.Fatalf("osc.message.encode processor not registered") } diff --git a/internal/processor/test/pubsub-publish_test.go b/internal/processor/test/pubsub-publish_test.go index 124a94c..35c931e 100644 --- a/internal/processor/test/pubsub-publish_test.go +++ b/internal/processor/test/pubsub-publish_test.go @@ -12,7 +12,7 @@ import ( ) func TestPubSubPublishFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["pubsub.publish"] + registration, ok := processor.GetProcessorRegistration("pubsub.publish") if !ok { t.Fatalf("pubsub.publish processor not registered") } @@ -70,7 +70,7 @@ func TestGoodPubSubPublish(t *testing.T) { } for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["pubsub.publish"] + registration, ok := processor.GetProcessorRegistration("pubsub.publish") if !ok { t.Fatalf("pubsub.publish processor not registered") } @@ -217,7 +217,7 @@ func TestBadPubSubPublish(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["pubsub.publish"] + registration, ok := processor.GetProcessorRegistration("pubsub.publish") if !ok { t.Fatalf("pubsub.publish processor not registered") } diff --git a/internal/processor/test/router-input_test.go b/internal/processor/test/router-input_test.go index 8aca9e0..28af28c 100644 --- a/internal/processor/test/router-input_test.go +++ b/internal/processor/test/router-input_test.go @@ -11,7 +11,7 @@ import ( ) func TestRouterInputFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["router.input"] + registration, ok := processor.GetProcessorRegistration("router.input") if !ok { t.Fatalf("router.input processor not registered") } @@ -35,8 +35,8 @@ func TestRouterInputFromRegistry(t *testing.T) { expected := "test" got, err := processorInstance.Process(t.Context(), common.WrappedPayload{ - InputHandler: test.GetNewTestRouter().HandleInput, - Payload: payload, + InputHandler: test.GetNewTestRouter().HandleInput, + Payload: payload, }) if err != nil { t.Fatalf("router.input processing failed: %s", err) @@ -59,7 +59,7 @@ func TestGoodRouterInput(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["router.input"] + registration, ok := processor.GetProcessorRegistration("router.input") if !ok { t.Fatalf("router.input processor not registered") } @@ -95,36 +95,36 @@ func TestBadRouterInput(t *testing.T) { errorString string }{ { - name: "no source param", - params: map[string]any{}, - payload: "test", - inputHandler: router.HandleInput, - errorString: "router.input source error: not found", + name: "no source param", + params: map[string]any{}, + payload: "test", + inputHandler: router.HandleInput, + errorString: "router.input source error: not found", }, { name: "non-string source", params: map[string]any{ "source": 123, }, - payload: "test", - inputHandler: router.HandleInput, - errorString: "router.input source error: not a string", + payload: "test", + inputHandler: router.HandleInput, + errorString: "router.input source error: not a string", }, { name: "router not found in context", params: map[string]any{ "source": "test", }, - payload: "test", - inputHandler: nil, - errorString: "router.input no input handler found", + payload: "test", + inputHandler: nil, + errorString: "router.input no input handler found", }, } for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["router.input"] + registration, ok := processor.GetProcessorRegistration("router.input") if !ok { t.Fatalf("router.input processor not registered") } diff --git a/internal/processor/test/script-expr_test.go b/internal/processor/test/script-expr_test.go index feeeed8..76cbe3a 100644 --- a/internal/processor/test/script-expr_test.go +++ b/internal/processor/test/script-expr_test.go @@ -9,7 +9,7 @@ import ( ) func TestScriptExprFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["script.expr"] + registration, ok := processor.GetProcessorRegistration("script.expr") if !ok { t.Fatalf("script.expr processor not registered") } @@ -62,7 +62,7 @@ func TestGoodScriptExpr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["script.expr"] + registration, ok := processor.GetProcessorRegistration("script.expr") if !ok { t.Fatalf("script.expr processor not registered") } @@ -117,7 +117,7 @@ func TestBadScriptExpr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["script.expr"] + registration, ok := processor.GetProcessorRegistration("script.expr") if !ok { t.Fatalf("script.expr processor not registered") } @@ -148,7 +148,7 @@ func TestBadScriptExpr(t *testing.T) { } func BenchmarkScriptExpr(b *testing.B) { - registration, ok := processor.ProcessorRegistry["script.expr"] + registration, ok := processor.GetProcessorRegistration("script.expr") if !ok { b.Fatalf("script.expr processor not registered") } diff --git a/internal/processor/test/script-js_test.go b/internal/processor/test/script-js_test.go index 17987ae..3caedb0 100644 --- a/internal/processor/test/script-js_test.go +++ b/internal/processor/test/script-js_test.go @@ -10,7 +10,7 @@ import ( ) func TestScriptJSFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["script.js"] + registration, ok := processor.GetProcessorRegistration("script.js") if !ok { t.Fatalf("script.js processor not registered") } @@ -45,7 +45,7 @@ func TestScriptJSFromRegistry(t *testing.T) { } func TestScriptJSNoProgram(t *testing.T) { - registration, ok := processor.ProcessorRegistry["script.js"] + registration, ok := processor.GetProcessorRegistration("script.js") if !ok { t.Fatalf("script.js processor not registered") } @@ -61,7 +61,7 @@ func TestScriptJSNoProgram(t *testing.T) { } func TestScriptJSBadConfigWrongProgramType(t *testing.T) { - registration, ok := processor.ProcessorRegistry["script.js"] + registration, ok := processor.GetProcessorRegistration("script.js") if !ok { t.Fatalf("script.js processor not registered") } @@ -151,7 +151,7 @@ func TestGoodScriptJS(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["script.js"] + registration, ok := processor.GetProcessorRegistration("script.js") if !ok { t.Fatalf("script.js processor not registered") } @@ -199,7 +199,7 @@ func TestBadScriptJS(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["script.js"] + registration, ok := processor.GetProcessorRegistration("script.js") if !ok { t.Fatalf("script.js processor not registered") } @@ -230,7 +230,7 @@ func TestBadScriptJS(t *testing.T) { } func BenchmarkScriptJS(b *testing.B) { - registration, ok := processor.ProcessorRegistry["script.js"] + registration, ok := processor.GetProcessorRegistration("script.js") if !ok { b.Fatalf("script.js processor not registered") } diff --git a/internal/processor/test/script-wasm_test.go b/internal/processor/test/script-wasm_test.go index 908b335..a43a423 100644 --- a/internal/processor/test/script-wasm_test.go +++ b/internal/processor/test/script-wasm_test.go @@ -11,7 +11,7 @@ import ( ) func TestScriptWASMFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["script.wasm"] + registration, ok := processor.GetProcessorRegistration("script.wasm") if !ok { t.Fatalf("script.wasm processor not registered") } @@ -60,7 +60,7 @@ func TestGoodScriptWASM(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["script.wasm"] + registration, ok := processor.GetProcessorRegistration("script.wasm") if !ok { t.Fatalf("script.wasm processor not registered") } @@ -160,7 +160,7 @@ func TestBadScriptWASM(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["script.wasm"] + registration, ok := processor.GetProcessorRegistration("script.wasm") if !ok { t.Fatalf("script.wasm processor not registered") } @@ -191,7 +191,7 @@ func TestBadScriptWASM(t *testing.T) { } func BenchmarkScriptWASM(b *testing.B) { - registration, ok := processor.ProcessorRegistry["script.wasm"] + registration, ok := processor.GetProcessorRegistration("script.wasm") if !ok { b.Fatalf("script.wasm processor not registered") } diff --git a/internal/processor/test/sip-response-audio-create_test.go b/internal/processor/test/sip-response-audio-create_test.go index 0c897e8..72af798 100644 --- a/internal/processor/test/sip-response-audio-create_test.go +++ b/internal/processor/test/sip-response-audio-create_test.go @@ -10,7 +10,7 @@ import ( ) func TestSipResponseAudioCreateFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["sip.response.audio.create"] + registration, ok := processor.GetProcessorRegistration("sip.response.audio.create") if !ok { t.Fatalf("sip.response.audio.create processor not registered") } @@ -76,7 +76,7 @@ func TestGoodSipResponseAudioCreate(t *testing.T) { for _, test := range tests { 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 { t.Fatalf("sip.response.audio.create processor not registered") } @@ -183,7 +183,7 @@ func TestBadSipResponseAudioCreate(t *testing.T) { for _, test := range tests { 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 { t.Fatalf("sip.response.audio.create processor not registered") } @@ -214,7 +214,7 @@ func TestBadSipResponseAudioCreate(t *testing.T) { } func BenchmarkSipResponseAudioCreate(b *testing.B) { - registration, ok := processor.ProcessorRegistry["sip.response.audio.create"] + registration, ok := processor.GetProcessorRegistration("sip.response.audio.create") if !ok { b.Fatalf("sip.response.audio.create processor not registered") } diff --git a/internal/processor/test/sip-response-dtmf-create_test.go b/internal/processor/test/sip-response-dtmf-create_test.go index ce3d384..8a3d238 100644 --- a/internal/processor/test/sip-response-dtmf-create_test.go +++ b/internal/processor/test/sip-response-dtmf-create_test.go @@ -10,7 +10,7 @@ import ( ) func TestSipResponseDTMFCreateFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["sip.response.dtmf.create"] + registration, ok := processor.GetProcessorRegistration("sip.response.dtmf.create") if !ok { t.Fatalf("sip.response.dtmf.create processor not registered") } @@ -74,7 +74,7 @@ func TestGoodSipResponseDTMFCreate(t *testing.T) { for _, test := range tests { 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 { t.Fatalf("sip.response.dtmf.create processor not registered") } @@ -191,7 +191,7 @@ func TestBadSipResponseDTMFCreate(t *testing.T) { for _, test := range tests { 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 { t.Fatalf("sip.response.dtmf.create processor not registered") } @@ -222,7 +222,7 @@ func TestBadSipResponseDTMFCreate(t *testing.T) { } func BenchmarkSipResponseDTMFCreate(b *testing.B) { - registration, ok := processor.ProcessorRegistry["sip.response.dtmf.create"] + registration, ok := processor.GetProcessorRegistration("sip.response.dtmf.create") if !ok { b.Fatalf("sip.response.dtmf.create processor not registered") } diff --git a/internal/processor/test/string-create_test.go b/internal/processor/test/string-create_test.go index f72fa8f..fc733d2 100644 --- a/internal/processor/test/string-create_test.go +++ b/internal/processor/test/string-create_test.go @@ -10,7 +10,7 @@ import ( ) func TestStringCreateFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["string.create"] + registration, ok := processor.GetProcessorRegistration("string.create") if !ok { t.Fatalf("string.create processor not registered") } @@ -84,7 +84,7 @@ func TestGoodStringCreate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["string.create"] + registration, ok := processor.GetProcessorRegistration("string.create") if !ok { t.Fatalf("string.create processor not registered") } @@ -157,7 +157,7 @@ func TestBadStringCreate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["string.create"] + registration, ok := processor.GetProcessorRegistration("string.create") if !ok { t.Fatalf("string.create processor not registered") } @@ -188,7 +188,7 @@ func TestBadStringCreate(t *testing.T) { } func BenchmarkStringCreate(b *testing.B) { - registration, ok := processor.ProcessorRegistry["string.create"] + registration, ok := processor.GetProcessorRegistration("string.create") if !ok { b.Fatalf("string.create processor not registered") } diff --git a/internal/processor/test/string-decode_test.go b/internal/processor/test/string-decode_test.go index 48382e0..7934752 100644 --- a/internal/processor/test/string-decode_test.go +++ b/internal/processor/test/string-decode_test.go @@ -10,7 +10,7 @@ import ( ) func TestStringDecodeFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["string.decode"] + registration, ok := processor.GetProcessorRegistration("string.decode") if !ok { t.Fatalf("string.decode processor not registered") } @@ -101,7 +101,7 @@ func TestBadStringDecode(t *testing.T) { } func BenchmarkStringDecode(b *testing.B) { - registration, ok := processor.ProcessorRegistry["string.decode"] + registration, ok := processor.GetProcessorRegistration("string.decode") if !ok { b.Fatalf("string.decode processor not registered") } diff --git a/internal/processor/test/string-encode_test.go b/internal/processor/test/string-encode_test.go index 237a41c..f00393a 100644 --- a/internal/processor/test/string-encode_test.go +++ b/internal/processor/test/string-encode_test.go @@ -11,7 +11,7 @@ import ( ) func TestStringEncodeFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["string.encode"] + registration, ok := processor.GetProcessorRegistration("string.encode") if !ok { t.Fatalf("string.encode processor not registered") } @@ -107,7 +107,7 @@ func TestBadStringEncode(t *testing.T) { } func BenchmarkStringEncode(b *testing.B) { - registration, ok := processor.ProcessorRegistry["string.encode"] + registration, ok := processor.GetProcessorRegistration("string.encode") if !ok { b.Fatalf("string.encode processor not registered") } diff --git a/internal/processor/test/string-split_test.go b/internal/processor/test/string-split_test.go index f1f22b4..3b980be 100644 --- a/internal/processor/test/string-split_test.go +++ b/internal/processor/test/string-split_test.go @@ -11,7 +11,7 @@ import ( ) func TestStringSplitFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["string.split"] + registration, ok := processor.GetProcessorRegistration("string.split") if !ok { t.Fatalf("string.split processor not registered") } @@ -66,7 +66,7 @@ func TestGoodStringSplit(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["string.split"] + registration, ok := processor.GetProcessorRegistration("string.split") if !ok { t.Fatalf("string.split processor not registered") } @@ -126,7 +126,7 @@ func TestBadStringSplit(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["string.split"] + registration, ok := processor.GetProcessorRegistration("string.split") if !ok { t.Fatalf("string.split processor not registered") } @@ -156,7 +156,7 @@ func TestBadStringSplit(t *testing.T) { } func BenchmarkStringSplit(b *testing.B) { - registration, ok := processor.ProcessorRegistry["string.split"] + registration, ok := processor.GetProcessorRegistration("string.split") if !ok { b.Fatalf("string.split processor not registered") } diff --git a/internal/processor/test/struct-field-get_test.go b/internal/processor/test/struct-field-get_test.go index 15cea80..174e1bb 100644 --- a/internal/processor/test/struct-field-get_test.go +++ b/internal/processor/test/struct-field-get_test.go @@ -11,7 +11,7 @@ import ( ) func TestStructFieldGetFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["struct.field.get"] + registration, ok := processor.GetProcessorRegistration("struct.field.get") if !ok { t.Fatalf("struct.field.get processor not registered") } @@ -93,7 +93,7 @@ func TestGoodStructFieldGet(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["struct.field.get"] + registration, ok := processor.GetProcessorRegistration("struct.field.get") if !ok { t.Fatalf("struct.field.get processor not registered") } @@ -162,7 +162,7 @@ func TestBadStructFieldGet(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["struct.field.get"] + registration, ok := processor.GetProcessorRegistration("struct.field.get") if !ok { t.Fatalf("struct.field.get processor not registered") } @@ -193,7 +193,7 @@ func TestBadStructFieldGet(t *testing.T) { } func BenchmarkStructFieldGet(b *testing.B) { - registration, ok := processor.ProcessorRegistry["struct.field.get"] + registration, ok := processor.GetProcessorRegistration("struct.field.get") if !ok { b.Fatalf("struct.field.get processor not registered") } diff --git a/internal/processor/test/struct-method-get_test.go b/internal/processor/test/struct-method-get_test.go index c75be35..f1dbc91 100644 --- a/internal/processor/test/struct-method-get_test.go +++ b/internal/processor/test/struct-method-get_test.go @@ -11,7 +11,7 @@ import ( ) func TestStructMethodGetFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["struct.method.get"] + registration, ok := processor.GetProcessorRegistration("struct.method.get") if !ok { t.Fatalf("struct.method.get processor not registered") } @@ -118,7 +118,7 @@ func TestGoodStructMethodGet(t *testing.T) { } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["struct.method.get"] + registration, ok := processor.GetProcessorRegistration("struct.method.get") if !ok { t.Fatalf("struct.method.get processor not registered") } @@ -187,7 +187,7 @@ func TestBadStructMethodGet(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["struct.method.get"] + registration, ok := processor.GetProcessorRegistration("struct.method.get") if !ok { t.Fatalf("struct.method.get processor not registered") } @@ -218,7 +218,7 @@ func TestBadStructMethodGet(t *testing.T) { } func BenchmarkStructMethodGet(b *testing.B) { - registration, ok := processor.ProcessorRegistry["struct.method.get"] + registration, ok := processor.GetProcessorRegistration("struct.method.get") if !ok { b.Fatalf("struct.method.get processor not registered") } diff --git a/internal/processor/test/time-sleep_test.go b/internal/processor/test/time-sleep_test.go index 139613b..55e1267 100644 --- a/internal/processor/test/time-sleep_test.go +++ b/internal/processor/test/time-sleep_test.go @@ -9,7 +9,7 @@ import ( ) func TestTimeSleepFromRegistry(t *testing.T) { - registration, ok := processor.ProcessorRegistry["time.sleep"] + registration, ok := processor.GetProcessorRegistration("time.sleep") if !ok { t.Fatalf("time.sleep processor not registered") } @@ -45,7 +45,7 @@ func TestGoodTimeSleep(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["time.sleep"] + registration, ok := processor.GetProcessorRegistration("time.sleep") if !ok { t.Fatalf("time.sleep processor not registered") } @@ -97,7 +97,7 @@ func TestBadTimeSleep(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - registration, ok := processor.ProcessorRegistry["time.sleep"] + registration, ok := processor.GetProcessorRegistration("time.sleep") if !ok { t.Fatalf("time.sleep processor not registered") } diff --git a/internal/route/route.go b/internal/route/route.go index c65586b..aa5df54 100644 --- a/internal/route/route.go +++ b/internal/route/route.go @@ -19,7 +19,7 @@ func NewRoute(config config.RouteConfig) (*Route, error) { if len(config.Processors) > 0 { for _, processorDecl := range config.Processors { - processorInfo, ok := processor.ProcessorRegistry[processorDecl.Type] + processorInfo, ok := processor.GetProcessorRegistration(processorDecl.Type) if !ok { return nil, fmt.Errorf("problem loading processor registration for processor type: %s", processorDecl.Type) } diff --git a/internal/schema/modules.go b/internal/schema/modules.go index 3e188ed..2ffb420 100644 --- a/internal/schema/modules.go +++ b/internal/schema/modules.go @@ -19,7 +19,7 @@ func GetModulesSchema() *jsonschema.Schema { } moduleDefinitionSchemas := []*jsonschema.Schema{} - for _, mod := range module.ModuleRegistry { + for _, mod := range module.GetModuleRegistrations() { moduleSchema := &jsonschema.Schema{ ID: mod.Type, Type: "object", diff --git a/internal/schema/processors.go b/internal/schema/processors.go index 25151c9..54a30bd 100644 --- a/internal/schema/processors.go +++ b/internal/schema/processors.go @@ -19,7 +19,7 @@ func GetProcessorsSchema() *jsonschema.Schema { } processorDefinitionSchemas := []*jsonschema.Schema{} - for _, proc := range processor.ProcessorRegistry { + for _, proc := range processor.GetProcessorRegistrations() { processorSchema := &jsonschema.Schema{ ID: proc.Type, Type: "object", diff --git a/router.go b/router.go index 3b9f24c..0ca6dae 100644 --- a/router.go +++ b/router.go @@ -36,7 +36,7 @@ func (r *Router) addModule(moduleDecl config.ModuleConfig) error { if moduleDecl.Id == "" { return errors.New("module id cannot be empty") } - moduleInfo, ok := module.ModuleRegistry[moduleDecl.Type] + moduleRegistration, ok := module.GetModuleRegistration(moduleDecl.Type) if !ok { 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") } - moduleInstance, err := moduleInfo.New(moduleDecl) + moduleInstance, err := moduleRegistration.New(moduleDecl) if err != nil { return err } @@ -208,11 +208,11 @@ func (r *Router) HandleInput(ctx context.Context, sourceId string, payload any) routeFound.Store(true) _, err := routeInstance.ProcessPayload(ctx, common.WrappedPayload{ - Payload: payload, - Source: sourceId, - Modules: r.ModuleInstances, - InputHandler: r.HandleInput, - End: false, + Payload: payload, + Source: sourceId, + Modules: r.ModuleInstances, + InputHandler: r.HandleInput, + End: false, }) if err != nil { if routeIOErrors == nil {