mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-08-21 05:58:59 +00:00
don't export module/processor/framer registrations
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user