mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 12:55:29 +00:00
add removeModule function to router
This commit is contained in:
11
router.go
11
router.go
@@ -26,7 +26,6 @@ type Router struct {
|
||||
tracer trace.Tracer
|
||||
}
|
||||
|
||||
// TODO(jwetzell): support removing module
|
||||
func (r *Router) addModule(moduleDecl config.ModuleConfig) error {
|
||||
if moduleDecl.Id == "" {
|
||||
return errors.New("module id cannot be empty")
|
||||
@@ -50,6 +49,16 @@ func (r *Router) addModule(moduleDecl config.ModuleConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Router) removeModule(moduleId string) error {
|
||||
moduleInstance, ok := r.ModuleInstances[moduleId]
|
||||
if !ok {
|
||||
return errors.New("module id not found")
|
||||
}
|
||||
moduleInstance.Stop()
|
||||
delete(r.ModuleInstances, moduleId)
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO(jwetzell): support removing route
|
||||
func (r *Router) addRoute(routeDecl config.RouteConfig) error {
|
||||
routeInstance, err := route.NewRoute(routeDecl)
|
||||
|
||||
Reference in New Issue
Block a user