Documentation
¶
Index ¶
- Constants
- func DefaultIntervalForType(ruleType string) time.Duration
- func DefaultIntervalStrForType(ruleType string) string
- func GenerateID(typ, repo string, number int, conditions, until []string, maxCount int, ...) string
- func SplitRepo(repo string) (string, string)
- type WatchRule
- func (r *WatchRule) ClearFiredState(condition string)
- func (r *WatchRule) ClearSeededState(condition string)
- func (r *WatchRule) Clone() *WatchRule
- func (r *WatchRule) CompiledIgnoreUsers() []*regexp.Regexp
- func (r *WatchRule) HasFiredForState(condition, stateKey string) bool
- func (r *WatchRule) IsOneShot() bool
- func (r *WatchRule) IsSeededState(condition, stateKey string) bool
- func (r *WatchRule) Label() string
- func (r *WatchRule) PollInterval() time.Duration
- func (r *WatchRule) RecordFiredState(condition, stateKey string)
- func (r *WatchRule) RecordSeededState(condition, stateKey string)
- func (r *WatchRule) SinceTime() time.Time
Constants ¶
const DefaultInterval = 1 * time.Minute
const DefaultIntervalStr = "1min"
Variables ¶
This section is empty.
Functions ¶
func DefaultIntervalForType ¶ added in v0.10.6
DefaultIntervalForType returns the default polling interval for the given rule type.
func DefaultIntervalStrForType ¶ added in v0.10.6
DefaultIntervalStrForType returns the default polling interval string for the given rule type.
func GenerateID ¶
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
ClearFiredState removes a condition from fired states (e.g., state reverted).
func (*WatchRule) ClearSeededState ¶ added in v0.9.3
ClearSeededState removes a condition from seeded states after it has been consumed.
func (*WatchRule) Clone ¶ added in v0.6.0
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
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
HasFiredForState returns true if the condition has already fired with the given stateKey.
func (*WatchRule) IsOneShot ¶
IsOneShot returns true if the rule should be removed after the first trigger (legacy behavior).
func (*WatchRule) IsSeededState ¶ added in v0.9.3
IsSeededState returns true if the condition was seeded with the given stateKey.
func (*WatchRule) Label ¶ added in v0.9.0
Label returns a human-readable short description of the rule target.
func (*WatchRule) PollInterval ¶ added in v0.2.0
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
RecordFiredState marks a condition as fired with the given stateKey.
func (*WatchRule) RecordSeededState ¶ added in v0.9.3
RecordSeededState records a state observed during seeding (first check).