示例#1
0
文件: main.go 项目: wubin1989/iron_go
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)
}
示例#2
0
文件: main.go 项目: wubin1989/iron_go
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))
}
示例#3
0
文件: mq.go 项目: joeshaw/iron_go
func (q Queue) queues(s ...string) *api.URL { return api.Action(q.Settings, "queues", s...) }
示例#4
0
func (c *Cache) caches(suffix ...string) *api.URL {
	return api.Action(c.Settings, "caches", suffix...)
}
示例#5
0
文件: worker.go 项目: edsrzf/iron_go
func (w *Worker) schedules(s ...string) *api.URL { return api.Action(w.Settings, "schedules", s...) }
示例#6
0
文件: worker.go 项目: edsrzf/iron_go
func (w *Worker) tasks(s ...string) *api.URL     { return api.Action(w.Settings, "tasks", s...) }
示例#7
0
文件: worker.go 项目: edsrzf/iron_go
func (w *Worker) codes(s ...string) *api.URL     { return api.Action(w.Settings, "codes", s...) }