// Return schedule interval(s) up to the number specified
182487
func (c *Client) IntervalsWithLimit(limit int) (intervals []contract.Interval, err error) {
	conn := c.Pool.Get()
	defer conn.Close()

	objects, err := getObjectsByRange(conn, models.IntervalKey, 0, limit-1)
	if err != nil {
		if err != redis.ErrNil {
			return intervals, err
		}
	}

	intervals = make([]contract.Interval, len(objects))
	for i, object := range objects {
		err = json.Unmarshal(object, &intervals[i])
		if err != nil {
			return []contract.Interval{}, err
		}
	}

	return intervals, nil
}
388443
func Interval(duration time.Duration) Expression {
	negative := false
	if duration < 0 {
		negative = true
		duration = -duration
	}
	return &intervalExpression{
		duration: duration,
		negative: negative,
	}
}
422555
func loadSupportSchedulerDBInformation() error {

	receivedIntervals, err := getSchedulerDBIntervals()
	if err != nil {
		LoggingClient.Error("failed to receive intervals from support-scheduler database:" + err.Error())
		return err
	}

	err = addReceivedIntervals(receivedIntervals)
	if err != nil {
		LoggingClient.Error("failed to add received intervals from support-scheduler database:" + err.Error())
		return err
	}

	intervalActions, err := getSchedulerDBIntervalActions()
	if err != nil {
		LoggingClient.Error("failed to receive interval actions from support-scheduler database:" + err.Error())
		return err
	}

	err = addReceivedIntervalActions(intervalActions)
	if err != nil {
		LoggingClient.Error("failed to add received interval actions from support-scheduler database:" + err.Error())
		return err
	}

	return nil
}
934443
func (cli *OpsGenieClient) ScheduleOverride() (*OpsGenieScheduleOverrideClient, error) {
	cli.makeHTTPTransportSettings()

	scheduleOverrideClient := new(OpsGenieScheduleOverrideClient)
	scheduleOverrideClient.SetOpsGenieClient(*cli)

	if cli.opsGenieAPIURL == "" {
		scheduleOverrideClient.SetOpsGenieAPIUrl(endpointURL)
	}

	return scheduleOverrideClient, nil
}
605675
func (r *Run) ScheduledForTime() (time.Time, error) {
	return time.Parse(time.RFC3339, r.ScheduledFor)
}
1340127
func (m *MockInterface) Scheduling() v1beta110.SchedulingV1beta1Interface {
	ret := m.ctrl.Call(m, "Scheduling")
	ret0, _ := ret[0].(v1beta110.SchedulingV1beta1Interface)
	return ret0
}
619353
func (sched *Scheduler) schedule(pod *v1.Pod) (core.ScheduleResult, error) {
	result, err := sched.config.Algorithm.Schedule(pod, sched.config.NodeLister)
	if err != nil {
		pod = pod.DeepCopy()
		sched.recordSchedulingFailure(pod, err, v1.PodReasonUnschedulable, err.Error())
		return core.ScheduleResult{}, err
	}
	return result, err
}
131614
func ScheduleUnmarshalJSON(b []byte) (schedule Schedule, err error) {
	var mixed interface{}
	json.Unmarshal(b, &mixed)

	for key, value := range mixed.(map[string]interface{}) {
		rawValue, _ := json.Marshal(value)
		switch key {
		case "date":
			var date Date
			err = json.Unmarshal(rawValue, &date)
			schedule = date
		case "day":
			var day Day
			err = json.Unmarshal(rawValue, &day)
			schedule = day
		case "intersection":
			var intersection Intersection
			err = json.Unmarshal(rawValue, &intersection)
			schedule = intersection
		case "month":
			var month Month
			err = json.Unmarshal(rawValue, &month)
			schedule = month
		case "union":
			var union Union
			err = json.Unmarshal(rawValue, &union)
			schedule = union
		case "week":
			var week Week
			err = json.Unmarshal(rawValue, &week)
			schedule = week
		case "weekday":
			var weekday Weekday
			err = json.Unmarshal(rawValue, &weekday)
			schedule = weekday
		case "year":
			var year Year
			err = json.Unmarshal(rawValue, &year)
			schedule = year
		default:
			err = fmt.Errorf("%s is not a recognized schedule", key)
		}
	}
	return
}
1268600
func (g *GoroutinePool) Schedule(job, onCanceled func()) {
	g.wg.Add(1)
	// Note: We could save a bit of memory by preallocating maxConcurrentJobs
	// goroutines instead of one goroutine per item.
	go func() {
		defer g.wg.Done()
		if g.sema.wait(g.ctx) == nil {
			defer g.sema.signal()
			job()
		} else if onCanceled != nil {
			onCanceled()
		}
	}()
}
798463
func (c Client) Get(id string, params *stripe.SubscriptionScheduleRevisionParams) (*stripe.SubscriptionScheduleRevision, error) {
	if params == nil {
		return nil, fmt.Errorf("params cannot be nil")
	}
	if params.Schedule == nil {
		return nil, fmt.Errorf("params.Schedule must be set")
	}

	path := stripe.FormatURLPath("/v1/subscription_schedules/%s/revisions/%s",
		stripe.StringValue(params.Schedule), id)
	rev := &stripe.SubscriptionScheduleRevision{}
	err := c.B.Call(http.MethodGet, path, c.Key, params, rev)
	return rev, err
}
987670
func (f DateHistogramFacet) Interval(interval string) DateHistogramFacet {
	f.interval = interval
	return f
}
720149
func (_m *DBClient) Intervals() ([]models.Interval, error) {
	ret := _m.Called()

	var r0 []models.Interval
	if rf, ok := ret.Get(0).(func() []models.Interval); ok {
		r0 = rf()
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]models.Interval)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func() error); ok {
		r1 = rf()
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
452167
func (t *TimeoutWheel) Schedule(
	d time.Duration,
	expireCb func(interface{}),
	arg interface{},
) (Timeout, error) {
	dTicks := (d + t.tickInterval - 1) / t.tickInterval
	deadline := atomic.LoadUint64(&t.ticks) + uint64(dTicks)
	timeout := t.getTimeoutLocked(deadline)

	if t.state != running {
		t.putTimeoutLocked(timeout)
		timeout.mtx.Unlock()
		return Timeout{}, ErrSystemStopped
	}

	bucket := &t.buckets[deadline&t.bucketMask]
	timeout.expireCb = expireCb
	timeout.expireArg = arg
	timeout.deadline = deadline
	timeout.state = timeoutActive
	out := Timeout{timeout: timeout, generation: timeout.generation}

	// execute the callback now, return a Timeout that is already Stopped (generation is bumped)
	if bucket.lastTick >= deadline {
		t.putTimeoutLocked(timeout)
		timeout.mtx.Unlock()
		expireCb(arg)
		return out, nil
	}

	timeout.prependLocked(bucket)
	timeout.mtx.Unlock()
	return out, nil
}
549676
func (c *clusterClient) SchedPolicyEnumerate() ([]*sched.SchedPolicy, error) {
	var schedPolicies []*sched.SchedPolicy
	req := c.c.Get().Resource(clusterPath + SchedPath)

	if err := req.Do().Unmarshal(&schedPolicies); err != nil {
		return nil, err
	}

	return schedPolicies, nil
}
626882
func addIntervalToSchedulerDB(interval contract.Interval) (string, error) {

	var err error
	var id string

	id, err = dbClient.AddInterval(interval)
	if err != nil {
		LoggingClient.Error("problem trying to add interval to support-scheduler service:" + err.Error())
		return "", err
	}
	interval.ID = id

	LoggingClient.Info("added interval to the support-scheduler database", "name", interval.Name, "id", ID)

	return id, nil
}
603978
func (s *schedule) Sync(timestamp uint32) {
	atomic.StoreInt64(&s.offset, time.Now().UnixNano()-int64(timestamp)*1000)
}
1325837
func (mc MongoClient) Intervals() ([]contract.Interval, error) {
	return mapIntervals(mc.getIntervals(bson.M{}))
}