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


Golang Context.Duration方法代码示例

本文整理汇总了Golang中github.com/vulcand/vulcand/Godeps/_workspace/src/github.com/codegangsta/cli.Context.Duration方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Duration方法的具体用法?Golang Context.Duration怎么用?Golang Context.Duration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/vulcand/vulcand/Godeps/_workspace/src/github.com/codegangsta/cli.Context的用法示例。


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

示例1: upsertHostAction

func (cmd *Command) upsertHostAction(c *cli.Context) {
	host, err := engine.NewHost(c.String("name"), engine.HostSettings{})
	if err != nil {
		cmd.printError(err)
		return
	}
	if c.String("cert") != "" || c.String("privateKey") != "" {
		keyPair, err := readKeyPair(c.String("cert"), c.String("privateKey"))
		if err != nil {
			cmd.printError(fmt.Errorf("failed to read key pair: %s", err))
			return
		}
		host.Settings.KeyPair = keyPair
	}
	host.Settings.OCSP = engine.OCSPSettings{
		Enabled:            c.Bool("ocsp"),
		SkipSignatureCheck: c.Bool("ocspSkipCheck"),
		Period:             c.Duration("ocspPeriod").String(),
		Responders:         c.StringSlice("ocspResponder"),
	}
	if err := cmd.client.UpsertHost(*host); err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("host added")
}
开发者ID:huhoo,项目名称:vulcand,代码行数:26,代码来源:host.go

示例2: upsertServerAction

func (cmd *Command) upsertServerAction(c *cli.Context) {
	s, err := engine.NewServer(c.String("id"), c.String("url"))
	if err != nil {
		cmd.printError(err)
		return
	}
	if err := cmd.client.UpsertServer(engine.BackendKey{Id: c.String("backend")}, *s, c.Duration("ttl")); err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("server upserted")
}
开发者ID:huhoo,项目名称:vulcand,代码行数:12,代码来源:server.go

示例3: upsertFrontendAction

func (cmd *Command) upsertFrontendAction(c *cli.Context) {
	settings, err := getFrontendSettings(c)
	if err != nil {
		cmd.printError(err)
		return
	}
	f, err := engine.NewHTTPFrontend(route.NewMux(), c.String("id"), c.String("b"), c.String("route"), settings)
	if err != nil {
		cmd.printError(err)
		return
	}
	if err := cmd.client.UpsertFrontend(*f, c.Duration("ttl")); err != nil {
		cmd.printError(err)
		return
	}
	cmd.printOk("frontend upserted")
}
开发者ID:huhoo,项目名称:vulcand,代码行数:17,代码来源:frontend.go

示例4: getBackendSettings

func getBackendSettings(c *cli.Context) (engine.HTTPBackendSettings, error) {
	s := engine.HTTPBackendSettings{}

	s.Timeouts.Read = c.Duration("readTimeout").String()
	s.Timeouts.Dial = c.Duration("dialTimeout").String()
	s.Timeouts.TLSHandshake = c.Duration("handshakeTimeout").String()

	s.KeepAlive.Period = c.Duration("keepAlivePeriod").String()
	s.KeepAlive.MaxIdleConnsPerHost = c.Int("maxIdleConns")

	tlsSettings, err := getTLSSettings(c)
	if err != nil {
		return s, err
	}
	s.TLS = tlsSettings
	return s, nil
}
开发者ID:huhoo,项目名称:vulcand,代码行数:17,代码来源:backend.go

示例5: FromCli

// FromCli constructs the middleware from the command line arguments
func FromCli(c *cli.Context) (plugin.Middleware, error) {
	return NewSpec(c.String("condition"), c.String("fallback"), c.String("onTripped"), c.String("onStandby"), c.Duration("fallbackDuration"), c.Duration("recoveryDuration"), c.Duration("checkPeriod"))
}
开发者ID:huhoo,项目名称:vulcand,代码行数:4,代码来源:spec.go


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