Example #1
0
File: mq.go Project: nildev/account
func ListQueues(s config.Settings, prefix, prev string, perPage int) ([]Queue, error) {
	var out struct {
		Queues []Queue `json:"queues"`
	}

	url := api.Action(s, "queues")

	if prev != "" {
		url.QueryAdd("previous", "%v", prev)
	}
	if prefix != "" {
		url.QueryAdd("prefix", "%v", prefix)
	}
	if perPage != 0 {
		url.QueryAdd("per_page", "%d", perPage)
	}

	err := url.Req("GET", nil, &out)
	if err != nil {
		return nil, err
	}

	for idx := range out.Queues {
		out.Queues[idx].Settings = s
	}

	return out.Queues, nil
}
Example #2
0
File: mq.go Project: nildev/account
// Will create a new queue, all fields are optional.
// Queue type cannot be changed.
func ConfigCreateQueue(queueInfo QueueInfo, settings *config.Settings) (QueueInfo, error) {
	if queueInfo.Name == "" {
		return QueueInfo{}, errors.New("Name of queue is empty")
	}

	url := api.Action(config.ManualConfig("iron_mq", settings), "queues", queueInfo.Name)

	in := struct {
		Queue QueueInfo `json:"queue"`
	}{
		Queue: queueInfo,
	}

	var out struct {
		Queue QueueInfo `json:"queue"`
	}

	err := url.Req("PUT", in, &out)
	return out.Queue, err
}
Example #3
0
File: mq.go Project: nildev/account
func (q Queue) queues(s ...string) *api.URL { return api.Action(q.Settings, "queues", s...) }