cron

package
v0.0.38 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2018 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtendLock added in v0.0.5

func ExtendLock(rc redis.Conn, key string, value string, expiration int) error

ExtendLock extends our lock expiration by the passed in number of seconds

func GrabLock

func GrabLock(rc redis.Conn, key string, value string, expiration int) (bool, error)

GrabLock grabs the passed in lock from redis in an atomic operation. It returns whether the lock was available and acquired

func ReleaseLock

func ReleaseLock(rc redis.Conn, key string, value string) error

ReleaseLock releases the passed in lock, returning any error encountered while doing so. It is not considered an error to release a lock that is no longer present

func StartCron added in v0.0.5

func StartCron(quit chan bool, rp *redis.Pool, name string, interval time.Duration, cronFunc Function)

StartCron calls the passed in function every minute, making sure it acquires a lock so that only one process is running at once. Note that across processes crons may be called more often than duration as there is no inter-process coordination of cron fires. (this might be a worthy addition)

Types

type Function

type Function func(lockName string, lockValue string) error

Function is the function that will be called on our schedule

Jump to

Keyboard shortcuts

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