diff options
Diffstat (limited to 'services_controller.go')
-rw-r--r-- | services_controller.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/services_controller.go b/services_controller.go index e5fa200..566f6ba 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,19 @@ 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 { + log.Println(service) + log.Println(err) + return errors.New(err.Error()) + } else { + log.Println(err) + log.Println(sc.services) + delete(sc.services, service.Port) + return nil + } +} |