Skip to content

Latest commit

 

History

History
85 lines (54 loc) · 2.37 KB

README.md

File metadata and controls

85 lines (54 loc) · 2.37 KB

TASKINATOR 🤖

Welcome to the TASKINATOR! This package provides a robust utility in Golang that helps to set up and manage tasks that executes based on the duration specified by the user.

Key Features 📌

  1. Schedule multiple tasks with given name, schedule time, maximum retry count, retry delay, and action function.

  2. Robust automatic retry logic in place in case of task failures.

  3. The ability to execute multiple tasks concurrently.


How to Use 🚀

1. Get the package

go get -u github.com/kylix31/taskinator 

2. Import the package

In your Go file, import the tasksgenerator package.

import "github.com/kylix31/taskinator"

3. Usage

Create a Scheduler object using the NewScheduler function.

scheduler := tasksgenerator.NewScheduler()

Add tasks to the Scheduler using the AddTask method. The Task struct must include the following fields:

  • Name (string): Name of the Task
  • Schedule (time.Duration): Interval at which the task will be triggered - if nil will run forever
  • MaxRetries (int): Maximum number of retries that will be done before task is considered failed
  • RetryDelay (time.Duration): Delay before each retry
  • Action (func() error): Function to be performed by the Task
task := tasksgenerator.Task{
	Name: "Sample Task",
	Schedule: 5 * time.Second,
	MaxRetries: 3,
	RetryDelay: 2 * time.Second,
	Action: func() error {
		// your task code
	},
}

scheduler.AddTask(task)

Finally, start the Scheduler using the Start method where Duration is the total time throughout which tasks should run.

scheduler.Start(60 * time.Second)  // Run tasks for 60 seconds

And that's it! Now, TASKINATOR is at your service, doing all those tasks you've scheduled on the desired interval.


Contribution ✨

Feel free to report issues or create a pull-request. All contributions are welcome.


ACKNOWLEDGEMENT 💖

Thanks goes to those wonderful people who inspired or contributed in any way towards the development of TASKINATOR.


Let TASKINATOR bring success to your task scheduling needs! 🎉

Made with 💙 and Go.