本文整理汇总了Golang中github.com/vburenin/firempq/pqueue.PQueue.UpdateLockByRcpt方法的典型用法代码示例。如果您正苦于以下问题:Golang PQueue.UpdateLockByRcpt方法的具体用法?Golang PQueue.UpdateLockByRcpt怎么用?Golang PQueue.UpdateLockByRcpt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vburenin/firempq/pqueue.PQueue
的用法示例。
在下文中一共展示了PQueue.UpdateLockByRcpt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ChangeMessageVisibility
func ChangeMessageVisibility(pq *pqueue.PQueue, sqsQuery *urlutils.SQSQuery) sqs_response.SQSResponse {
var receipt string
var visibilityTimeout int64 = -1
paramsLen := len(sqsQuery.ParamsList) - 1
for i := 0; i < paramsLen; i += 2 {
switch sqsQuery.ParamsList[i] {
case "ReceiptHandle":
receipt = sqsQuery.ParamsList[i+1]
case "VisibilityTimeout":
v, err := strconv.ParseInt(sqsQuery.ParamsList[i+1], 10, 0)
if err != nil || v < 0 {
return sqserr.MalformedInputError("VisibilityTimeout must be a positive integer value")
}
visibilityTimeout = v * 1000
}
}
if receipt == "" {
return sqserr.MissingParameterError("The request must contain the parameter ReceiptHandle.")
}
if visibilityTimeout < 0 {
return sqserr.MissingParameterError("The request must contain the parameter VisibilityTimeout.")
}
resp := pq.UpdateLockByRcpt(receipt, visibilityTimeout)
if resp == mpqerr.ERR_INVALID_RECEIPT {
return sqserr.InvalidReceiptHandleError("The input receipt handle is not a valid receipt handle.")
}
return &ChangeMessageVisibilityResponse{
RequestId: "cvtreq",
}
}
示例2: ChangeMessageVisibilityBatch
func ChangeMessageVisibilityBatch(pq *pqueue.PQueue, sqsQuery *urlutils.SQSQuery) sqs_response.SQSResponse {
attrs, _ := urlutils.ParseNNotationAttr(
"ChangeMessageVisibilityBatchRequestEntry.", sqsQuery.ParamsList,
nil, NewVisibilityBatchParams)
attrsLen := len(attrs)
checker, err := validation.NewBatchIdValidation(attrsLen)
if err != nil {
return err
}
attrList := make([]*VisibilityBatchParams, 0, attrsLen)
for i := 1; i <= attrsLen; i++ {
a, ok := attrs[i]
if !ok {
return sqserr.MissingParameterError("The request is missing sequence %d", i)
}
p, _ := a.(*VisibilityBatchParams)
if err = checker.Validate(p.Id); err != nil {
return err
}
attrList = append(attrList, p)
}
output := &ChangeMessageVisibilityBatchResponse{
RequestId: "visibilitybatch",
}
for _, batchItem := range attrList {
resp := pq.UpdateLockByRcpt(batchItem.ReceiptHandle, batchItem.VisibilityTimeout)
if resp == mpqerr.ERR_INVALID_RECEIPT {
e := sqserr.InvalidReceiptHandleError("The input receipt handle is not a valid receipt handle.")
output.ErrorEntry = append(output.ErrorEntry, e.BatchResult(batchItem.Id))
} else {
output.ResultEntry = append(output.ResultEntry, &OkChange{Id: batchItem.Id})
}
}
return output
}