simplecron

package module
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: MIT Imports: 1 Imported by: 2

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
}

image

🌐 Telegram канал

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

This section is empty.

Types ΒΆ

type CronCallback ΒΆ

type CronCallback func()

CronCallback - cron callback /α ο½‘β€Έο½‘αŸ\

type CronObject ΒΆ

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

CronObject - cron object /α ο½‘β€Έο½‘αŸ\

func NewCronHandler ΒΆ

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

NewCronHandler - create new cron

func (*CronObject) IsActive ΒΆ added in v1.5.0

func (c *CronObject) IsActive() bool

IsActive - check cron is not paused & is not stopped

func (*CronObject) IsPaused ΒΆ added in v1.4.0

func (c *CronObject) IsPaused() bool

IsPaused - check cron is paused status

func (*CronObject) Pause ΒΆ

func (c *CronObject) Pause()

Pause cron event exec

func (*CronObject) Resume ΒΆ

func (c *CronObject) Resume()

Resume cron event exec

func (*CronObject) Run ΒΆ

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

Run cron

func (*CronObject) Stop ΒΆ

func (c *CronObject) Stop()

Stop cron

type RunTimeLimitHandler ΒΆ added in v1.1.2

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

RunTimeLimitHandler - func runtime limit handler

func NewRuntimeLimitHandler ΒΆ added in v1.1.2

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

NewRuntimeLimitHandler - create new func runtime limit handler

func (*RunTimeLimitHandler) Run ΒΆ added in v1.1.2

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