本文整理匯總了Golang中github.com/hevnly/eevy/event.Event.GetId方法的典型用法代碼示例。如果您正苦於以下問題:Golang Event.GetId方法的具體用法?Golang Event.GetId怎麽用?Golang Event.GetId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hevnly/eevy/event.Event
的用法示例。
在下文中一共展示了Event.GetId方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Exec
// Satisfies the Listener interface and calls the relevant binary file
func (this *Cli) Exec(evt event.Event) {
this.Log.Handler(this, &evt)
bin := magicString(this.Config.GetBin(), evt)
stdin := magicString(this.Config.GetStdin(), evt)
args := append([]string(nil), this.Config.GetArgs()...)
for i, arg := range this.Config.GetArgs() {
args[i] = magicString(arg, evt)
}
cmd := exec.Command(bin, args...)
cmd.Stdin = strings.NewReader(stdin)
var out bytes.Buffer
var sErr bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &sErr
this.Log.Info("CLI CMD %s %s \"%s %s\"", evt.GetId(), this.GetName(), bin, strings.Join(args, " "))
err := cmd.Run()
if err != nil {
this.Log.HandlerError(this, err.Error(), &evt)
return
}
this.Log.Debug("CLI OUT %s %s \"%s\"", evt.GetId(), this.GetName(), out.String())
}
示例2: Exec
// Satisfies the Listener interface and calls the Lambda function
func (this *Lambda) Exec(evt event.Event) {
this.Log.Handler(this, &evt)
msg := magicString(this.Config.GetMessage(), evt)
reg := magicString(this.Config.GetRegion(), evt)
fun := magicString(this.Config.GetFunction(), evt)
svc := lambda.New(&aws.Config{Region: reg})
params := &lambda.InvokeInput{
FunctionName: aws.String(fun), // Required
Payload: []byte(msg),
}
resp, err := svc.Invoke(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
msg := fmt.Sprintf("%s %s", awsErr.Code(), awsErr.Message())
this.Log.HandlerError(this, msg, &evt)
if _, ok := err.(awserr.RequestFailure); ok {
}
} else {
this.Log.HandlerError(this, err.Error(), &evt)
}
return
}
this.Log.Debug("LAMBDA OUT %s %s \"%s\"", evt.GetId(), this.GetName(), awsutil.StringValue(resp))
}
示例3: Exec
// Satisfies the Listener interface and calls the relevant binary file
func (this *Cli) Exec(evt event.Event) {
this.Log.Handler(this, &evt)
bin := magicString(this.Config.GetBin(), evt)
stdin := magicString(this.Config.GetStdin(), evt)
args := append([]string(nil), this.Config.GetArgs()...)
for i, arg := range this.Config.GetArgs() {
args[i] = magicString(arg, evt)
}
cmd := exec.Command(bin, args...)
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
cmd.Stdin = strings.NewReader(stdin)
var out bytes.Buffer
var sErr bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &sErr
this.Log.Info("CLI CMD %s %s \"%s %s\"", evt.GetId(), this.GetName(), bin, strings.Join(args, " "))
err := cmd.Start()
if err != nil {
this.Log.Error("CLI ERR %s %s \"%s\"", evt.GetId(), this.GetName(), sErr.String())
this.Log.HandlerError(this, err.Error(), &evt)
return
}
timeOut := this.Config.GetTimeout()
if timeOut == 0 {
if err := cmd.Wait(); err != nil {
this.Log.Error("CLI ERROR %s", err.Error())
}
} else {
// this allows us to set a timeout on the cli (phantomjs def needs this)
done := make(chan error, 1)
go func() {
done <- cmd.Wait()
}()
select {
case <-time.After(time.Duration(timeOut) * time.Second):
pgid, err := syscall.Getpgid(cmd.Process.Pid)
if err == nil {
syscall.Kill(-pgid, 15) // note the minus sign
this.Log.Warning("CLITIMEOUT %s %s", evt.GetId(), this.GetName())
}
<-done // allow goroutine to exit
case err := <-done:
if err != nil {
this.Log.Error("CLI ERROR %s", err.Error())
}
}
}
this.Log.Debug("CLI OUT %s %s \"%s\"", evt.GetId(), this.GetName(), out.String())
}