Skip to content

operation-hardcode/healthcheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: MIT

healthcheck

A zero-dependencies and lightweight go library for job scheduling.

Quick Start

package main

import (
	"github.com/operation-hardcode/healthcheck"
	"time"
)

func main() {
	worker := healthcheck.NewWorker()

	worker.AddJob(healthcheck.NewJob("1", time.Minute, func(job healthcheck.Job) { 
		// work here every minute.
		if something {
			 job.Cancel()
		}
	}))

	<-worker.Work() // waiting for signals.
}

Cancellation

package main

import (
	"github.com/operation-hardcode/healthcheck"
	"time"
)

func main() {
	worker := healthcheck.NewWorker()

	worker.AddJob(healthcheck.NewJob("1", time.Hour, func(job healthcheck.Job) { 
		// work here.
	}))

	worker.AddJob(healthcheck.NewJob("2", time.Minute, func(job healthcheck.Job) {
		// work here.
	}))

	worker.CancelJob("1") // cancel concrete job by its id.

	worker.CancelJobs() // or cancel all jobs.
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages