本文整理汇总了Golang中github.com/Cepave/common/model.Event.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Event.String方法的具体用法?Golang Event.String怎么用?Golang Event.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Cepave/common/model.Event
的用法示例。
在下文中一共展示了Event.String方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: popEvent
func popEvent(queues []string) (*model.Event, error) {
log := logger.Logger()
count := len(queues)
params := make([]interface{}, count+1)
for i := 0; i < count; i++ {
params[i] = queues[i]
}
// set timeout 0
params[count] = 0
rc := g.RedisConnPool.Get()
defer rc.Close()
reply, err := redis.Strings(rc.Do("BRPOP", params...))
if err != nil {
log.Error(fmt.Sprintf("get alarm event from redis fail: %v", err))
return nil, err
}
var event model.Event
err = json.Unmarshal([]byte(reply[1]), &event)
if err != nil {
log.Error(fmt.Sprintf("parse alarm event fail: %v", err))
return nil, err
}
log.Debug(event.String())
//insert event into database
eventmodel.InsertEvent(&event)
// save in memory. display in dashboard
g.Events.Put(&event)
return &event, nil
}
示例2: popEvent
func popEvent(queues []string) (*model.Event, error) {
count := len(queues)
params := make([]interface{}, count+1)
for i := 0; i < count; i++ {
params[i] = queues[i]
}
// set timeout 0
params[count] = 0
rc := g.RedisConnPool.Get()
defer rc.Close()
reply, err := redis.Strings(rc.Do("BRPOP", params...))
if err != nil {
log.Printf("get alarm event from redis fail: %v", err)
return nil, err
}
var event model.Event
err = json.Unmarshal([]byte(reply[1]), &event)
if err != nil {
log.Printf("parse alarm event fail: %v", err)
return nil, err
}
if g.Config().Debug {
log.Println("======>>>>")
log.Println(event.String())
}
// save in memory. display in dashboard
g.Events.Put(&event)
return &event, nil
}