litecron

package module
v0.0.0-...-9034e69 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2018 License: MIT Imports: 8 Imported by: 0

README

LiteCron


What's LiteCron

LiteCron is a In-Processing distributed cron job processor. its easy to handle you cron job into you web app. you don't need any special machine for run cron job.

UseCase

  • running cron job into my web app.
  • build a distributed cron job service(for replace system cron service).

UseAge

//Step 1: init default cron client.
	litecron.InitDefaultCron(&litecron.MutexConfig{
		RedisConfig:&litecron.RedisConfig{
			DNS:"127.0.0.1:6379",
		},
		Prefix:"litecron/examples/defaults/",
		Factor:0.01,
	})
	//Register a cron job for every 2 seconds.
	litecron.Register("@every 2s",exampleHandle)
	go litecron.Run()
	time.Sleep(10 * time.Second)
	// Output:

Examples

  1. default cron client
  2. without default cron client
  3. mock multi processor

Deps & Thanks

Documentation

Index

Constants

View Source
const (
	DefaultMutexPrefix = "litecron/defaults"
	DefaultMutexFator  = 0.05
)

Variables

This section is empty.

Functions

func Register

func Register(c string, f handle)

func Run

func Run()

Types

type Cron

type Cron struct {
	MutexConfig *MutexConfig
	// contains filtered or unexported fields
}

func InitDefaultCron

func InitDefaultCron(config *MutexConfig) *Cron

func NewCron

func NewCron(config *MutexConfig) *Cron

func (*Cron) Register

func (c *Cron) Register(cronScheue string, h handle)

func (*Cron) Run

func (c *Cron) Run()

type Handler

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

type MutexConfig

type MutexConfig struct {
	RedisConfig *RedisConfig
	Prefix      string
	Factor      float64
}

type RedisConfig

type RedisConfig struct {
	DNS string
}

Jump to

Keyboard shortcuts

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