Documentation
¶
Overview ¶
Package ossignal provides a Task that listens for signals from the operating system. Signal capture begins at NewTask construction time.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultSignals ¶
DefaultSignals returns the os signals that will cause this task to exit.
Types ¶
type Option ¶
type Option func(options *options)
Option is an option func for NewTask.
func WithLogger ¶
WithLogger sets the logger to be used.
func WithOnSignal ¶
WithOnSignal sets a callback that is invoked after the signal is logged.
func WithSignalLogLevel ¶
WithSignalLogLevel sets the log level used when an OS signal is received.
func WithSignals ¶
WithSignals overrides the default signals being listened for.
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task is a task.Task that waits for a termination signal from the OS.
func NewTask ¶
NewTask creates a new Task. Signal capture begins immediately upon construction. Panics if the resolved signals list is empty.
Example ¶
ExampleNewTask demonstrates creating an ossignal Task that listens for the default termination signals (SIGINT, SIGTERM, SIGQUIT).
package main
import (
"log/slog"
"github.com/wood-jp/task/ossignal"
)
func main() {
t := ossignal.NewTask(
ossignal.WithLogger(slog.Default()),
)
_ = t
}
Output: