All Projects → roylee0704 → Gron

roylee0704 / Gron

Licence: mit
gron, Cron Jobs in Go.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Gron

Laravel Totem
Manage Your Laravel Schedule From A Web Dashboard
Stars: ✭ 1,299 (+54.83%)
Mutual labels:  scheduling, cron-jobs
Cronscheduler.aspnetcore
Cron Scheduler for AspNetCore 2.x/3.x or DotNetCore 2.x/3.x Self-hosted
Stars: ✭ 100 (-88.08%)
Mutual labels:  scheduling, cron-jobs
Magento2 Cronjobmanager
Cron Job Manager for Magento 2
Stars: ✭ 233 (-72.23%)
Mutual labels:  scheduling, cron-jobs
Healthchecks
A cron monitoring tool written in Python & Django
Stars: ✭ 4,297 (+412.16%)
Mutual labels:  cron-jobs
Odin
A programmable, observable and distributed job orchestration system.
Stars: ✭ 405 (-51.73%)
Mutual labels:  scheduling
Posterus
Composable async primitives with cancelation, control over scheduling, and coroutines. Superior replacement for JS Promises.
Stars: ✭ 536 (-36.11%)
Mutual labels:  scheduling
Shift Scheduling
Shift Scheduling for workforce
Stars: ✭ 22 (-97.38%)
Mutual labels:  scheduling
Pretalx
Conference planning tool: CfP, scheduling, speaker management
Stars: ✭ 363 (-56.73%)
Mutual labels:  scheduling
Nodock
Docker Compose for Node projects with Node, MySQL, Redis, MongoDB, NGINX, Apache2, Memcached, Certbot and RabbitMQ images
Stars: ✭ 734 (-12.51%)
Mutual labels:  cron-jobs
Quartznet
Quartz Enterprise Scheduler .NET
Stars: ✭ 4,825 (+475.09%)
Mutual labels:  scheduling
Chronos
Fault tolerant job scheduler for Mesos which handles dependencies and ISO8601 based schedules
Stars: ✭ 4,303 (+412.87%)
Mutual labels:  cron-jobs
Active workflow
Turn complex requirements to workflows without leaving the comfort of your technology stack.
Stars: ✭ 413 (-50.77%)
Mutual labels:  scheduling
Ecs Deploy
Powerful CLI tool to simplify Amazon ECS deployments, rollbacks & scaling
Stars: ✭ 541 (-35.52%)
Mutual labels:  scheduling
Pg timetable
pg_timetable: Advanced scheduling for PostgreSQL
Stars: ✭ 382 (-54.47%)
Mutual labels:  scheduling
Flask Apscheduler
Adds APScheduler support to Flask
Stars: ✭ 741 (-11.68%)
Mutual labels:  cron-jobs
Azkaban
Azkaban workflow manager.
Stars: ✭ 3,914 (+366.51%)
Mutual labels:  scheduling
Oncall
Oncall is a calendar tool designed for scheduling and managing on-call shifts. It can be used as source of dynamic ownership info for paging systems like http://iris.claims.
Stars: ✭ 702 (-16.33%)
Mutual labels:  scheduling
Nging
漂亮的Go语言通用后台管理框架,包含计划任务、MySQL管理、Redis管理、FTP管理、SSH管理、服务器管理、Caddy配置、云存储管理等功能。
Stars: ✭ 443 (-47.2%)
Mutual labels:  cron-jobs
Openpbs
An HPC workload manager and job scheduler for desktops, clusters, and clouds.
Stars: ✭ 427 (-49.11%)
Mutual labels:  scheduling
Ical4j
A Java library for parsing and building iCalendar data models
Stars: ✭ 493 (-41.24%)
Mutual labels:  scheduling

gron

Build Status Go Report Card GoDoc

Gron provides a clear syntax for writing and deploying cron jobs.

Goals

  • Minimalist APIs for scheduling jobs.
  • Thread safety.
  • Customizable Job Type.
  • Customizable Schedule.

Installation

$ go get github.com/roylee0704/gron

Usage

Create schedule.go

package main

import (
	"fmt"
	"time"
	"github.com/roylee0704/gron"
)

func main() {
	c := gron.New()
	c.AddFunc(gron.Every(1*time.Hour), func() {
		fmt.Println("runs every hour.")
	})
	c.Start()
}

Schedule Parameters

All scheduling is done in the machine's local time zone (as provided by the Go time package).

Setup basic periodic schedule with gron.Every().

gron.Every(1*time.Second)
gron.Every(1*time.Minute)
gron.Every(1*time.Hour)

Also support Day, Week by importing gron/xtime:

import "github.com/roylee0704/gron/xtime"

gron.Every(1 * xtime.Day)
gron.Every(1 * xtime.Week)

Schedule to run at specific time with .At(hh:mm)

gron.Every(30 * xtime.Day).At("00:00")
gron.Every(1 * xtime.Week).At("23:59")

Custom Job Type

You may define custom job types by implementing gron.Job interface: Run().

For example:

type Reminder struct {
	Msg string
}

func (r Reminder) Run() {
  fmt.Println(r.Msg)
}

After job has defined, instantiate it and schedule to run in Gron.

c := gron.New()
r := Reminder{ "Feed the baby!" }
c.Add(gron.Every(8*time.Hour), r)
c.Start()

Custom Job Func

You may register Funcs to be executed on a given schedule. Gron will run them in their own goroutines, asynchronously.

c := gron.New()
c.AddFunc(gron.Every(1*time.Second), func() {
	fmt.Println("runs every second")
})
c.Start()

Custom Schedule

Schedule is the interface that wraps the basic Next method: Next(p time.Duration) time.Time

In gron, the interface value Schedule has the following concrete types:

  • periodicSchedule. adds time instant t to underlying period p.
  • atSchedule. reoccurs every period p, at time components(hh:mm).

For more info, checkout schedule.go.

Full Example

package main

import (
	"fmt"
	"github.com/roylee0704/gron"
	"github.com/roylee0704/gron/xtime"
)

type PrintJob struct{ Msg string }

func (p PrintJob) Run() {
	fmt.Println(p.Msg)
}

func main() {

	var (
		// schedules
		daily     = gron.Every(1 * xtime.Day)
		weekly    = gron.Every(1 * xtime.Week)
		monthly   = gron.Every(30 * xtime.Day)
		yearly    = gron.Every(365 * xtime.Day)

		// contrived jobs
		purgeTask = func() { fmt.Println("purge aged records") }
		printFoo  = printJob{"Foo"}
		printBar  = printJob{"Bar"}
	)

	c := gron.New()

	c.Add(daily.At("12:30"), printFoo)
	c.AddFunc(weekly, func() { fmt.Println("Every week") })
	c.Start()

	// Jobs may also be added to a running Gron
	c.Add(monthly, printBar)
	c.AddFunc(yearly, purgeTask)

	// Stop Gron (running jobs are not halted).
	c.Stop()
}
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].