add create/delete/start/stop to runtime

This commit is contained in:
Asim Aslam
2019-09-13 21:58:03 -07:00
parent 0fc4c180ee
commit 0cdfc7b9ea
2 changed files with 26 additions and 8 deletions

View File

@@ -141,7 +141,7 @@ func (s *service) Wait() {
s.running = false
}
func (r *runtime) Register(s *Service) error {
func (r *runtime) Create(s *Service) error {
r.Lock()
defer r.Unlock()
@@ -155,7 +155,19 @@ func (r *runtime) Register(s *Service) error {
return nil
}
func (r *runtime) Run() error {
func (r *runtime) Delete(s *Service) error {
r.Lock()
defer r.Unlock()
if s, ok := r.services[s.Name]; ok {
delete(r.services, s.Name)
return s.Stop()
}
return nil
}
func (r *runtime) Start() error {
r.Lock()
// already running