rule

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultInterval = 1 * time.Minute
View Source
const DefaultIntervalStr = "1min"

Variables

This section is empty.

Functions

func DefaultIntervalForType added in v0.10.6

func DefaultIntervalForType(ruleType string) time.Duration

DefaultIntervalForType returns the default polling interval for the given rule type.

func DefaultIntervalStrForType added in v0.10.6

func DefaultIntervalStrForType(ruleType string) string

DefaultIntervalStrForType returns the default polling interval string for the given rule type.

func GenerateID

func GenerateID(typ, repo string, number int, conditions, until []string, maxCount int, ignoreUsers []string) string

func SplitRepo

func SplitRepo(repo string) (string, string)

Types

type WatchRule

type WatchRule struct {
	ID              string            `json:"id"`
	Type            string            `json:"type"` // "pr", "issue", "discussion", "workflow"
	Repo            string            `json:"repo"` // "owner/repo"
	Number          int               `json:"number"`
	Conditions      []string          `json:"conditions"`        // OR evaluation
	Actions         []string          `json:"actions,omitempty"` // e.g. ["open"], ["notify"], ["open","notify"]
	URL             string            `json:"url"`
	CreatedAt       time.Time         `json:"created_at"`
	Status          string            `json:"status"`              // "watching", "triggered", "stopped"
	Until           []string          `json:"until,omitempty"`     // termination conditions (any match ends the rule)
	MaxCount        int               `json:"max_count,omitempty"` // 0=unlimited, N=end after N triggers
	TriggerCount    int               `json:"trigger_count"`       // current trigger count
	LastCheckedAt   time.Time         `json:"last_checked_at,omitzero"`
	LastTriggeredAt time.Time         `json:"last_triggered_at,omitzero"`
	Interval        string            `json:"interval,omitempty"`      // polling interval (e.g., "30sec", "5min", "1h")
	IgnoreUsers     []string          `json:"ignore_users,omitempty"`  // regex patterns of users to ignore
	FiredStates     map[string]string `json:"fired_states,omitempty"`  // state-based condition dedup (condition -> stateKey)
	SeededStates    map[string]string `json:"seeded_states,omitempty"` // states recorded during seeding (first check)

	Seeding bool `json:"-"` // transient: when true, state-based conditions seed without triggering
	// contains filtered or unexported fields
}

func (*WatchRule) ClearFiredState added in v0.3.2

func (r *WatchRule) ClearFiredState(condition string)

ClearFiredState removes a condition from fired states (e.g., state reverted).

func (*WatchRule) ClearSeededState added in v0.9.3

func (r *WatchRule) ClearSeededState(condition string)

ClearSeededState removes a condition from seeded states after it has been consumed.

func (*WatchRule) Clone added in v0.6.0

func (r *WatchRule) Clone() *WatchRule

Clone returns a deep copy of the rule. Compiled ignore-user regexps are shared (read-only) to avoid recompilation.

func (*WatchRule) CompiledIgnoreUsers added in v0.3.0

func (r *WatchRule) CompiledIgnoreUsers() []*regexp.Regexp

CompiledIgnoreUsers returns pre-compiled regexps for IgnoreUsers patterns. Invalid patterns are silently skipped (validated at rule creation time).

func (*WatchRule) HasFiredForState added in v0.3.2

func (r *WatchRule) HasFiredForState(condition, stateKey string) bool

HasFiredForState returns true if the condition has already fired with the given stateKey.

func (*WatchRule) IsOneShot

func (r *WatchRule) IsOneShot() bool

IsOneShot returns true if the rule should be removed after the first trigger (legacy behavior).

func (*WatchRule) IsSeededState added in v0.9.3

func (r *WatchRule) IsSeededState(condition, stateKey string) bool

IsSeededState returns true if the condition was seeded with the given stateKey.

func (*WatchRule) Label added in v0.9.0

func (r *WatchRule) Label() string

Label returns a human-readable short description of the rule target.

func (*WatchRule) PollInterval added in v0.2.0

func (r *WatchRule) PollInterval() time.Duration

PollInterval returns the rule's polling interval as time.Duration. Falls back to the type-specific default if not set or invalid.

func (*WatchRule) RecordFiredState added in v0.3.2

func (r *WatchRule) RecordFiredState(condition, stateKey string)

RecordFiredState marks a condition as fired with the given stateKey.

func (*WatchRule) RecordSeededState added in v0.9.3

func (r *WatchRule) RecordSeededState(condition, stateKey string)

RecordSeededState records a state observed during seeding (first check).

func (*WatchRule) SinceTime

func (r *WatchRule) SinceTime() time.Time

SinceTime returns the appropriate "since" time for comment checks. Uses LastCheckedAt if set (continuous watch), otherwise CreatedAt.

Jump to

Keyboard shortcuts

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