in provider/core/server/FSOFRegistry.php [128:198]
protected function ServiceSerialize()
{
try
{
unset($this->fsofUrlList);
if (!empty($this->serverProviders))
{
if ($this->ephemeral)
{
//注册时间
//$this->config["service_properties"]["timestamp"] = (int)(microtime(true) * 1000);
$this->config["service_properties"]["dynamic"] = "true";
}
else
{
$this->config["service_properties"]["dynamic"] = "false";
}
$services = $this->serverProviders;
foreach ($services as $interface => $serviceInfo)
{
//合并全局配置
if (isset($this->config["service_properties"]))
{
//接口配置优先级高于全局配置,所以$serviceInfo放后面
$serviceInfo = array_merge($this->config["service_properties"], $serviceInfo);
}
//不用上报的信息去掉
unset($serviceInfo['service']);
unset($serviceInfo['p2p_mode']);
if (empty($serviceInfo["version"]))
{
$serviceInfo['version'] = FSOFConstants::FSOF_SERVICE_VERSION_DEFAULT;
}
//与dubbo兼容处理
$serviceInfo['interface'] = $interface;//dubbo_admin需要使用
//序列化方式
$serviceInfo['serialization']= "fastjson";
ksort($serviceInfo);//参数排序,与dubbo兼容
$urlPara = array(
'scheme' => 'dubbo',
'host' => $this->localIp,
'port' => $this->port,
'path' => '/' . $interface,
//http_build_query会进行urlencode导致query参数被多编码一次,使用urldecode抵消
'query' => urldecode(http_build_query($serviceInfo)),
);
$this->logger->debug("serviceInfo:" . json_encode($serviceInfo) . "|urlPara:" . json_encode($urlPara));
try
{
$fsofUrl = new FSOFUrl($urlPara);
}
catch (\Exception $e)
{
$this->logger->error('init url failed|app:' . $this->appName . '|urlPara:' . json_encode($urlPara));
}
$this->fsofUrlList[] = $fsofUrl;
}
}
}
catch(\Exception $e)
{
$errMsg = $e->getMessage();
$this->logger->error('ServiceSerialize:'.$errMsg, $e);
}
}