Skip to content

firminochangani/recurrent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

recurrent

main

A Go package to run tasks recurrently. - Inspired by the Python lib schedule

  • Parallel execution of jobs
  • Cancellation of running jobs via context

Usage

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/flowck/recurrent/recurrent"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
	defer cancel()

	s := recurrent.New()

	s.Every(time.Second * 1).Do(func(ctx context.Context) {
		fmt.Println("--->", time.Now())
	})

	s.Every(time.Second * 2).Do(func(ctx context.Context) {
		fmt.Println("--->", time.Now())
	})

	s.Run(ctx)
}

Releases

No releases published

Packages

No packages published

Languages