All Projects → madflojo → tasks

madflojo / tasks

Licence: MIT license
Package tasks is an easy to use in-process scheduler for recurring tasks in Go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to tasks

linda
Linda is a simple dispatcher library.
Stars: ✭ 12 (-90.08%)
Mutual labels:  task, scheduler
Queuer
Queuer is a queue manager, built on top of OperationQueue and Dispatch (aka GCD).
Stars: ✭ 964 (+696.69%)
Mutual labels:  task, scheduler
josk
🏃🤖 Scheduler and manager for jobs and tasks in node.js on multi-server and clusters setup
Stars: ✭ 27 (-77.69%)
Mutual labels:  task, scheduler
go-xxl-job-client
xxl-job go client
Stars: ✭ 36 (-70.25%)
Mutual labels:  task, scheduler
Chronus
Chronus是360金融技术团队基于阿里开源项目TBSchedule重写的分布式调度。
Stars: ✭ 166 (+37.19%)
Mutual labels:  task, scheduler
croner
Trigger functions and/or evaluate cron expressions in JavaScript. No dependencies. Most features. All environments.
Stars: ✭ 169 (+39.67%)
Mutual labels:  task, scheduler
Xxl Job
A distributed task scheduling framework.(分布式任务调度平台XXL-JOB)
Stars: ✭ 20,197 (+16591.74%)
Mutual labels:  task, scheduler
resc
A task orchestrator using redis, written in rust
Stars: ✭ 27 (-77.69%)
Mutual labels:  task, scheduler
Ects
Elastic Crontab System 简单易用的分布式定时任务管理系统
Stars: ✭ 156 (+28.93%)
Mutual labels:  task, scheduler
Beatserver
Beatserver, a periodic task scheduler for Django 🎵
Stars: ✭ 106 (-12.4%)
Mutual labels:  task, scheduler
chronus
Chronus是360数科技术团队基于阿里开源项目TBSchedule重写的分布式调度。
Stars: ✭ 174 (+43.8%)
Mutual labels:  task, scheduler
YACLib
Yet Another Concurrency Library
Stars: ✭ 193 (+59.5%)
Mutual labels:  task, scheduler
Docker Airflow
Docker Apache Airflow
Stars: ✭ 3,375 (+2689.26%)
Mutual labels:  task, scheduler
Clock
可视化任务调度系统,精简到一个二进制文件 (Web visual task scheduler system , yes ! just one binary solve all the problems !)
Stars: ✭ 86 (-28.93%)
Mutual labels:  task, scheduler
Scheduler
Task scheduler for Golang
Stars: ✭ 171 (+41.32%)
Mutual labels:  task, scheduler
Cloudtask
cloudtask is a distributed task scheduling platform.
Stars: ✭ 173 (+42.98%)
Mutual labels:  task, scheduler
diffido
Watch web pages for changes
Stars: ✭ 19 (-84.3%)
Mutual labels:  scheduler
rx-scheduler-transformer
rxjava scheduler transformer tools for android
Stars: ✭ 15 (-87.6%)
Mutual labels:  scheduler
EasyJob
🔨 EasyJob - keep and execute your PowerShell and BAT scripts from one interface
Stars: ✭ 228 (+88.43%)
Mutual labels:  task
Android-Task-Injection
Task Hijacking in Android (somebody call it also StrandHogg vulnerability)
Stars: ✭ 52 (-57.02%)
Mutual labels:  task

Tasks

Coverage Status Go Report Card PkgGoDev

Package tasks is an easy to use in-process scheduler for recurring tasks in Go. Tasks is focused on high frequency tasks that run quick, and often. The goal of Tasks is to support concurrent running tasks at scale without scheduler induced jitter.

Tasks is focused on accuracy of task execution. To do this each task is called within it's own goroutine. This ensures that long execution of a single invocation does not throw the schedule as a whole off track.

As usage of this scheduler scales, it is expected to have a larger number of sleeping goroutines. As it is designed to leverage Go's ability to optimize goroutine CPU scheduling.

For simplicity this task scheduler uses the time.Duration type to specify intervals. This allows for a simple interface and flexible control over when tasks are executed.

Below is an example of starting the scheduler and registering a new task that runs every 30 seconds.

// Start the Scheduler
scheduler := tasks.New()
defer scheduler.Stop()

// Add a task
id, err := scheduler.Add(&tasks.Task{
  Interval: time.Duration(30 * time.Second),
  TaskFunc: func() error {
    // Put your logic here
  }(),
})
if err != nil {
  // Do Stuff
}

Sometimes schedules need to started at a later time. This package provides the ability to start a task only after a certain time. The below example shows this in practice.

// Add a recurring task for every 30 days, starting 30 days from now
id, err := scheduler.Add(&tasks.Task{
  Interval: time.Duration(30 * (24 * time.Hour)),
  StartAfter: time.Now().Add(30 * (24 * time.Hour)),
  TaskFunc: func() error {
    // Put your logic here
  }(),
})
if err != nil {
  // Do Stuff
}

It is also common for applications to run a task only once. The below example shows scheduling a task to run only once after waiting for 60 seconds.

// Add a one time only task for 60 seconds from now
id, err := scheduler.Add(&tasks.Task{
  Interval: time.Duration(60 * time.Second)
  RunOnce:  true,
  TaskFunc: func() error {
    // Put your logic here
  }(),
})
if err != nil {
  // Do Stuff
}

One powerful feature of Tasks is that it allows users to specify custom error handling. This is done by allowing users to define a function that is called when a task returns an error. The below example shows scheduling a task that logs when an error occurs.

// Add a task with custom error handling
id, err := scheduler.Add(&tasks.Task{
  Interval: time.Duration(30 * time.Second),
  TaskFunc: func() error {
    // Put your logic here
  }(),
  ErrFunc: func(e error) {
    log.Printf("An error occurred when executing task %s - %s", id, e)
  }(),
})
if err != nil {
  // Do Stuff
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].