gocron

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 3 Imported by: 0

README

simple-cron

Library to run func by cron. Also to limit func runtime. Written in Golang

usage example
var myfunc = func() {
	// func example
	time.Sleep(time.Second * 10)
}

isTimeIsUP := simplecron.NewRuntimeLimitHandler(
	time.Second * 2,
	myfunc,
).Run()
if isTimeIsUP {
	// handle timeout
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CronObject

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

func NewCronHandler

func NewCronHandler(callback func(), timerTime time.Duration) *CronObject

func (*CronObject) IsActive

func (c *CronObject) IsActive() bool

func (*CronObject) IsPaused

func (c *CronObject) IsPaused() bool

func (*CronObject) Pause

func (c *CronObject) Pause()

func (*CronObject) Resume

func (c *CronObject) Resume()

func (*CronObject) Run

func (c *CronObject) Run(immediately ...bool)

func (*CronObject) Stop

func (c *CronObject) Stop()

type RunTimeLimitHandler

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

RunTimeLimitHandler - func runtime limit handler

func NewRuntimeLimitHandler

func NewRuntimeLimitHandler(timeout time.Duration, runFunc func()) *RunTimeLimitHandler

NewRuntimeLimitHandler - create new func runtime limit handler

func (*RunTimeLimitHandler) Run

func (r *RunTimeLimitHandler) Run() bool

Run - run func & limit runtime. returns: bool: true if time is up

Jump to

Keyboard shortcuts

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