Example #1
0
func main() {
	worker := goworker.NewManager("Task Manager", 10)

	for i := 0; i < TASKS; i++ {
		worker.Exec(Task(i))
	}

	worker.Finish()
}
Example #2
0
func main() {
	name := "Recipes Task Manager"

	app := goworker.NewManager(name, 10)

	app.Exec(recipeFinder.New())
	for i := 0; i < 99; i++ {
		app.Exec(recipeReader.New())
	}

	app.Finish()

	log.Println("Stopping Recipes App")
}
Example #3
0
	return nil
}

type task_two int

func (t task_two) Do() error {
	log.Printf("First task: %d starting...", t)

	time.Sleep(sleep_time())

	log.Printf("Second task: %d done.", t)

	return nil
}

var worker = goworker.NewManager("Dependent Tasks", 10)

const TASKS = 1000

func sleep_time() time.Duration {
	return time.Duration(int(time.Millisecond) * (rand.Intn(91) + 10))
}

func main() {
	for i := 0; i < TASKS; i++ {
		worker.Exec(task_one(i)).Then(task_two(i))
	}

	worker.Finish()
}