// Receive a result, or timeout in 1 second
425862
func (adaptor Adapter) Receive() []*api.RunnerResult {
	params := &sqs.ReceiveMessageInput{
		QueueUrl:            aws.String(adaptor.QueueURL),
		MaxNumberOfMessages: aws.Int64(10),
		VisibilityTimeout:   aws.Int64(1),
		WaitTimeSeconds:     aws.Int64(1),
	}
	resp, err := adaptor.Client.ReceiveMessage(params)

	if err != nil {
		fmt.Println(err.Error())
		return nil
	}

	if len(resp.Messages) == 0 {
		return nil
	}

	items := resp.Messages
	results := make([]*api.RunnerResult, 0)
	deleteEntries := make([]*sqs.DeleteMessageBatchRequestEntry, 0)
	for _, item := range items {
		result, jsonerr := resultFromJSON(*item.Body)
		if jsonerr != nil {
			fmt.Println(err.Error())
			return nil
		}
		deleteEntries = append(deleteEntries, &sqs.DeleteMessageBatchRequestEntry{
			Id:            aws.String(*item.MessageId),
			ReceiptHandle: aws.String(*item.ReceiptHandle),
		})
		results = append(results, result)
	}

	deleteParams := &sqs.DeleteMessageBatchInput{
		Entries:  deleteEntries,
		QueueUrl: aws.String(adaptor.QueueURL),
	}
	_, delerr := adaptor.Client.DeleteMessageBatch(deleteParams)

	if delerr != nil {
		fmt.Println(delerr.Error())
		return nil
	}

	return results
}
681065
func (s *SnapshotVerifyRepositoryService) Timeout(timeout string) *SnapshotVerifyRepositoryService {
	s.timeout = timeout
	return s
}
567239
func (t Result) Time() time.Time {
	res, _ := time.Parse(time.RFC3339, t.String())
	return res
}
1079801
func (c *Client) Result(req *Request, resp interface{}) error {
	result, err := c.Do(req)
	if err != nil {
		return err
	}
	return unmarshal(result, resp)
}
143209
func (s *CreateIndexService) Timeout(timeout string) *CreateIndexService {
	s.timeout = timeout
	return s
}
818698
func (c Client) Receive(filename string, mode string) (io.WriterTo, error) {
	conn, err := net.ListenUDP("udp", &net.UDPAddr{})
	if err != nil {
		return nil, err
	}
	if c.timeout == 0 {
		c.timeout = defaultTimeout
	}
	r := &receiver{
		send:     make([]byte, datagramLength),
		receive:  make([]byte, datagramLength),
		conn:     &connConnection{conn: conn},
		retry:    &backoff{handler: c.backoff},
		timeout:  c.timeout,
		retries:  c.retries,
		addr:     c.addr,
		autoTerm: true,
		block:    1,
		mode:     mode,
	}
	if c.blksize != 0 || c.tsize {
		r.opts = make(options)
	}
	if c.blksize != 0 {
		r.opts["blksize"] = strconv.Itoa(c.blksize)
		// Clean it up so we don't send options twice
		defer func() { delete(r.opts, "blksize") }()
	}
	if c.tsize {
		r.opts["tsize"] = "0"
	}
	n := packRQ(r.send, opRRQ, filename, mode, r.opts)
	l, addr, err := r.receiveWithRetry(n)
	if err != nil {
		return nil, err
	}
	r.l = l
	r.addr = addr
	return r, nil
}
6036
func (dt *dynamicTimeout) Timeout() time.Duration {
	return time.Duration(atomic.LoadInt64(&dt.timeout))
}
698340
func (r FutureGetMempoolEntryResult) Receive() (*btcjson.GetMempoolEntryResult, error) {
	res, err := receiveFuture(r)
	if err != nil {
		return nil, err
	}

	// Unmarshal the result as an array of strings.
	var mempoolEntryResult btcjson.GetMempoolEntryResult
	err = json.Unmarshal(res, &mempoolEntryResult)
	if err != nil {
		return nil, err
	}

	return &mempoolEntryResult, nil
}
1249125
func (s *PutScriptService) Timeout(timeout string) *PutScriptService {
	s.timeout = timeout
	return s
}
745359
func (r FutureDecodeScriptResult) Receive() (*btcjson.DecodeScriptResult, error) {
	res, err := receiveFuture(r)
	if err != nil {
		return nil, err
	}

	// Unmarshal result as a decodescript result object.
	var decodeScriptResult btcjson.DecodeScriptResult
	err = json.Unmarshal(res, &decodeScriptResult)
	if err != nil {
		return nil, err
	}

	return &decodeScriptResult, nil
}
1252965
func (f Future) GetResult(sender autorest.Sender) (*http.Response, error) {
	if f.pt.finalGetURL() == "" {
		// we can end up in this situation if the async operation returns a 200
		// with no polling URLs.  in that case return the response which should
		// contain the JSON payload (only do this for successful terminal cases).
		if lr := f.pt.latestResponse(); lr != nil && f.pt.hasSucceeded() {
			return lr, nil
		}
		return nil, autorest.NewError("Future", "GetResult", "missing URL for retrieving result")
	}
	req, err := http.NewRequest(http.MethodGet, f.pt.finalGetURL(), nil)
	if err != nil {
		return nil, err
	}
	return sender.Do(req)
}
842674
func (c *BaseConn) Receive() (packet.Generic, error) {
	c.rMutex.Lock()
	defer c.rMutex.Unlock()

	// read next packet
	pkt, err := c.stream.Read()
	if err != nil {
		// ensure connection gets closed
		_ = c.carrier.Close()

		return nil, err
	}

	// reset timeout
	err = c.resetTimeout()
	if err != nil {
		return nil, err
	}

	return pkt, nil
}
959732
func (r FutureGetWork) Receive() (*btcjson.GetWorkResult, error) {
	res, err := receiveFuture(r)
	if err != nil {
		return nil, err
	}

	// Unmarshal result as a getwork result object.
	var result btcjson.GetWorkResult
	err = json.Unmarshal(res, &result)
	if err != nil {
		return nil, err
	}

	return &result, nil
}
20843
func (c *conn) Receive() ([]Message, error) {
	b := make([]byte, os.Getpagesize())
	for {
		// Peek at the buffer to see how many bytes are available.
		//
		// TODO(mdlayher): deal with OOB message data if available, such as
		// when PacketInfo ConnOption is true.
		n, _, _, _, err := c.s.Recvmsg(b, nil, unix.MSG_PEEK)
		if err != nil {
			return nil, os.NewSyscallError("recvmsg", err)
		}

		// Break when we can read all messages
		if n < len(b) {
			break
		}

		// Double in size if not enough bytes
		b = make([]byte, len(b)*2)
	}

	// Read out all available messages
	n, _, _, _, err := c.s.Recvmsg(b, nil, 0)
	if err != nil {
		return nil, os.NewSyscallError("recvmsg", err)
	}

	n = nlmsgAlign(n)

	raw, err := syscall.ParseNetlinkMessage(b[:n])
	if err != nil {
		return nil, err
	}

	msgs := make([]Message, 0, len(raw))
	for _, r := range raw {
		m := Message{
			Header: sysToHeader(r.Header),
			Data:   r.Data,
		}

		msgs = append(msgs, m)
	}

	return msgs, nil
}
609769
func (r FutureGetGenerateResult) Receive() (bool, error) {
	res, err := receiveFuture(r)
	if err != nil {
		return false, err
	}

	// Unmarshal result as a boolean.
	var result bool
	err = json.Unmarshal(res, &result)
	if err != nil {
		return false, err
	}

	return result, nil
}
1093587
func (r FutureDumpPrivKeyResult) Receive() (*btcutil.WIF, error) {
	res, err := receiveFuture(r)
	if err != nil {
		return nil, err
	}

	// Unmarshal result as a string.
	var privKeyWIF string
	err = json.Unmarshal(res, &privKeyWIF)
	if err != nil {
		return nil, err
	}

	return btcutil.DecodeWIF(privKeyWIF)
}
713712
func ReceiveMessage(config *Config, topic string, qos packet.QOS, timeout time.Duration) (*packet.Message, error) {
	// create client
	client := New()

	// connect to broker
	future, err := client.Connect(config)
	if err != nil {
		return nil, err
	}

	// wait for future
	err = future.Wait(timeout)
	if err != nil {
		return nil, err
	}

	// create channel
	msgCh := make(chan *packet.Message)
	errCh := make(chan error)

	// set callback
	client.Callback = func(msg *packet.Message, err error) error {
		if err != nil {
			errCh <- err
			return nil
		}

		msgCh <- msg
		return nil
	}

	// make subscription
	subscribeFuture, err := client.Subscribe(topic, qos)
	if err != nil {
		return nil, err
	}

	// wait for future
	err = subscribeFuture.Wait(timeout)
	if err != nil {
		return nil, err
	}

	// prepare message
	var msg *packet.Message

	// wait for error, message or timeout
	select {
	case err = <-errCh:
		return nil, err
	case msg = <-msgCh:
	case <-time.After(timeout):
	}

	// disconnect
	err = client.Disconnect()
	if err != nil {
		return nil, err
	}

	return msg, nil
}