Example #1
0
func init() {
	defer PrintSpecReport()
	Describe("gets config", func() {
		It("gets default configs", func() {
			s := config.Config("iron_undefined")
			Expect(s.Host, ToEqual, "undefined-aws-us-east-1.iron.io")
		})
	})
}
Example #2
0
func main() {
	// Create your configuration for iron_worker
	// Find these value in credentials
	config := config.Config("iron_worker")
	config.ProjectId = "your_project_id"
	config.Token = "your_token"

	// Capture info for this code
	codeId := "522d160a91c530531f6f528d"

	// Create your endpoint url for tasks
	url := api.Action(config, "codes", codeId)
	log.Printf("Url: %s\n", url.URL.String())

	// Post the request to Iron.io
	resp, err := url.Request("GET", nil)
	defer resp.Body.Close()
	if err != nil {
		log.Println(err)
		return
	}

	// Check the status code
	if resp.StatusCode != 200 {
		log.Printf("%v\n", resp)
		return
	}

	// Capture the response
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Println(err)
		return
	}

	// Unmarshall to struct
	code := &Code{}
	err = json.Unmarshal(body, code)
	if err != nil {
		log.Printf("%v\n", err)
		return
	}

	// Unmarshall to map
	results := map[string]interface{}{}
	err = json.Unmarshal(body, &results)
	if err != nil {
		log.Printf("%v\n", err)
		return
	}

	// Pretty print the response
	prettyPrint(code)
}
Example #3
0
func main() {
	// Create your configuration for iron_worker
	// Find these value in credentials
	config := config.Config("iron_worker")
	config.ProjectId = "your_project_id"
	config.Token = "your_token"

	// Create your endpoint url for tasks
	url := api.ActionEndpoint(config, "tasks")
	url.QueryAdd("code_name", "%s", "task")
	log.Printf("Url: %s\n", url.URL.String())

	// Post the request to Iron.io
	resp, err := url.Request("GET", nil)
	defer resp.Body.Close()
	if err != nil {
		log.Println(err)
		return
	}

	// Check the status code
	if resp.StatusCode != 200 {
		log.Printf("%v\n", resp)
		return
	}

	// Capture the response
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Println(err)
		return
	}

	// Unmarshall to struct
	taskResponse := &TaskResponse{}
	err = json.Unmarshal(body, taskResponse)
	if err != nil {
		log.Printf("%v\n", err)
		return
	}

	// Or you can Unmarshall to map
	results := map[string]interface{}{}
	err = json.Unmarshal(body, &results)
	if err != nil {
		log.Printf("%v\n", err)
		return
	}

	// Pretty print the response
	prettyPrint(taskResponse)
}
Example #4
0
func main() {
	// Create your configuration for iron_worker
	// Find these value in credentials
	config := config.Config("iron_worker")
	config.ProjectId = "your_project_id"
	config.Token = "your_token"

	// Create your endpoint url for tasks
	url := api.ActionEndpoint(config, "tasks")
	log.Printf("Url: %s\n", url.URL.String())

	// Convert the payload to a slice of bytes
	postData := bytes.NewBufferString(payload)

	// Post the request to Iron.io
	resp, err := url.Request("POST", postData)
	defer resp.Body.Close()
	if err != nil {
		log.Println(err)
		return
	}

	// Capture the response
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Println(err)
		return
	}

	// Unmarshall to struct
	taskResponse := &TaskResponse{}
	err = json.Unmarshal(body, taskResponse)
	if err != nil {
		log.Printf("%v\n", err)
		return
	}

	// Or you can Unmarshall to map
	results := map[string]interface{}{}
	err = json.Unmarshal(body, &results)
	if err != nil {
		log.Printf("%v\n", err)
		return
	}

	// Pretty print the response
	prettyPrint(taskResponse)
}
Example #5
0
func main() {
	// Create your configuration for iron_worker
	// Find these value in credentials
	config := config.Config("iron_worker")
	config.ProjectId = "your_project_id"
	config.Token = "your_token"

	// Capture info for this task
	taskId := "52b45b17a31186632b00da4c"

	// Create your endpoint url for tasks
	url := api.Action(config, "tasks", taskId, "log")
	log.Printf("Url: %s\n", url.URL.String())

	// Post the request to Iron.io
	resp, err := url.Request("GET", nil)
	defer resp.Body.Close()
	if err != nil {
		log.Println(err)
		return
	}

	// Check the status code
	if resp.StatusCode != 200 {
		log.Printf("%v\n", resp)
		return
	}

	// Capture the response
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Println(err)
		return
	}

	// Display the log
	log.Printf("\n%s\n", string(body))
}
Example #6
0
// New returns a struct ready to make requests with.
// The cacheName argument is used as namespace.
func New(cacheName string) *Cache {
	return &Cache{Settings: config.Config("iron_cache"), Name: cacheName}
}
Example #7
0
func New(queueName string) *Queue {
	return &Queue{Settings: config.Config("iron_mq"), Name: queueName}
}
Example #8
0
func ListQueues(page, perPage int) (queues []Queue, err error) {
	settings := config.Config("iron_mq")
	return ListProjectQueues(settings.ProjectId, settings.Token, page, perPage)
}
Example #9
0
func ListProjectQueues(projectId string, token string, page int, perPage int) (queues []Queue, err error) {
	settings := config.Config("iron_mq")
	settings.ProjectId = projectId
	settings.Token = token
	return ListSettingsQueues(settings, page, perPage)
}
Example #10
0
func New() *Worker {
	return &Worker{Settings: config.Config("iron_worker")}
}