rule

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultInterval = 30 * time.Second
View Source
const DefaultIntervalStr = "30sec"

Variables

This section is empty.

Functions

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"
	Repo          string            `json:"repo"` // "owner/repo"
	Number        int               `json:"number"`
	Conditions    []string          `json:"conditions"` // OR evaluation
	Action        string            `json:"action"`     // "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"`
	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)
	// 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) 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) 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 DefaultInterval 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) 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