示例#1
0
func GetQueue() (Q *sqs.Queue, err os.Error) {
	proxyURL, err := GetProxyURL()
	if err != nil {
		return
	}
	id, err := GetAWSIdentity()
	if err != nil {
		return
	}
	if queueURL != nil && *queueURL != "" {
		qrl, err := http.ParseURL(*queueURL)
		if err == nil {
			ep := awsconn.NewEndpoint(qrl, proxyURL)
			Q = sqs.NewQueueURL(ep)
		}
	} else if queueName != nil && *queueName != "" {
		ep, err := http.ParseURL(*sqsEndpoint)
		if err == nil {
			log.Printf("Parsed EP url: %v", ep)
			ep := awsconn.NewEndpoint(ep, proxyURL)
			_sqs := sqs.NewService(ep)
			Q, err = _sqs.CreateQueue(id, *queueName, 90)
			if err != nil {
				log.Fatalf("Qerr: [%v]", err)
			}
		}
	} else {
		err = os.NewError("Either Queue(+Endpoint) or QueueURL are required")
	}
	return
}
示例#2
0
func GetSQSService() (s *sqs.Service, err os.Error) {
	ep, err := GetEndpoint()
	if err != nil {
		return
	}
	s = sqs.NewService(ep)
	return
}