Documentation
¶
Overview ¶
Package tickermod provides ticker functionality as a module.
Index ¶
Examples ¶
Constants ¶
View Source
const ( ErrMissingInterval = errStr("interval not set") ErrMissingTickFunc = errStr("tick function not set") )
View Source
const ID = "tickermod"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Opt ¶
type Ticker ¶
type Ticker struct {
// contains filtered or unexported fields
}
func New ¶
New creates ticker with given options. WithInterval and WithFunc options are mandatory.
Example ¶
package main
import (
"errors"
"log/slog"
"time"
"github.com/go-srvc/mods/tickermod"
"github.com/go-srvc/srvc"
)
func main() {
srvc.RunAndExit(
tickermod.New(
tickermod.WithInterval(time.Second),
tickermod.WithFunc(func() error {
slog.Info("Hello from ticker")
return errors.New("ticker error")
}),
),
)
}
Output:
Click to show internal directories.
Click to hide internal directories.