Skip to content

epazote/scheduler

Repository files navigation

Build Status Coverage Status Go Report Card

Calls a function every N time.Duration

Example

package main

import (
        "fmt"
        "time"

        "github.com/epazote/scheduler"
)

func main() {
        // Create new scheduler
        s := scheduler.New()

        every := time.Second
        // Add a scheduled function
        s.AddScheduler("every second", every, func() {
                fmt.Println("Second passed")
        })

        // Let scheduler run for five seconds
        time.Sleep(5 * time.Second)

        // Stop the scheduled "every second" function
        err := s.Stop("every second")
        if err != nil {
                panic(err)
        }

        // Scheduler has now stopped
        time.Sleep(5 * time.Second)
}

About

Calls a function every N seconds.

Resources

License

Stars

Watchers

Forks

Packages

No packages published