本文整理汇总了Golang中github.com/vulcand/vulcand/Godeps/_workspace/src/github.com/codegangsta/cli.Context类的典型用法代码示例。如果您正苦于以下问题:Golang Context类的具体用法?Golang Context怎么用?Golang Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Context类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: deleteBackendAction
func (cmd *Command) deleteBackendAction(c *cli.Context) {
if err := cmd.client.DeleteBackend(engine.BackendKey{Id: c.String("id")}); err != nil {
cmd.printError(err)
} else {
cmd.printOk("backend deleted")
}
}
开发者ID:huhoo,项目名称:vulcand,代码行数:7,代码来源:backend.go
示例2: deleteHostAction
func (cmd *Command) deleteHostAction(c *cli.Context) {
if err := cmd.client.DeleteHost(engine.HostKey{Name: c.String("name")}); err != nil {
cmd.printError(err)
return
}
cmd.printOk("host deleted")
}
开发者ID:huhoo,项目名称:vulcand,代码行数:7,代码来源:host.go
示例3: printHostAction
func (cmd *Command) printHostAction(c *cli.Context) {
host, err := cmd.client.GetHost(engine.HostKey{Name: c.String("name")})
if err != nil {
cmd.printError(err)
return
}
cmd.printHost(host)
}
开发者ID:huhoo,项目名称:vulcand,代码行数:8,代码来源:host.go
示例4: printListenerAction
func (cmd *Command) printListenerAction(c *cli.Context) {
l, err := cmd.client.GetListener(engine.ListenerKey{Id: c.String("id")})
if err != nil {
cmd.printError(err)
return
}
cmd.printListener(l)
}
开发者ID:huhoo,项目名称:vulcand,代码行数:8,代码来源:listener.go
示例5: deleteServerAction
func (cmd *Command) deleteServerAction(c *cli.Context) {
sk := engine.ServerKey{BackendKey: engine.BackendKey{Id: c.String("backend")}, Id: c.String("id")}
if err := cmd.client.DeleteServer(sk); err != nil {
cmd.printError(err)
return
}
cmd.printOk("Server %v deleted", sk.Id)
}
开发者ID:huhoo,项目名称:vulcand,代码行数:8,代码来源:server.go
示例6: printServersAction
func (cmd *Command) printServersAction(c *cli.Context) {
srvs, err := cmd.client.GetServers(engine.BackendKey{Id: c.String("backend")})
if err != nil {
cmd.printError(err)
return
}
cmd.printServers(srvs)
}
开发者ID:huhoo,项目名称:vulcand,代码行数:8,代码来源:server.go
示例7: deleteFrontendAction
func (cmd *Command) deleteFrontendAction(c *cli.Context) {
err := cmd.client.DeleteFrontend(engine.FrontendKey{Id: c.String("id")})
if err != nil {
cmd.printError(err)
return
}
cmd.printOk("frontend deleted")
}
开发者ID:huhoo,项目名称:vulcand,代码行数:8,代码来源:frontend.go
示例8: printServerAction
func (cmd *Command) printServerAction(c *cli.Context) {
s, err := cmd.client.GetServer(engine.ServerKey{Id: c.String("id"), BackendKey: engine.BackendKey{Id: c.String("backend")}})
if err != nil {
cmd.printError(err)
return
}
cmd.printServer(s)
}
开发者ID:huhoo,项目名称:vulcand,代码行数:8,代码来源:server.go
示例9: FromCli
// FromCli constructs a middleware instance from the command line parameters.
func FromCli(c *cli.Context) (plugin.Middleware, error) {
return FromOther(
RateLimit{
PeriodSeconds: int64(c.Int("period")),
Requests: int64(c.Int("requests")),
Burst: int64(c.Int("burst")),
Variable: c.String("var"),
RateVar: c.String("rateVar")})
}
开发者ID:huhoo,项目名称:vulcand,代码行数:10,代码来源:ratelimit.go
示例10: updateLogSeverityAction
func (cmd *Command) updateLogSeverityAction(c *cli.Context) {
sev, err := log.SeverityFromString(c.String("severity"))
if err != nil {
cmd.printError(err)
return
}
if err := cmd.client.UpdateLogSeverity(sev); err != nil {
cmd.printError(err)
return
}
cmd.printOk("log severity updated")
}
开发者ID:huhoo,项目名称:vulcand,代码行数:12,代码来源:log.go
示例11: initBundle
func initBundle(c *cli.Context) {
b, err := NewBundler(c.StringSlice("middleware"))
if err != nil {
log.Errorf("Failed to bundle middlewares: %s", err)
return
}
if err := b.bundle(); err != nil {
log.Errorf("Failed to bundle middlewares: %s", err)
} else {
log.Infof("SUCCESS: bundle vulcand and vctl completed")
}
}
开发者ID:huhoo,项目名称:vulcand,代码行数:12,代码来源:main.go
示例12: upsertBackendAction
func (cmd *Command) upsertBackendAction(c *cli.Context) {
settings, err := getBackendSettings(c)
if err != nil {
cmd.printError(err)
return
}
b, err := engine.NewHTTPBackend(c.String("id"), settings)
if err != nil {
cmd.printError(err)
return
}
cmd.printResult("%s upserted", b, cmd.client.UpsertBackend(*b))
}
开发者ID:huhoo,项目名称:vulcand,代码行数:13,代码来源:backend.go
示例13: printBackendAction
func (cmd *Command) printBackendAction(c *cli.Context) {
bk := engine.BackendKey{Id: c.String("id")}
b, err := cmd.client.GetBackend(bk)
if err != nil {
cmd.printError(err)
return
}
srvs, err := cmd.client.GetServers(bk)
if err != nil {
cmd.printError(err)
return
}
cmd.printBackend(b, srvs)
}
开发者ID:huhoo,项目名称:vulcand,代码行数:14,代码来源:backend.go
示例14: FromCli
// FromCli constructs the middleware from the command line.
func FromCli(c *cli.Context) (plugin.Middleware, error) {
var suppliedConfig map[string]*domain
configFile := c.String(configFile)
if configFile != "" {
yamlFile, err := ioutil.ReadFile(configFile)
if err != nil {
fmt.Println(errorFileIO)
}
yaml.Unmarshal(yamlFile, &suppliedConfig)
}
return New(suppliedConfig)
}
开发者ID:uniqueusa,项目名称:vulcan-locale,代码行数:16,代码来源:locale.go
示例15: printFrontendAction
func (cmd *Command) printFrontendAction(c *cli.Context) {
fk := engine.FrontendKey{Id: c.String("id")}
frontend, err := cmd.client.GetFrontend(fk)
if err != nil {
cmd.printError(err)
return
}
ms, err := cmd.client.GetMiddlewares(fk)
if err != nil {
cmd.printError(err)
return
}
cmd.printFrontend(frontend, ms)
}
开发者ID:huhoo,项目名称:vulcand,代码行数:15,代码来源:frontend.go
示例16: 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
示例17: 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
示例18: 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
示例19: getStream
func getStream(c *cli.Context) (io.Writer, io.Closer, error) {
if c.String("file") != "" {
file, err := os.OpenFile(c.String("file"), os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
return nil, nil, fmt.Errorf("failed to open file %s, error: %s", c.String("file"), err)
}
return file, file, nil
}
return os.Stdout, nil, nil
}
开发者ID:huhoo,项目名称:vulcand,代码行数:10,代码来源:secret.go
示例20: upsertListenerAction
func (cmd *Command) upsertListenerAction(c *cli.Context) {
var settings *engine.HTTPSListenerSettings
if c.String("proto") == engine.HTTPS {
s, err := getTLSSettings(c)
if err != nil {
cmd.printError(err)
return
}
settings = &engine.HTTPSListenerSettings{TLS: *s}
}
listener, err := engine.NewListener(c.String("id"), c.String("proto"), c.String("net"), c.String("addr"), c.String("scope"), settings)
if err != nil {
cmd.printError(err)
return
}
if err := cmd.client.UpsertListener(*listener); err != nil {
cmd.printError(err)
return
}
cmd.printOk("listener upserted")
}
开发者ID:huhoo,项目名称:vulcand,代码行数:21,代码来源:listener.go
注:本文中的github.com/vulcand/vulcand/Godeps/_workspace/src/github.com/codegangsta/cli.Context类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论