Example #1
0
func DeleteQueue(svcMgr *qmgr.ServiceManager, sqsQuery *urlutils.SQSQuery) sqs_response.SQSResponse {
	resp := svcMgr.DropService(sqsQuery.QueueName)
	if resp == mpqerr.ERR_NO_SVC {
		return sqserr.QueueDoesNotExist()
	}
	return &DeleteQueueResponse{
		RequestId: "delqueue",
	}
}
Example #2
0
func ListQueues(svcMgr *qmgr.ServiceManager, sqsQuery *urlutils.SQSQuery) sqs_response.SQSResponse {
	nameList := svcMgr.BuildServiceNameList(sqsQuery.QueueNamePrefix)
	sort.Strings(nameList)

	urlList := make([]string, 0, len(nameList))
	for _, name := range nameList {
		urlList = append(urlList, sqsQuery.Host+"/queue/"+name)
	}
	return &ListQueuesResponse{
		QueueUrl:  urlList,
		RequestId: "reqId",
	}
}
Example #3
0
func CreateQueue(svcMgr *qmgr.ServiceManager, sqsQuery *urlutils.SQSQuery) sqs_response.SQSResponse {
	queueAttributes, parseErr := ParseCreateQueueAttributes(sqsQuery)
	if parseErr != nil {
		return parseErr
	}

	if errResp := CheckAvailableQueues(svcMgr, queueAttributes, sqsQuery); errResp != nil {
		return errResp
	}

	resp := svcMgr.CreatePQueue(sqsQuery.QueueName, queueAttributes.MakePQConfig())
	if resp.IsError() {
		e, _ := resp.(error)
		return sqserr.ServerSideError(e.Error())
	}

	return &CreateQueueResponse{
		QueueUrl:  sqsQuery.Host + "/queue/" + sqsQuery.QueueName,
		RequestId: "1111-2222-3333",
	}
}
Example #4
0
func CheckAvailableQueues(
	svcMgr *qmgr.ServiceManager,
	attr *QueueAttributes,
	sqsQuery *urlutils.SQSQuery) sqs_response.SQSResponse {

	svc, ok := svcMgr.GetService(sqsQuery.QueueName)
	if ok {
		if svc.Info().Type != apis.ServiceTypePriorityQueue {
			return sqserr.QueueAlreadyExistsError("Queue already exists for a different type of service")
		}
		pq, _ := svc.(*pqueue.PQueue)
		pqConfig := pq.Config()
		if !ok {
			log.Error("Unexpected config type from the found service!")
			return sqserr.ServerSideError("Queue config data error")
		}
		if attr.VisibilityTimeout >= 0 && attr.VisibilityTimeout != pqConfig.PopLockTimeout {
			return sqserr.QueueAlreadyExistsError(errQueueExists + AttrVisibilityTimeout)
		}
		if attr.DelaySeconds >= 0 && attr.DelaySeconds != pqConfig.DeliveryDelay {
			return sqserr.QueueAlreadyExistsError(errQueueExists + AttrDelaySeconds)
		}
		if attr.MaximumMessageSize >= 0 && attr.MaximumMessageSize != pqConfig.MaxMsgSize {
			return sqserr.QueueAlreadyExistsError(errQueueExists + AttrMaximumMessageSize)
		}
		if attr.MessageRetentionPeriod >= 0 && attr.MessageRetentionPeriod != pqConfig.MsgTtl {
			return sqserr.QueueAlreadyExistsError(errQueueExists + AttrMessageRetentionPeriod)
		}
		if attr.ReceiveMessageWaitTimeSeconds >= 0 && attr.ReceiveMessageWaitTimeSeconds != pqConfig.PopWaitTimeout {
			return sqserr.QueueAlreadyExistsError(errQueueExists + AttrReceiveMessageWaitTimeSeconds)
		}
		return &CreateQueueResponse{
			QueueUrl:  sqsQuery.Host + "/queue/" + sqsQuery.QueueName,
			RequestId: "1111-2222-3333",
		}
	}
	return nil
}