Documentation
¶
Index ¶
Constants ¶
const DefaultRetention = 3 * 24 * time.Hour // 3 days
Variables ¶
This section is empty.
Functions ¶
func AggregateSuggestedActions ¶ added in v0.6.0
func AggregateSuggestedActions(allActions []*apiv1.SuggestedActions) *apiv1.SuggestedActions
AggregateSuggestedActions combines multiple suggested actions with priority rules. If any action suggests HW_INSPECTION, that takes priority over SYSTEM_REBOOT. This allows components to evaluate multiple failure types and get a single recommendation.
func EvaluateSuggestedActions ¶ added in v0.6.0
func EvaluateSuggestedActions( rebootEvents Events, failureEvents Events, maxRebootsBeforeInspection int, ) *apiv1.SuggestedActions
EvaluateSuggestedActions evaluates repair actions based on reboot history and failure events. It returns health state and suggested actions.
The logic follows these rules: - If no failure events: panic (should never happen) - If the first reboot happened after the first failure: return nil (reboot may have fixed the issue) - If no reboots: suggest reboot - If only 1 reboot or 1 failure event: suggest reboot - Otherwise, count "reboot → failure" sequences (failures that occurred after reboots) - If reboot→failure sequences >= maxRebootsBeforeInspection: suggest hardware inspection - Otherwise: suggest reboot
The function analyzes sequences where a failure occurs AFTER a reboot, indicating that the reboot did not resolve the issue.
Parameters:
- rebootEvents: Historical reboot events
- failureEvents: Slice of failure events to evaluate (must not be empty, will panic if empty)
- maxRebootsBeforeInspection: Threshold for reboot→failure sequences before suggesting hardware inspection (typically 2)
Returns:
- health: Health state (always Unhealthy when failures exist)
- suggestedActions: Suggested repair actions (REBOOT, HW_INSPECTION, or nil)
Types ¶
type Bucket ¶
type Bucket interface {
Name() string
Insert(ctx context.Context, ev Event) error
// Find returns nil if the event is not found.
Find(ctx context.Context, ev Event) (*Event, error)
// Get queries the event in the descending order of timestamp (latest event first).
Get(ctx context.Context, since time.Time) (Events, error)
// Latest queries the latest event, returns nil if no event found.
Latest(ctx context.Context) (*Event, error)
Purge(ctx context.Context, beforeTimestamp int64) (int, error)
Close()
}
type Event ¶ added in v0.5.0
type Event struct {
// Component represents which component generated the event.
Component string
// Time represents when the event happened
Time time.Time
// Name represents the name of the event.
Name string
// Type represents the type of the event.
Type string
// Message represents the detailed message of the event.
Message string
// ExtraInfo represents the extra information of the event.
ExtraInfo map[string]string
}
Event represents an entry in the event store.