本文整理匯總了Golang中github.com/hashicorp/serf/cli.Ui.Info方法的典型用法代碼示例。如果您正苦於以下問題:Golang Ui.Info方法的具體用法?Golang Ui.Info怎麽用?Golang Ui.Info使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hashicorp/serf/cli.Ui
的用法示例。
在下文中一共展示了Ui.Info方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Run
func (c *MonitorCommand) Run(args []string, ui cli.Ui) int {
var logLevel string
cmdFlags := flag.NewFlagSet("monitor", flag.ContinueOnError)
cmdFlags.Usage = func() { ui.Output(c.Help()) }
cmdFlags.StringVar(&logLevel, "log-level", "INFO", "log level")
rpcAddr := RPCAddrFlag(cmdFlags)
if err := cmdFlags.Parse(args); err != nil {
return 1
}
client, err := RPCClient(*rpcAddr)
if err != nil {
ui.Error(fmt.Sprintf("Error connecting to Serf agent: %s", err))
return 1
}
defer client.Close()
eventCh := make(chan string)
doneCh := make(chan struct{})
if err := client.Monitor(logutils.LogLevel(logLevel), eventCh, doneCh); err != nil {
ui.Error(fmt.Sprintf("Error starting monitor: %s", err))
return 1
}
eventDoneCh := make(chan struct{})
go func() {
defer close(eventDoneCh)
for e := range eventCh {
ui.Info(e)
}
c.lock.Lock()
defer c.lock.Unlock()
if !c.quitting {
ui.Info("")
ui.Output("Remote side ended the monitor! This usually means that the\n" +
"remote side has exited or crashed.")
}
}()
select {
case <-eventDoneCh:
return 1
case <-c.ShutdownCh:
c.lock.Lock()
c.quitting = true
c.lock.Unlock()
}
close(doneCh)
return 0
}