// Get gets one job from any of the given queues, or times out if timeout has elapsed without a job being available.
// Returns a job or an error
166124
func (c *RedisClient) Get(timeout time.Duration, queues ...string) (Job, error) {

	ret, err := c.GetMulti(0, timeout, queues...)
	if err != nil {
		return Job{}, err
	}
	if ret == nil || len(ret) == 0 {
		return Job{}, errors.New("disque: no jobs returned")
	}
	return ret[0], nil

}
70215
func (client *Client) GetJob(jobURL JobURL) (Job, Warnings, error) {
	request, err := client.newHTTPRequest(requestOptions{URL: string(jobURL)})
	if err != nil {
		return Job{}, nil, err
	}

	var job Job
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &job,
	}

	err = client.connection.Make(request, &response)
	return job, response.Warnings, err
}
593953
func (client *Client) GetJob(jobGUID string) (Job, Warnings, error) {
	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.GetJobRequest,
		URIParams:   Params{"job_guid": jobGUID},
	})
	if err != nil {
		return Job{}, nil, err
	}

	var job Job
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &job,
	}

	err = client.connection.Make(request, &response)
	return job, response.Warnings, err
}
1216041
func (chainAsyncResult *ChainAsyncResult) Get(sleepDuration time.Duration) ([]reflect.Value, error) {
	if chainAsyncResult.backend == nil {
		return nil, ErrBackendNotConfigured
	}

	var (
		results []reflect.Value
		err     error
	)

	for _, asyncResult := range chainAsyncResult.asyncResults {
		results, err = asyncResult.Get(sleepDuration)
		if err != nil {
			return nil, err
		}
	}

	return results, err
}
973391
func (s *JobClient) Get(ctx context.Context, input *GetJobInput) (*GetJobOutput, error) {
	fullPath := path.Join("/", s.client.AccountName, "jobs", input.JobID, "live", "status")

	reqInput := client.RequestInput{
		Method: http.MethodGet,
		Path:   fullPath,
	}
	respBody, _, err := s.client.ExecuteRequestStorage(ctx, reqInput)
	if respBody != nil {
		defer respBody.Close()
	}
	if err != nil {
		return nil, errors.Wrap(err, "unable to get job")
	}

	job := &Job{}
	decoder := json.NewDecoder(respBody)
	if err = decoder.Decode(&job); err != nil {
		return nil, errors.Wrap(err, "unable to decode get job response")
	}

	return &GetJobOutput{
		Job: job,
	}, nil
}
330553
func (c *FakeCronJobs) Get(name string, options v1.GetOptions) (result *v1beta1.CronJob, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewGetAction(cronjobsResource, c.ns, name), &v1beta1.CronJob{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1beta1.CronJob), err
}
682818
func (d *Disque) Fetch(queueName string, timeout time.Duration) (job *Job, err error) {
	var jobs []*Job
	if jobs, err = d.FetchMultiple(queueName, 1, timeout); err == nil {
		if len(jobs) > 0 {
			job = jobs[0]
		}
	}
	return
}
733806
func (js *JobsService) Find(opt *JobFindOptions) ([]Job, *http.Response, error) {
	if opt != nil && !opt.IsValid() {
		return nil, nil, fmt.Errorf(
			"More than one value set in provided JobFindOptions instance",
		)
	}

	u, err := urlWithOptions("/jobs", opt)
	if err != nil {
		return nil, nil, err
	}

	req, err := js.client.NewRequest("GET", u, nil, nil)
	if err != nil {
		return nil, nil, err
	}

	var jobsResp findJobsResponse
	resp, err := js.client.Do(req, &jobsResp)
	if err != nil {
		return nil, resp, err
	}

	return jobsResp.Jobs, resp, err
}
934896
func (pool *WorkerPool) Queue(job func(), timeout ...time.Duration) bool {
	if pool.stopped() {
		return false
	}
	var t <-chan time.Time
	if len(timeout) > 0 && timeout[0] > 0 {
		t = time.After(timeout[0])
	}
	select {
	case pool.jobs <- job:
	case <-t:
		return false
	case <-pool.quit:
		return false
	}
	return true
}
107686
func (q *BytesQueue) Get(index int) ([]byte, error) {
	data, _, err := q.peek(index)
	return data, err
}
350972
func (job *QorJob) GetJob() *Job {
	if job.Job != nil {
		return job.Job
	}
	return nil
}
20361
func (jenkins *Jenkins) GetJobs() ([]Job, error) {
	var payload = struct {
		Jobs []Job `json:"jobs"`
	}{}
	err := jenkins.get("", nil, &payload)
	return payload.Jobs, err
}
254335
func (pool *Pool) Wait(job *Job) error {
	sess := pool.redis.Get()
	defer sess.Close()

	for {
		reply, err := sess.Do("SHOW", job.ID)
		if err != nil {
			return err
		}
		if reply == nil {
			break
		}

		time.Sleep(50 * time.Millisecond)
	}

	return nil
}
494152
func (s *Duration) Get() time.Duration {
	return time.Duration(atomic.LoadInt64(&s.currentVal))
}
572022
func (p *Pool) get() (Conn, error) {
	p.mu.Lock()

	if p.closed {
		p.mu.Unlock()
		return nil, errors.New("redigo: get on closed pool")
	}

	// Prune stale connections.

	if timeout := p.IdleTimeout; timeout > 0 {
		for i, n := 0, p.idle.Len(); i < n; i++ {
			e := p.idle.Back()
			if e == nil {
				break
			}
			ic := e.Value.(idleConn)
			if ic.t.Add(timeout).After(nowFunc()) {
				break
			}
			p.idle.Remove(e)
			p.active -= 1
			p.mu.Unlock()
			ic.c.Close()
			p.mu.Lock()
		}
	}

	// Get idle connection.

	for i, n := 0, p.idle.Len(); i < n; i++ {
		e := p.idle.Front()
		if e == nil {
			break
		}
		ic := e.Value.(idleConn)
		p.idle.Remove(e)
		test := p.TestOnBorrow
		p.mu.Unlock()
		if test == nil || test(ic.c, ic.t) == nil {
			return ic.c, nil
		}
		ic.c.Close()
		p.mu.Lock()
		p.active -= 1
	}

	if p.MaxActive > 0 && p.active >= p.MaxActive {
		p.mu.Unlock()
		return nil, ErrPoolExhausted
	}

	// No idle connection, create new.

	dial := p.Dial
	p.active += 1
	p.mu.Unlock()
	c, err := dial()
	if err != nil {
		p.mu.Lock()
		p.active -= 1
		p.mu.Unlock()
		c = nil
	}
	return c, err
}
515904
func Get() (u Uptime, err error) {
	err = u.Get()
	return u, err
}
1077387
func (p *Pool) Get(ctx context.Context) (conn *Disque, err error) {
	var r pools.Resource
	if r, err = p.pool.Get(ctx); err == nil && r != nil {
		conn = r.(*Disque)
	}
	return conn, err
}