本文整理汇总了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
}
开发者ID:jmptrader,项目名称:qlbridge,代码行数:25,代码来源:source.go
示例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
}
开发者ID:schmichael,项目名称:qlbridge,代码行数:32,代码来源:results.go
示例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
}
开发者ID:schmichael,项目名称:qlbridge,代码行数:44,代码来源:source.go
注:本文中的github.com/araddon/qlbridge/datasource.Message类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论