Browse Source

连接服务时增加配置判断

master v0.6.5
guzeng 3 years ago
parent
commit
6b7051ea95
4 changed files with 16 additions and 4 deletions
  1. +1
    -1
      client.siteinfo_test.go
  2. +12
    -3
      common.go
  3. +1
    -0
      go.mod
  4. +2
    -0
      go.sum

+ 1
- 1
client.siteinfo_test.go View File

@ -6,7 +6,7 @@ import (
func Test_GetSiteInfoByHost(t *testing.T) { func Test_GetSiteInfoByHost(t *testing.T) {
res, err := GetSiteInfoByHost("http://devmaster.tetele.net", "dev.tetele.net")
res, err := GetSiteInfoByHost("dev.tetele.net")
t.Log(res) t.Log(res)
t.Log(err) t.Log(err)


+ 12
- 3
common.go View File

@ -1,14 +1,23 @@
package siterpc package siterpc
import (
"git.tetele.net/tgo/conf"
)
var DES_KEY = "confdata" var DES_KEY = "confdata"
func rpc_server_conn(url ...string) (*SiteServiceClient, error) { func rpc_server_conn(url ...string) (*SiteServiceClient, error) {
var wx_rpc_url string = "127.0.0.1:7971"
var rpc_url string
if len(url) > 0 && url[0] != "" { if len(url) > 0 && url[0] != "" {
wx_rpc_url = url[0]
rpc_url = url[0]
} else if conf.SITE_RPC_URL != "" {
rpc_url = conf.SITE_RPC_URL
} else {
rpc_url = "127.0.0.1:" + conf.SITE_RPC_PORT
} }
conn, _, err := DialSiteService("tcp", wx_rpc_url)
conn, _, err := DialSiteService("tcp", rpc_url)
if err != nil { if err != nil {
return nil, err return nil, err
} }


+ 1
- 0
go.mod View File

@ -3,6 +3,7 @@ module git.tetele.net/tgo/siterpc
go 1.14 go 1.14
require ( require (
git.tetele.net/tgo/conf v0.33.1 // indirect
git.tetele.net/tgo/crypter v0.2.2 // indirect git.tetele.net/tgo/crypter v0.2.2 // indirect
github.com/chai2010/protorpc v1.0.0 // indirect github.com/chai2010/protorpc v1.0.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect github.com/golang/protobuf v1.5.2 // indirect


+ 2
- 0
go.sum View File

@ -1,3 +1,5 @@
git.tetele.net/tgo/conf v0.33.1 h1:ZEIv3Vq35RCv5f3T3Uz97s2mkZLl7W5OlmXvzI3/sS8=
git.tetele.net/tgo/conf v0.33.1/go.mod h1:AWVIBEDE5dtotthUgR0SWaR2Qa6/f+O5WQ3s7Tj8q7A=
git.tetele.net/tgo/crypter v0.2.2 h1:YMQJh2Gj5Po4ZfelJUmXBKi01UbmtiSy3bmqRfnYQMo= git.tetele.net/tgo/crypter v0.2.2 h1:YMQJh2Gj5Po4ZfelJUmXBKi01UbmtiSy3bmqRfnYQMo=
git.tetele.net/tgo/crypter v0.2.2/go.mod h1:vfvRLZA8+lHNgNXneOcgvVhDyuv25ZRb+C6xHOmXNx0= git.tetele.net/tgo/crypter v0.2.2/go.mod h1:vfvRLZA8+lHNgNXneOcgvVhDyuv25ZRb+C6xHOmXNx0=
github.com/chai2010/protorpc v1.0.0 h1:aJ45G9sl1utSKo35EqnBSTs5jqTpdJDJAuZMMYPAtFo= github.com/chai2010/protorpc v1.0.0 h1:aJ45G9sl1utSKo35EqnBSTs5jqTpdJDJAuZMMYPAtFo=


Loading…
Cancel
Save