logedge

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MPL-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package logedge gates repetitive condition logs: emit on the edge (first sight or signature change), optionally a sparse pulse while the condition holds, and once more when it clears.

Use it for periodic probes that fail the same way on every tick. Callers still own the slog line; this package only answers whether to print and with what counters. It is not a logger and not a retry scheduler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event int

Event says why a Result should (or should not) be logged.

const (
	// Skip: same signature, pulse not due.
	Skip Event = iota
	// Rise: first observation, or the signature changed.
	Rise
	// Hold: same signature, Repeat elapsed since the last emission.
	Hold
	// Fall: Clear after a recorded condition.
	Fall
)

type Gate

type Gate struct {
	// Repeat is the minimum interval between Hold pulses. Zero disables them.
	Repeat time.Duration
	// contains filtered or unexported fields
}

Gate tracks per-key signatures. A zero Gate is ready to use (Repeat=0 means edge-only: Rise/Fall, never Hold).

func (*Gate) Clear

func (g *Gate) Clear(key string) Result

Clear drops key. Fall if it was tracked, otherwise Skip.

func (*Gate) Observe

func (g *Gate) Observe(key, sig string) Result

Observe records that key currently has signature sig.

type Result

type Result struct {
	Event Event
	// Streak is consecutive Observe hits for the current signature
	// (Fall: streak at the moment of Clear).
	Streak int
	Since  time.Time
	// Suppressed is how many Observe calls were skipped since the last
	// emission (Hold/Fall). Zero on Rise.
	Suppressed int
}

Result is the decision for one Observe or Clear call.

Jump to

Keyboard shortcuts

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