本文整理汇总了Golang中github.com/vburenin/firempq/pqueue.PQueue.SetParams方法的典型用法代码示例。如果您正苦于以下问题:Golang PQueue.SetParams方法的具体用法?Golang PQueue.SetParams怎么用?Golang PQueue.SetParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vburenin/firempq/pqueue.PQueue
的用法示例。
在下文中一共展示了PQueue.SetParams方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetQueueAttributes
func SetQueueAttributes(pq *pqueue.PQueue, sqsQuery *urlutils.SQSQuery) sqs_response.SQSResponse {
attrs, err := urlutils.ParseNNotationAttr("MessageAttribute.", sqsQuery.ParamsList, nil, NewAttribute)
if err != nil {
return err
}
attrsLen := len(attrs)
params := &pqueue.PQueueParams{}
for i := 1; i < attrsLen; i++ {
a, ok := attrs[i]
if !ok {
return sqserr.InvalidParameterValueError("The request must contain non-empty message attribute name.")
}
attr, _ := a.(*Attribute)
err = nil
switch attr.Name {
case "DelaySeconds":
if v, e := strconv.ParseInt(attr.Value, 10, 0); e == nil {
v := v * 1000
if v >= 0 && v <= conf.CFG_PQ.MaxDeliveryDelay {
params.DeliveryDelay = &v
continue
}
}
return sqserr.InvalidAttributeValueError(AttrErrText, attr.Name)
case "MaximumMessageSize":
if v, e := strconv.ParseInt(attr.Value, 10, 0); e == nil {
if v >= 1024 && v <= conf.CFG_PQ.MaxMessageSize {
params.MaxMsgSize = &v
continue
}
}
return sqserr.InvalidAttributeValueError(AttrErrText, attr.Name)
case "MessageRetentionPeriod":
if v, e := strconv.ParseInt(attr.Value, 10, 0); e == nil {
if v >= 60 && v <= 1209600 {
v := v * 1000
params.MsgTTL = &v
continue
}
}
return sqserr.InvalidAttributeValueError(AttrErrText, attr.Name)
case "ReceiveMessageWaitTimeSeconds":
if v, e := strconv.ParseInt(attr.Value, 10, 0); e == nil {
v := v * 1000
if v >= 60000 && v <= conf.CFG_PQ.MaxPopWaitTimeout {
params.PopWaitTimeout = &v
continue
}
}
return sqserr.InvalidAttributeValueError(AttrErrText, attr.Name)
case "VisibilityTimeout":
if v, e := strconv.ParseInt(attr.Value, 10, 0); e == nil {
v := v * 1000
if v > 0 && v <= conf.CFG_PQ.MaxLockTimeout {
params.PopLockTimeout = &v
continue
}
}
return sqserr.InvalidAttributeValueError(AttrErrText, attr.Name)
// These parameters are just ignored.
case "Policy":
case "ApproximateNumberOfMessages":
case "ApproximateNumberOfMessagesDelayed":
case "ApproximateNumberOfMessagesNotVisible":
case "CreatedTimestamp":
case "LastModifiedTimestamp":
case "QueueArn":
// Any unexpected attribute will produce unexpected attribute error.
default:
return sqserr.InvalidAttributeNameError("Unknown Attribute: %s", attr.Name)
}
}
pq.SetParams(params)
return &SetQueueAttributesResponse{
RequestId: "req",
}
}