Skip to content
This repository has been archived by the owner on Sep 12, 2020. It is now read-only.
/ goalarm Public archive

Schedule task to be executed periodically or at specified time.

License

Notifications You must be signed in to change notification settings

kafji/goalarm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goalarm

Build Status codecov

Run job periodically or at specific time. Job is a function that accept context.Context and return interface{} and error. Job will be executed in different goroutine than the caller. Cancel periodically executed job using cancel function returned from context.WithCancel(context.Background()). For more use case take a look at its tests.

Installation

go get -u github.com/kafji/goalarm

Example

ctx := context.Background()

// Print "hello" in 10 seconds.
goalarm.In(ctx, 10*time.Second, func(ctx context.Context) (interface{}, error) {
	fmt.Println("hello")
	return nil, nil
})

// Print "hello" every 10 seconds.
goalarm.Every(ctx, 10*time.Second, 0, func(ctx context.Context) (interface{}, error) {
	fmt.Println("hello")
	return nil, nil
})

Development

Run test

go test $(go list ./... | grep -v /vendor/)

About

Schedule task to be executed periodically or at specified time.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages