浏览代码

fix optional settings issue (#309)

jinfahua 4 年之前
父节点
当前提交
6ed3074d93
共有 1 个文件被更改,包括 3 次插入4 次删除
  1. 3 4
      xstream/extensions/edgex_source.go

+ 3 - 4
xstream/extensions/edgex_source.go

@@ -64,15 +64,13 @@ func (es *EdgexSource) Configure(device string, props map[string]interface{}) er
 	}
 
 	mbconf := types.MessageBusConfig{SubscribeHost: types.HostInfo{Protocol: protocol, Host: server, Port: port}, Type: mbusType}
-	common.Log.Infof("Use configuration for edgex messagebus %v\n", mbconf)
 
 	var optional = make(map[string]string)
 	if ops, ok := props["optional"]; ok {
-		if ops1, ok1 := ops.(map[interface{}]interface{}); ok1 {
+		if ops1, ok1 := ops.(map[string]interface{}); ok1 {
 			for k, v := range ops1 {
-				k1 := k.(string)
 				if cv, ok := CastToString(v); ok {
-					optional[k1] = cv
+					optional[k] = cv
 				} else {
 					common.Log.Infof("Cannot convert configuration %s: %s to string type.\n", k, v)
 				}
@@ -80,6 +78,7 @@ func (es *EdgexSource) Configure(device string, props map[string]interface{}) er
 		}
 		mbconf.Optional = optional
 	}
+	common.Log.Infof("Use configuration for edgex messagebus %v\n", mbconf)
 
 	if client, err := messaging.NewMessageClient(mbconf); err != nil {
 		return err