Skip to content

Commit

Permalink
1.code formating
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Nov 25, 2016
1 parent 9f99423 commit 44754a0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 47 deletions.
47 changes: 23 additions & 24 deletions src/invok/invokerDesc.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,29 @@ class invokerDesc{
private $version = " ";
private $schema = 'jsonrpc';

public function __construct($serviceName, $version=null, $group=null){
$this->serviceName = $serviceName ;
$this->version = $version;
$this->group = $group;
}

public function getService(){
return $this->serviceName;
}

public function toString(){
$group_str = isset($this->group) ? $this->group : ' ';
$version_str = isset($this->version) ? $this->version : ' ';
return $this->serviceName.'_'.$group_str.'_'.$version_str.'_'.$this->schema;
}

public function isMatch($group,$version){
return $this->group === $group && $this->version === $version;
}

public function isMatchDesc($desc){
return $this->group == $desc->group && $this->version == $desc->version;
}

public function __construct($serviceName, $version=null, $group=null){
$this->serviceName = $serviceName ;
$this->version = $version;
$this->group = $group;
}

public function getService(){
return $this->serviceName;
}

public function toString(){
$group_str = isset($this->group) ? $this->group : ' ';
$version_str = isset($this->version) ? $this->version : ' ';
return $this->serviceName.'_'.$group_str.'_'.$version_str.'_'.$this->schema;
}

public function isMatch($group,$version){
return $this->group === $group && $this->version === $version;
}

public function isMatchDesc($desc){
return $this->group == $desc->group && $this->version == $desc->version;
}

}

Expand Down
42 changes: 19 additions & 23 deletions src/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,17 @@ public function getInvoker($invokerDesc){
}



public function configurators(){
return true;
}



protected function getSubscribePath($serviceName){
return '/dubbo/' .$serviceName.'/providers';
}

protected function getRegistryAddress() {
return $this->config['registry_address'];
return $this->config['registry_address'];
}


Expand All @@ -135,7 +133,7 @@ private function makeRegistryNode($serviceName, $application = array()){
$params = http_build_query($application);
$url = '/dubbo/'.$serviceName.'/consumers/'.urlencode('consumer://'.$this->ip.'/'.$serviceName.'?').$params;
return $url;
}
}


/**
Expand All @@ -151,11 +149,11 @@ private function makeRegistryPath($serviceName, $application = array()){


protected function getConfiguratorsPath($serviceName){
return '/dubbo/'.$serviceName.'/configurators';
return '/dubbo/'.$serviceName.'/configurators';
}

protected function getProviderTimeout(){
return $this->config['provider_timeout'] * 1000;
return $this->config['provider_timeout'] * 1000;
}


Expand All @@ -171,27 +169,25 @@ public function zkinfo($invokerDesc){
* we will get from the command.
*/
private function achieveRegisterIp(){
try {
$registerIp = gethostbyaddr($_SERVER['SERVER_ADDR']);
if (empty($registerIp)) {
if (substr(strtolower(PHP_OS), 0, 3) != 'win') {
$ss = exec('/sbin/ifconfig | sed -n \'s/^ *.*addr:\\([0-9.]\\{7,\\}\\) .*$/\\1/p\'', $arr);
$registerIp = $arr[0];
}else{
/** @TODO
* @ implement the windows ip
**/
try {
$registerIp = gethostbyaddr($_SERVER['SERVER_ADDR']);
if (empty($registerIp)) {
if (substr(strtolower(PHP_OS), 0, 3) != 'win') {
$ss = exec('/sbin/ifconfig | sed -n \'s/^ *.*addr:\\([0-9.]\\{7,\\}\\) .*$/\\1/p\'', $arr);
$registerIp = $arr[0];
}else{
/** @TODO
* @ implement the windows ip
**/
}
}
}catch (\Exception $e){
error_log("We can't get your local ip address.\n");
error_log($e->getMessage()."\n");
}
}catch (\Exception $e){
error_log("We can't get your local ip address.\n");
error_log($e->getMessage()."\n");
return $registerIp;
}
return $registerIp;
}


}


?>

0 comments on commit 44754a0

Please sign in to comment.