file

package
v0.0.0-...-efbc44a Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: GPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package file is the FILE_CHECK health check: a real server's health follows the number in a tracked file.

It is not a check in the sense the others are. Nothing is probed, nothing is scheduled, and there is no retry: an external agent writes a number and the verdict follows it immediately. C reflects that by queueing the checker with a nil thread function and pre-setting two fields (check_file.c:157-166):

current_checker->has_run = true;   /* there is no concept of running */
current_checker->alpha  = false;   /* the state is known immediately */

Alpha mode is cleared because its purpose — suppress the first notification, since the initial "down" was an assumption — does not apply when the initial state was read from the file rather than assumed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker struct {
	// TrackFile is the track_file name this check follows.
	TrackFile string
	// RealServer identifies the backend whose weight this drives.
	RealServer string

	// Weight is the multiplier applied to the file's value. Zero makes the
	// check a plain up/down: any non-zero value is a fault.
	Weight int
	// Reverse inverts the sense, from `weight <n> reverse`.
	Reverse bool
	// contains filtered or unexported fields
}

Checker binds one real server to one tracked file.

func (*Checker) Status

func (c *Checker) Status() int

Status is the weight contribution the current file value produces.

func (*Checker) String

func (c *Checker) String() string

func (*Checker) Up

func (c *Checker) Up() bool

Up reports whether the backend is usable.

Fault is a distinct state from "weight zero": a real server contributing zero weight is still in the IPVS table and still receiving no traffic, whereas one in fault has been taken down. They coincide for an unweighted checker and diverge for a weighted one, where a value of zero is a legitimate healthy contribution of nothing.

func (*Checker) Update

func (c *Checker) Update(value int64) Transition

Update applies a new file value and returns the transition (process_update_checker_track_file_status, track_file.c:737-772).

The three cases C distinguishes are kept distinct here because they call for different actions: entering fault takes the server down and zeroes its contribution, leaving fault brings it back with the new contribution, and anything else is a weight adjustment on a server that stays up.

func (*Checker) Value

func (c *Checker) Value() (int64, bool)

Value returns the last value applied.

type Transition

type Transition struct {
	// From and To are the weight contributions before and after.
	From, To int
	// WeightDelta is what to add to the real server's effective weight.
	// It is a delta rather than an absolute because C applies it that way
	// (`checker->rs->effective_weight + new_status - previous_status`,
	// track_file.c:771) and several trackers can drive one server.
	WeightDelta int
	// EnteredFault and LeftFault report the up/down edges. Exactly one can
	// be true, and both are false for a weight change within the up state.
	EnteredFault bool
	LeftFault    bool
	// Changed reports whether anything happened at all.
	Changed bool
}

Transition is the effect of a new file value.

Jump to

Keyboard shortcuts

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