1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| package exec
import ( "sync" )
type Service struct { Execs Execs mu sync.Mutex }
func NewService() *Service { return &Service{} }
func (s *Service) NewExec(key string, cmd string, path string, envvars ...string) *Exec { s.mu.Lock() defer s.mu.Unlock() idx := len(s.Execs.GetByKey(key)) + 1 e := NewExec(key, idx, cmd, path, envvars...) s.Execs = append(s.Execs, e) s.Execs.Sort() return e }
|