cron

package
v0.0.0-...-1649e63 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMetrics

func GetMetrics() []prometheus.Collector

Types

type Doer

type Doer interface {
	Do() error
}

type Job

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

Job reporesents Cron Job which could be runned in some interval or on daily basis. It's a thin wrapper around stdlib's time.Ticker.

func NewDailyJob

func NewDailyJob(hour, min int, log *slog.Logger) *Job

NewDailyJob constructs job which will be triggered on the daily basis at the given point of time. NOTE: it expects time in UTC timezone. It's -3 hours compared to Kyiv Time: 12:00 UTC = 15:00 by Kyiv

func NewJob

func NewJob(interval time.Duration, log *slog.Logger) *Job

NewJob constructs job which will be triggered after provided interval.

func (*Job) Do

func (j *Job) Do(fn Doer)

Do method calls provided fn with the given interval. Does not stop on error, only logs it and then goes on. Reset is needed for the daily job, to change it to 24 hours and it's done only once after first run.

type MetricsDecorator

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

func NewWithMetrics

func NewWithMetrics(doer Doer, event string) *MetricsDecorator

func (*MetricsDecorator) Do

func (md *MetricsDecorator) Do() error

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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