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


Golang PQueue.UpdateLockByRcpt方法代码示例

本文整理汇总了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",
	}
}
开发者ID:vburenin,项目名称:firempq,代码行数:35,代码来源:change_message_visibility.go

示例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
}
开发者ID:vburenin,项目名称:firempq,代码行数:40,代码来源:change_message_visibility_batch.go


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