Example #1
0
// 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 #2
0
// ConfigNew uses the specified settings over configuration specified in an iron.json file or
// environment variables to return a Queue object capable of acquiring information about or
// modifying the queue specified by queueName.
func ConfigNew(queueName string, settings *config.Settings) Queue {
	return Queue{Settings: config.ManualConfig("iron_mq", settings), Name: queueName}
}