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


Golang PQueue.Description方法代码示例

本文整理汇总了Golang中github.com/vburenin/firempq/pqueue.PQueue.Description方法的典型用法代码示例。如果您正苦于以下问题:Golang PQueue.Description方法的具体用法?Golang PQueue.Description怎么用?Golang PQueue.Description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/vburenin/firempq/pqueue.PQueue的用法示例。


在下文中一共展示了PQueue.Description方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: GetQueueAttributes

func GetQueueAttributes(pq *pqueue.PQueue, sqsQuery *urlutils.SQSQuery) sqs_response.SQSResponse {
	paramsLen := len(sqsQuery.ParamsList) - 1

	pqCfg := pq.Config()
	pqDesc := pq.Description()

	resp := &GetQueueAttributesResponse{
		RequestId: "reqId",
	}

	for i := 0; i < paramsLen; i += 2 {
		allAttr := false
		if strings.HasPrefix(sqsQuery.ParamsList[i], "AttributeName") {
			attrName := sqsQuery.ParamsList[i+1]
			if attrName == AttrAll {
				allAttr = true
				resp.Attributes = make([]*QAttr, 0, 13) // 13 total attributes
			}

			if allAttr || attrName == AttrApproximateNumberOfMessages {
				resp.Attributes = append(resp.Attributes, &QAttr{
					Name:  AttrApproximateNumberOfMessages,
					Value: pq.AvailableMessages(),
				})
			}

			if allAttr || attrName == AttrApproximateNumberOfMessagesNotVisible {
				resp.Attributes = append(resp.Attributes, &QAttr{
					Name:  AttrApproximateNumberOfMessagesNotVisible,
					Value: pq.LockedCount(),
				})
			}

			if allAttr || attrName == AttrVisibilityTimeout {
				resp.Attributes = append(resp.Attributes, &QAttr{
					Name:  AttrVisibilityTimeout,
					Value: pqCfg.PopLockTimeout / 1000,
				})
			}

			if allAttr || attrName == AttrCreatedTimestamp {
				resp.Attributes = append(resp.Attributes, &QAttr{
					Name:  AttrCreatedTimestamp,
					Value: pqDesc.CreateTs / 1000,
				})
			}

			if allAttr || attrName == AttrLastModifiedTimestamp {
				resp.Attributes = append(resp.Attributes, &QAttr{
					Name:  AttrLastModifiedTimestamp,
					Value: pqCfg.LastUpdateTs / 1000,
				})
			}

			if allAttr || attrName == AttrMaximumMessageSize {
				resp.Attributes = append(resp.Attributes, &QAttr{
					Name:  AttrMaximumMessageSize,
					Value: pqCfg.MaxMsgSize,
				})
			}

			if allAttr || attrName == AttrMessageRetentionPeriod {
				resp.Attributes = append(resp.Attributes, &QAttr{
					Name:  AttrMessageRetentionPeriod,
					Value: pqCfg.MsgTtl / 1000,
				})
			}

			if allAttr || attrName == AttrQueueArn {
				resp.Attributes = append(resp.Attributes, &QAttr{
					Name:  AttrQueueArn,
					Value: makeQueueArn(pqDesc.Name),
				})
			}

			if allAttr || attrName == AttrApproximateNumberOfMessagesDelayed {
				resp.Attributes = append(resp.Attributes, &QAttr{
					Name:  AttrApproximateNumberOfMessagesDelayed,
					Value: pq.DelayedCount(),
				})
			}

			if allAttr || attrName == AttrDelaySeconds {
				resp.Attributes = append(resp.Attributes, &QAttr{
					Name:  AttrDelaySeconds,
					Value: pqCfg.DeliveryDelay / 1000,
				})
			}

			if allAttr || attrName == AttrReceiveMessageWaitTimeSeconds {
				resp.Attributes = append(resp.Attributes, &QAttr{
					Name:  AttrReceiveMessageWaitTimeSeconds,
					Value: pqCfg.PopWaitTimeout / 1000,
				})
			}

			if allAttr || attrName == AttrRedrivePolicy {
				if pqCfg.PopLimitQueueName != "" {
					resp.Attributes = append(resp.Attributes, &QAttr{
						Name: AttrRedrivePolicy,
//.........这里部分代码省略.........
开发者ID:vburenin,项目名称:firempq,代码行数:101,代码来源:get_queue_attributes.go


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