Skip to content

Commit

Permalink
fix: export the expired field to allow proper trigger unmarshalling (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
reugn committed Mar 11, 2024
1 parent a90c2c9 commit 50c609c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions quartz/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (st *SimpleTrigger) Description() string {
// This type of Trigger can only be fired once and will expire immediately.
type RunOnceTrigger struct {
Delay time.Duration
expired bool
Expired bool
}

// Verify RunOnceTrigger satisfies the Trigger interface.
Expand All @@ -53,17 +53,16 @@ var _ Trigger = (*RunOnceTrigger)(nil)
// NewRunOnceTrigger returns a new RunOnceTrigger with the given delay time.
func NewRunOnceTrigger(delay time.Duration) *RunOnceTrigger {
return &RunOnceTrigger{
Delay: delay,
expired: false,
Delay: delay,
}
}

// NextFireTime returns the next time at which the RunOnceTrigger is scheduled to fire.
// Sets expired to true afterwards.
func (ot *RunOnceTrigger) NextFireTime(prev int64) (int64, error) {
if !ot.expired {
if !ot.Expired {
next := prev + ot.Delay.Nanoseconds()
ot.expired = true
ot.Expired = true
return next, nil
}

Expand All @@ -73,7 +72,7 @@ func (ot *RunOnceTrigger) NextFireTime(prev int64) (int64, error) {
// Description returns the description of the trigger.
func (ot *RunOnceTrigger) Description() string {
status := "valid"
if ot.expired {
if ot.Expired {
status = "expired"
}

Expand Down

0 comments on commit 50c609c

Please sign in to comment.