本文整理汇总了Golang中github.com/araddon/qlbridge/datasource.Message类的典型用法代码示例。如果您正苦于以下问题:Golang Message类的具体用法?Golang Message怎么用?Golang Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Message类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: joinValue
func joinValue(ctx *Context, node expr.Node, msg datasource.Message) (string, bool) {
if msg == nil {
u.Warnf("got nil message?")
}
if msgReader, ok := msg.Body().(expr.ContextReader); ok {
joinVal, ok := vm.Eval(msgReader, node)
//u.Debugf("msg: %#v", msgReader)
//u.Infof("evaluating: ok?%v T:%T result=%v node expr:%v", ok, joinVal, joinVal.ToString(), node.StringAST())
if !ok {
u.Errorf("could not evaluate: %v", msg)
return "", false
}
switch val := joinVal.(type) {
case value.StringValue:
return val.Val(), true
default:
u.Warnf("unknown type? %T", joinVal)
}
} else {
u.Errorf("could not convert to message reader: %T", msg.Body())
}
return "", false
}
示例2: msgToRow
func msgToRow(msg datasource.Message, cols []string, dest []driver.Value) error {
//u.Debugf("msg? %v %T \n%p %v", msg, msg, dest, dest)
switch mt := msg.Body().(type) {
case *datasource.ContextUrlValues:
for i, key := range cols {
if val, ok := mt.Get(key); ok && !val.Nil() {
dest[i] = val.Value()
//u.Infof("key=%v val=%v", key, val)
} else {
u.Warnf("missing value? %v %T %v", key, val.Value(), val.Value())
}
}
//u.Debugf("got msg in row result writer: %#v", mt)
case *datasource.ContextSimple:
for i, key := range cols {
//u.Debugf("key=%v mt = nil? %v", key, mt)
if val, ok := mt.Get(key); ok && val != nil && !val.Nil() {
dest[i] = val.Value()
//u.Infof("key=%v val=%v", key, val)
} else if val == nil {
u.Errorf("could not evaluate? %v %#v", key, mt)
} else {
u.Warnf("missing value? %v %T %v", key, val.Value(), val.Value())
}
}
//u.Debugf("got msg in row result writer: %#v", mt)
default:
u.Errorf("unknown message type: %T", mt)
}
return nil
}
示例3: joinValue
func joinValue(ctx *Context, node expr.Node, msg datasource.Message, cols map[string]*expr.Column) (string, bool) {
if msg == nil {
u.Warnf("got nil message?")
}
//u.Infof("got message: %T %#v", msg, cols)
switch mt := msg.(type) {
case *datasource.SqlDriverMessage:
msgReader := datasource.NewValueContextWrapper(mt, cols)
joinVal, ok := vm.Eval(msgReader, node)
//u.Debugf("msg: %#v", msgReader)
//u.Debugf("evaluating: ok?%v T:%T result=%v node '%v'", ok, joinVal, joinVal.ToString(), node.String())
if !ok {
u.Errorf("could not evaluate: %T %#v %v", joinVal, joinVal, msg)
return "", false
}
switch val := joinVal.(type) {
case value.StringValue:
return val.Val(), true
default:
u.Warnf("unknown type? %T", joinVal)
}
default:
if msgReader, ok := msg.Body().(expr.ContextReader); ok {
joinVal, ok := vm.Eval(msgReader, node)
//u.Debugf("msg: %#v", msgReader)
//u.Infof("evaluating: ok?%v T:%T result=%v node expr:%v", ok, joinVal, joinVal.ToString(), node.StringAST())
if !ok {
u.Errorf("could not evaluate: %v", msg)
return "", false
}
switch val := joinVal.(type) {
case value.StringValue:
return val.Val(), true
default:
u.Warnf("unknown type? %T", joinVal)
}
} else {
u.Errorf("could not convert to message reader: %T", msg.Body())
}
}
return "", false
}