daemon

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunShell

func RunShell(sched *Controller, runner *Runner, filter t.Filter, in io.Reader, out io.Writer)

RunShell provides the interactive prompt when dockwatch is attached to a TTY. Input and output are injected so the shell can be driven in tests.

Types

type Config

type Config struct {
	Client            container.Client
	ScheduleSpec      string
	Cleanup           bool
	NoRestart         bool
	NoPull            bool
	MonitorOnly       bool
	EnableLabel       bool
	LifecycleHooks    bool
	RollingRestart    bool
	LabelPrecedence   bool
	Scope             string
	DisableContainers []string
	Timeout           time.Duration
}

Config is the resolved runtime configuration for a dockwatch run. It is a plain value with no package-level mutable state: build it once, hand it to New, and its validation rules live in one testable place.

func (Config) Validate

func (c Config) Validate() error

Validate reports configuration combinations that make a run illegal.

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller owns the cron schedule that drives periodic update scans. Each tick delegates to the Runner, which enforces the single-flight guard.

func NewController

func NewController(runner *Runner, filter t.Filter) *Controller

NewController returns a Controller that will run scans for filter via runner.

func (*Controller) Current

func (c *Controller) Current() string

Current returns the active cron spec.

func (*Controller) NextRun

func (c *Controller) NextRun() time.Time

NextRun returns the next scheduled run time, or the zero time if unscheduled.

func (*Controller) Set

func (c *Controller) Set(spec string) (time.Time, error)

Set installs (or replaces) the schedule and returns the next run time.

func (*Controller) Stop

func (c *Controller) Stop()

Stop halts the schedule.

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

Daemon owns the update run: the single-flight Runner and the schedule.

func New

func New(cfg Config) *Daemon

New builds a Daemon from a resolved Config.

func (*Daemon) Run

func (d *Daemon) Run(opts Options) error

Run executes the daemon according to opts and returns an error for any fatal condition. A nil error means a clean exit. It blocks until interrupted when running in periodic or interactive mode.

type Options

type Options struct {
	Filter           t.Filter
	FilterDesc       string
	RunOnce          bool
	EnableUpdateAPI  bool
	EnableMetricsAPI bool
	UnblockHTTPAPI   bool
	Interactive      bool
	NoStartupMessage bool
	APIToken         string
	In               io.Reader
	Out              io.Writer
}

Options describe a single invocation's run mode. They are the run-time knobs that come from the command line, separated from the resolved Config.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner executes container update scans and guarantees that only one scan runs at a time. It owns the single-flight guard that was previously hand-rolled as a `chan bool` in the scheduler, the shell and the HTTP API.

func NewRunner

func NewRunner(cfg Config) *Runner

NewRunner returns a Runner bound to cfg with no scan in flight.

func (*Runner) Run

func (r *Runner) Run(filter t.Filter) *metrics.Metric

Run blocks until the single-flight guard is free, runs a scan for filter, registers the scan metric and returns it. It returns nil without scanning when maxQueuedScans callers are already waiting.

func (*Runner) TryRun

func (r *Runner) TryRun(filter t.Filter) (*metrics.Metric, bool)

TryRun runs a scan only when no other scan is in flight. It returns the scan metric and whether it ran; a skipped run registers an empty scan.

func (*Runner) Wait

func (r *Runner) Wait()

Wait blocks until any in-flight scan has finished. Used at shutdown.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL