mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	updating github.com/robfig/cron to v1.1.0
This commit is contained in:
		
							
								
								
									
										4
									
								
								vendor/github.com/robfig/cron/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/robfig/cron/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,2 +1,6 @@
 | 
			
		||||
[](http://godoc.org/github.com/robfig/cron) 
 | 
			
		||||
[](https://travis-ci.org/robfig/cron)
 | 
			
		||||
 | 
			
		||||
# cron
 | 
			
		||||
 | 
			
		||||
Documentation here: https://godoc.org/github.com/robfig/cron
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										68
									
								
								vendor/github.com/robfig/cron/cron.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										68
									
								
								vendor/github.com/robfig/cron/cron.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -165,11 +165,11 @@ func (c *Cron) runWithRecovery(j Job) {
 | 
			
		||||
	j.Run()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Run the scheduler.. this is private just due to the need to synchronize
 | 
			
		||||
// Run the scheduler. this is private just due to the need to synchronize
 | 
			
		||||
// access to the 'running' state variable.
 | 
			
		||||
func (c *Cron) run() {
 | 
			
		||||
	// Figure out the next activation times for each entry.
 | 
			
		||||
	now := time.Now().In(c.location)
 | 
			
		||||
	now := c.now()
 | 
			
		||||
	for _, entry := range c.entries {
 | 
			
		||||
		entry.Next = entry.Schedule.Next(now)
 | 
			
		||||
	}
 | 
			
		||||
@@ -178,45 +178,46 @@ func (c *Cron) run() {
 | 
			
		||||
		// Determine the next entry to run.
 | 
			
		||||
		sort.Sort(byTime(c.entries))
 | 
			
		||||
 | 
			
		||||
		var effective time.Time
 | 
			
		||||
		var timer *time.Timer
 | 
			
		||||
		if len(c.entries) == 0 || c.entries[0].Next.IsZero() {
 | 
			
		||||
			// If there are no entries yet, just sleep - it still handles new entries
 | 
			
		||||
			// and stop requests.
 | 
			
		||||
			effective = now.AddDate(10, 0, 0)
 | 
			
		||||
			timer = time.NewTimer(100000 * time.Hour)
 | 
			
		||||
		} else {
 | 
			
		||||
			effective = c.entries[0].Next
 | 
			
		||||
			timer = time.NewTimer(c.entries[0].Next.Sub(now))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		timer := time.NewTimer(effective.Sub(now))
 | 
			
		||||
		select {
 | 
			
		||||
		case now = <-timer.C:
 | 
			
		||||
			now = now.In(c.location)
 | 
			
		||||
			// Run every entry whose next time was this effective time.
 | 
			
		||||
			for _, e := range c.entries {
 | 
			
		||||
				if e.Next != effective {
 | 
			
		||||
					break
 | 
			
		||||
		for {
 | 
			
		||||
			select {
 | 
			
		||||
			case now = <-timer.C:
 | 
			
		||||
				now = now.In(c.location)
 | 
			
		||||
				// Run every entry whose next time was less than now
 | 
			
		||||
				for _, e := range c.entries {
 | 
			
		||||
					if e.Next.After(now) || e.Next.IsZero() {
 | 
			
		||||
						break
 | 
			
		||||
					}
 | 
			
		||||
					go c.runWithRecovery(e.Job)
 | 
			
		||||
					e.Prev = e.Next
 | 
			
		||||
					e.Next = e.Schedule.Next(now)
 | 
			
		||||
				}
 | 
			
		||||
				go c.runWithRecovery(e.Job)
 | 
			
		||||
				e.Prev = e.Next
 | 
			
		||||
				e.Next = e.Schedule.Next(now)
 | 
			
		||||
 | 
			
		||||
			case newEntry := <-c.add:
 | 
			
		||||
				timer.Stop()
 | 
			
		||||
				now = c.now()
 | 
			
		||||
				newEntry.Next = newEntry.Schedule.Next(now)
 | 
			
		||||
				c.entries = append(c.entries, newEntry)
 | 
			
		||||
 | 
			
		||||
			case <-c.snapshot:
 | 
			
		||||
				c.snapshot <- c.entrySnapshot()
 | 
			
		||||
				continue
 | 
			
		||||
 | 
			
		||||
			case <-c.stop:
 | 
			
		||||
				timer.Stop()
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
			continue
 | 
			
		||||
 | 
			
		||||
		case newEntry := <-c.add:
 | 
			
		||||
			c.entries = append(c.entries, newEntry)
 | 
			
		||||
			newEntry.Next = newEntry.Schedule.Next(time.Now().In(c.location))
 | 
			
		||||
 | 
			
		||||
		case <-c.snapshot:
 | 
			
		||||
			c.snapshot <- c.entrySnapshot()
 | 
			
		||||
 | 
			
		||||
		case <-c.stop:
 | 
			
		||||
			timer.Stop()
 | 
			
		||||
			return
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// 'now' should be updated after newEntry and snapshot cases.
 | 
			
		||||
		now = time.Now().In(c.location)
 | 
			
		||||
		timer.Stop()
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -251,3 +252,8 @@ func (c *Cron) entrySnapshot() []*Entry {
 | 
			
		||||
	}
 | 
			
		||||
	return entries
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// now returns current time in c location
 | 
			
		||||
func (c *Cron) now() time.Time {
 | 
			
		||||
	return time.Now().In(c.location)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								vendor/github.com/robfig/cron/doc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								vendor/github.com/robfig/cron/doc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -78,22 +78,22 @@ You may use one of several pre-defined schedules in place of a cron expression.
 | 
			
		||||
	-----                  | -----------                                | -------------
 | 
			
		||||
	@yearly (or @annually) | Run once a year, midnight, Jan. 1st        | 0 0 0 1 1 *
 | 
			
		||||
	@monthly               | Run once a month, midnight, first of month | 0 0 0 1 * *
 | 
			
		||||
	@weekly                | Run once a week, midnight on Sunday        | 0 0 0 * * 0
 | 
			
		||||
	@weekly                | Run once a week, midnight between Sat/Sun  | 0 0 0 * * 0
 | 
			
		||||
	@daily (or @midnight)  | Run once a day, midnight                   | 0 0 0 * * *
 | 
			
		||||
	@hourly                | Run once an hour, beginning of hour        | 0 0 * * * *
 | 
			
		||||
 | 
			
		||||
Intervals
 | 
			
		||||
 | 
			
		||||
You may also schedule a job to execute at fixed intervals.  This is supported by
 | 
			
		||||
formatting the cron spec like this:
 | 
			
		||||
You may also schedule a job to execute at fixed intervals, starting at the time it's added 
 | 
			
		||||
or cron is run. This is supported by formatting the cron spec like this:
 | 
			
		||||
 | 
			
		||||
    @every <duration>
 | 
			
		||||
 | 
			
		||||
where "duration" is a string accepted by time.ParseDuration
 | 
			
		||||
(http://golang.org/pkg/time/#ParseDuration).
 | 
			
		||||
 | 
			
		||||
For example, "@every 1h30m10s" would indicate a schedule that activates every
 | 
			
		||||
1 hour, 30 minutes, 10 seconds.
 | 
			
		||||
For example, "@every 1h30m10s" would indicate a schedule that activates after
 | 
			
		||||
1 hour, 30 minutes, 10 seconds, and then every interval after that.
 | 
			
		||||
 | 
			
		||||
Note: The interval does not take the job runtime into account.  For example,
 | 
			
		||||
if a job takes 3 minutes to run, and it is scheduled to run every 5 minutes,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user