当前位置: 首页>>代码示例>>Golang>>正文


Golang config.Config函数代码示例

本文整理汇总了Golang中github.com/iron-io/iron_go3/config.Config函数的典型用法代码示例。如果您正苦于以下问题:Golang Config函数的具体用法?Golang Config怎么用?Golang Config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Config函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: init

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")
		})
	})
}
开发者ID:toshipon,项目名称:iron_go3,代码行数:9,代码来源:config_test.go

示例2: UnmarshalJSON

func (q *Queue) UnmarshalJSON(data []byte) error {
	var name struct {
		Name string `json:"name"`
	}
	err := json.Unmarshal(data, &name)
	q.Name = name.Name
	q.Settings = config.Config("iron_mq") // TODO could maybe cache this in config, map[$PWD]config, if $PWD changes, update config
	return err
}
开发者ID:romand,项目名称:ironcli,代码行数:9,代码来源:mq.go

示例3: main

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.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
	task := &Task{}
	err = json.Unmarshal(body, task)
	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(task)
}
开发者ID:toshipon,项目名称:iron_go3,代码行数:54,代码来源:main.go

示例4: listQueues

func listQueues(prefix, prev string, perPage int) ([]Queue, error) {
	var out struct {
		Queues []Queue `json:"queues"`
	}

	url := api.Action(config.Config("iron_mq"), "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
	}

	return out.Queues, nil
}
开发者ID:romand,项目名称:ironcli,代码行数:24,代码来源:mq.go

示例5: New

func New() *Worker {
	return &Worker{Settings: config.Config("iron_worker")}
}
开发者ID:alex-litvak,项目名称:iron_go3,代码行数:3,代码来源:worker.go

示例6: New

// New uses the 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 New(queueName string) Queue {
	return Queue{Settings: config.Config("iron_mq"), Name: queueName}
}
开发者ID:romand,项目名称:ironcli,代码行数:6,代码来源:mq.go

示例7: New

// 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}
}
开发者ID:toshipon,项目名称:iron_go3,代码行数:5,代码来源:cache.go

示例8: FilterPage

// Like ListPage, but with an added filter.
func FilterPage(prefix, prev string, perPage int) ([]Queue, error) {
	return ListQueues(config.Config("iron_mq"), prefix, prev, perPage)
}
开发者ID:nildev,项目名称:prj-tpl-basic-api,代码行数:4,代码来源:mq.go

示例9: Filter

// Filter is like List, but will only return queues with the specified prefix.
func Filter(prefix string) ([]Queue, error) {
	return ListQueues(config.Config("iron_mq"), prefix, "", 0)
}
开发者ID:nildev,项目名称:prj-tpl-basic-api,代码行数:4,代码来源:mq.go

示例10: List

// List will get a listQueues of all queues for the configured project, paginated 30 at a time.
// For paging or filtering, see ListPage and Filter.
func List() ([]Queue, error) {
	return ListQueues(config.Config("iron_mq"), "", "", 0)
}
开发者ID:nildev,项目名称:prj-tpl-basic-api,代码行数:5,代码来源:mq.go

示例11: FilterPage

// Like ListPage, but with an added filter.
// Uses the default configuration settings.
func FilterPage(prefix, prev string, perPage int) ([]Queue, error) {
	return FilterPageConfig(prefix, prev, perPage, config.Config("iron_mq"))
}
开发者ID:gengo,项目名称:iron_go3,代码行数:5,代码来源:mq.go

示例12: Filter

// Filter is like List, but will only return queues with the specified prefix.
// Uses the default configuration settings.
func Filter(prefix string) ([]Queue, error) {
	return FilterConfig(prefix, config.Config("iron_mq"))
}
开发者ID:gengo,项目名称:iron_go3,代码行数:5,代码来源:mq.go

示例13: ListPage

// ListPage is like List, but will allow specifying a page length and pagination
// To get the first page, let prev = "".
// To get the second page, use the name of the last queue on the first page as "prev".
// Uses the default configuration settings.
func ListPage(prev string, perPage int) ([]Queue, error) {
	return ConfigListPage(prev, perPage, config.Config("iron_mq"))
}
开发者ID:gengo,项目名称:iron_go3,代码行数:7,代码来源:mq.go

示例14: List

// List will get a listQueues of all queues for the configured project, paginated 30 at a time
// For paging or filtering, see ListPage and Filter.
// Uses the default configuration settings.
func List() ([]Queue, error) {
	return ConfigList(config.Config("iron_mq"))
}
开发者ID:gengo,项目名称:iron_go3,代码行数:6,代码来源:mq.go


注:本文中的github.com/iron-io/iron_go3/config.Config函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。