redcron

package module
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

README

redcron

Go Reference

Package redcron provides RedCron struct to run cron jobs periodically by using Redis.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Client  *redis.Client
	OnError func(err error, name string)
}

Config holds RedCron config.

type RedCron

type RedCron struct {
	// contains filtered or unexported fields
}

RedCron registers and runs cron jobs.

func New

func New(cfg Config) (c *RedCron)

New creates a new RedCron struct.

func (*RedCron) Register added in v0.3.0

func (c *RedCron) Register(name string, repeatSec int, offsetSec int, f func(context.Context)) *RedCron

Register registers a new cron job by the given parameters. It returns the underlying RedCron. If the underlying RedCron is stopped, registered cron jobs won't be triggered.

func (*RedCron) Stop

func (c *RedCron) Stop(ctx context.Context)

Stop stops triggering cron jobs and waits for all jobs are finished. When ctx has been done, all contexts of jobs are cancelled. If ctx is nil, all contexts of jobs are cancelled immediately.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL