当前位置: 首页>>代码示例>>Golang>>正文


Golang sqs.Queue类代码示例

本文整理汇总了Golang中github.com/crowdmob/goamz/sqs.Queue的典型用法代码示例。如果您正苦于以下问题:Golang Queue类的具体用法?Golang Queue怎么用?Golang Queue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Queue类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: waitForMessages

func (l *SQSListener) waitForMessages(q *sqs.Queue) {
	msgResponse, err := q.ReceiveMessage(1)
	if err != nil || len(msgResponse.Messages) < 1 {
		time.Sleep(l.PollInterval)
		return
	}
	l.handle(&msgResponse.Messages[0], q)
}
开发者ID:hyandell,项目名称:aws_utils,代码行数:8,代码来源:listener.go

示例2: handle

func (l *SQSListener) handle(msg *sqs.Message, q *sqs.Queue) {
	err := l.Handler.Handle(msg)
	if err != nil {
		q.ChangeMessageVisibility(msg, 10)
		fmt.Println(err)
		return
	}
	_, err = q.DeleteMessage(msg)
	if err != nil {
		fmt.Println("unable to delete msg: ", err)
	}
}
开发者ID:hyandell,项目名称:aws_utils,代码行数:12,代码来源:listener.go

示例3: deleteFromQueueOnce

func deleteFromQueueOnce(q *sqs.Queue, del chan string, timeout time.Duration) error {
	batch := assembleDeleteMessageBatch(del, timeout)

	if len(batch) > 0 {
		log.Printf("deleting %d messages from q\n", len(batch))
		_, err := q.DeleteMessageBatch(batch)
		if err != nil {
			return err
		}
	}

	return nil
}
开发者ID:hayesgm,项目名称:queue,代码行数:13,代码来源:delete.go

示例4: readFromQueueOnce

func (r *SQSReader) readFromQueueOnce(q *sqs.Queue) error {
	r.Logger.Printf("%s: reading messages from queue\n", r.QueueName)
	results, err := q.ReceiveMessage(RECV_MAX_MESSAGES)
	if err != nil {
		return err
	}

	r.Logger.Printf("%s: read %d messages\n", r.QueueName, len(results.Messages))
	for _, message := range results.Messages {
		r.enqueueMessage(message.Body, message.ReceiptHandle)
	}

	return nil
}
开发者ID:hayesgm,项目名称:queue,代码行数:14,代码来源:reader.go

示例5: pushMessage

func pushMessage(q *sqs.Queue, message interface{}) error {

	j, err := json.Marshal(message)
	if err != nil {
		return err
	}

	_, err = q.SendMessage(string(j))
	if err != nil {
		return err
	}

	return nil
}
开发者ID:fun-alex-alex2006hw,项目名称:teamOFP,代码行数:14,代码来源:messaging.go

示例6: listenOnQueue

func listenOnQueue(q *sqs.Queue, ch chan *sqs.Message) {

	for {
		resp, err := q.ReceiveMessage(1)
		if err != nil {
			log.Panic(err)
		}

		for _, m := range resp.Messages {
			ch <- &m
			q.DeleteMessage(&m)
		}
	}

}
开发者ID:fun-alex-alex2006hw,项目名称:teamOFP,代码行数:15,代码来源:messaging.go

示例7: writeToQueueOnce

func (w *SQSWriter) writeToQueueOnce(q *sqs.Queue) error {
	batch, err := w.assembleSendMessageBatch()
	if err != nil {
		return err
	}

	if len(batch) > 0 {
		w.Logger.Printf("%s: sending %d messages to q\n", w.QueueName, len(batch))
		result, err := q.SendMessageBatch(batch)
		if err != nil {
			w.Logger.Printf("%#v\n", result)
			return err
		}
	}

	return nil
}
开发者ID:hayesgm,项目名称:queue,代码行数:17,代码来源:writer.go

示例8: Start

func Start(q *sqs.Queue, h Handler, t time.Duration, receiveMessageNum int, client twilio.Client, sender string) {
	fmt.Println(fmt.Sprintf("worker: Start polling  [%s]", time.Now().Local()))
	for {
		resp, err := q.ReceiveMessage(receiveMessageNum)
		if err != nil {
			log.Println(err)
			continue
		}
		if len(resp.Messages) > 0 {
			fmt.Printf("\r")
			run(q, h, resp, client, sender)
		} else {
			fmt.Printf(".")
		}
		time.Sleep(t)
	}
}
开发者ID:AurelienMassiot,项目名称:SMSsender-Twilio-AmazonSQS,代码行数:17,代码来源:worker_sms.go

示例9: handle

func (s *SQSClient) handle(message string, q *sqs.Queue) error {
	var res *sqs.SendMessageResponse
	err := Retrier.Retry(func() error {
		// Call sqs.Queue.SendMessage() - initiates a HTTP request.
		var e error
		res, e = q.SendMessage(message)
		return e
	})
	if err != nil {
		return err
	}
	// check md5
	expectedHash := md5.New()
	expectedHash.Write([]byte(message))
	expected := fmt.Sprintf("%x", expectedHash.Sum(nil))
	if expected != res.MD5 {
		return errors.New(fmt.Sprintf("message %s Did Not match expected %s", res.MD5, expected))
	}
	return nil
}
开发者ID:hyandell,项目名称:aws_utils,代码行数:20,代码来源:notifier.go

示例10: handleMessage

func handleMessage(q *sqs.Queue, m *sqs.Message, h Handler, client twilio.Client, sender string) error {
	var err error
	err = h.HandleMessage(m)
	fmt.Println("Sending the following message : ", m.Body)
	receiver := m.MessageAttribute[1].Value.StringValue // collect the mobile number
	fmt.Println("To : ", receiver)
	fmt.Println("\n")
	message, err2 := twilio.NewMessage(client, sender, receiver, twilio.Body(m.Body))

	// verification
	if err2 != nil {
		fmt.Println(err2)
	} else {
		fmt.Println(message.Status)
	}
	if err != nil {
		return err
	}
	// delete
	_, err = q.DeleteMessage(m)
	return err
}
开发者ID:AurelienMassiot,项目名称:SMSsender-Twilio-AmazonSQS,代码行数:22,代码来源:worker_sms.go


注:本文中的github.com/crowdmob/goamz/sqs.Queue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。