schedule

package
v0.163.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Daily

type Daily struct {
	Hour, Minute int
	Location     *time.Location
}

func (Daily) UntilNext

func (i Daily) UntilNext(lastRanAt time.Time) time.Duration

type Interval

type Interval time.Duration

func Every added in v0.157.0

func Every(d time.Duration) Interval

Every is a syntax sugar to make the reading the usage of time.Duration based Interval more fluent.

func (Interval) UntilNext

func (i Interval) UntilNext(lastRanAt time.Time) time.Duration

type Monthly

type Monthly struct {
	Day, Hour, Minute int
	Location          *time.Location
}

func (Monthly) UntilNext

func (i Monthly) UntilNext(lastRanAt time.Time) time.Duration

type Repository added in v0.157.0

type Repository interface {
	Locks() guard.LockerFactory[StateID]
	States() StateRepository
}

type Scheduler

type Scheduler struct{ Repository Repository }

func (Scheduler) WithSchedule

func (s Scheduler) WithSchedule(id StateID, interval tasker.Interval, job tasker.Task) tasker.Task
Example
package main

import (
	"context"
	"github.com/adamluzsi/frameless/pkg/tasker/schedule"
	"log"
)

func main() {
	scheduler := schedule.Scheduler{
		Repository: nil, // &postgresql.TaskerScheduleRepository{CM: cm},
	}

	task := scheduler.WithSchedule("db maintenance", schedule.Monthly{Day: 1}, func(ctx context.Context) error {
		return nil
	})

	if err := task(context.Background()); err != nil {
		log.Println("ERROR", err.Error())
	}
}
Output:

type State

type State struct {
	ID        StateID `ext:"id"`
	Timestamp time.Time
}

type StateID added in v0.157.0

type StateID string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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