aboutsummaryrefslogtreecommitdiff
path: root/services_controller.go
diff options
context:
space:
mode:
Diffstat (limited to 'services_controller.go')
-rw-r--r--services_controller.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/services_controller.go b/services_controller.go
index e5fa200..aea4693 100644
--- a/services_controller.go
+++ b/services_controller.go
@@ -20,8 +20,9 @@ package main
import (
"context"
"errors"
- log "github.com/sirupsen/logrus"
"sync"
+
+ log "github.com/sirupsen/logrus"
)
type Service struct {
@@ -79,3 +80,15 @@ func (sc *ServicesController) GetServices() map[uint16]Service {
sc.mutex.Unlock()
return services
}
+
+func (sc *ServicesController) DeleteService(c context.Context, service Service) error {
+ sc.mutex.Lock()
+ defer sc.mutex.Unlock()
+
+ if err := sc.storage.Delete(Services).Context(c).Filter(OrderedDocument{{"_id", service.Port}}).One(); err != nil {
+ return errors.New(err.Error())
+ } else {
+ delete(sc.services, service.Port)
+ return nil
+ }
+}