diff --git a/README.md b/README.md index 7d53d3b..df64216 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The `Manager` handles communication and synchronized shutdown procedure. 1. Create a unit manager 2. Implement the `WorkUnit` on your goroutines 3. Add units to the manager -4. Start the manager and wait on its `Quit` channel +4. Run the manager and wait on its `Quit` channel ```golang import ( @@ -81,8 +81,8 @@ func main() { manager.AddUnit(worker) manager.AddUnit(worker2) - // Start the manager - go manager.Start() + // Run the manager + go manager.Run() // Wait for all units to shutdown gracefully through their `Shutdown` method diff --git a/manager.go b/manager.go index a9a774e..deef8a7 100644 --- a/manager.go +++ b/manager.go @@ -12,7 +12,7 @@ import ( var idGen = IdGenerator() type WorkUnit interface { - Spawn(UnitManager) + Run(UnitManager) Shutdown() } @@ -57,12 +57,12 @@ type Manager struct { panic chan error // Used for panicing goroutines } -func (m *Manager) Start() { +func (m *Manager) Run() { log.Println("Starting manager ...") for unitName, w := range m.workers { log.Printf("Starting <%s>\n", unitName) - go w.unit.Spawn(w) + go w.unit.Run(w) } for { diff --git a/manager_test.go b/manager_test.go index 0ab7aca..cdc6ed0 100644 --- a/manager_test.go +++ b/manager_test.go @@ -13,7 +13,7 @@ var WorkerID int type Worker struct{} // Example loop, it will be spwaned in a goroutine -func (w *Worker) Spawn(um UnitManager) { +func (w *Worker) Run(um UnitManager) { ticker := time.NewTicker(time.Second) // Worker's loop @@ -62,7 +62,7 @@ func DoRunMain(pid chan int, quit chan<- bool) { manager.AddUnit(worker2) // Start the manager - go manager.Start() + go manager.Run() // Wait for all units to shutdown gracefully through their `Shutdown` method quit <- <-manager.Quit