예제 #1
0
func pollSQS(rule *fromSQSRule) Message {
	query := make(url.Values)
	query.Add("Action", "ReceiveMessage")
	query.Add("AttributeName", "All")
	query.Add("Version", AWSSQSAPIVersion)
	query.Add("SignatureVersion", AWSSignatureVersion)
	query.Add("WaitTimeSeconds", "10")

	keys := &aws4.Keys{
		AccessKey: rule.AccessKey,
		SecretKey: rule.AccessSecret,
	}

	c := aws4.Client{Keys: keys}

	resp, err := c.Get(rule.SQSEndpoint + query.Encode())
	if err != nil {
		log.Println(err.Error())
	}

	var v Message

	body, err := ioutil.ReadAll(resp.Body)
	err = xml.Unmarshal(body, &v)
	if err != nil {
		log.Println(err.Error())
	}
	return v
}
예제 #2
0
func deleteMessage(rule *fromSQSRule, ReceiptHandle string) {
	query := make(url.Values)
	query.Add("Action", "DeleteMessage")
	query.Add("ReceiptHandle", ReceiptHandle)
	query.Add("Version", AWSSQSAPIVersion)
	query.Add("SignatureVersion", AWSSignatureVersion)

	keys := &aws4.Keys{
		AccessKey: rule.AccessKey,
		SecretKey: rule.AccessSecret,
	}

	c := aws4.Client{Keys: keys}

	_, err := c.Get(rule.SQSEndpoint + query.Encode())
	if err != nil {
		log.Println(err.Error())
	}
}