Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-common
Commits
7d97d8b6
Commit
7d97d8b6
authored
Mar 16, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:去掉不必要的fatal,保留最后的连接userCenter的fatal
parent
483fd7af
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
27 deletions
+25
-27
user_center.go
rpc/user_center.go
+25
-27
No files found.
rpc/user_center.go
View file @
7d97d8b6
...
...
@@ -70,31 +70,26 @@ func (b *Builder) UpdateState(addrs []string) {
}
func
init
()
{
client
,
err
:=
consulapi
.
NewClient
(
consulapi
.
DefaultConfig
())
//非默认情况下需要设置实际的参数
mylogrus
.
MyLog
.
Infoln
(
client
,
err
)
if
err
!=
nil
{
mylogrus
.
MyLog
.
Fatalln
(
err
)
}
if
client
==
nil
{
mylogrus
.
MyLog
.
Fatalln
(
"Fail to get consul client."
)
}
// 本地环境下不需要userCenter
if
config
.
AppIsLocal
()
{
mylogrus
.
MyLog
.
Infoln
(
"userCenter is not required in local env."
)
return
}
client
,
err
:=
consulapi
.
NewClient
(
consulapi
.
DefaultConfig
())
//非默认情况下需要设置实际的参数
if
err
!=
nil
||
client
==
nil
{
mylogrus
.
MyLog
.
Errorf
(
"consul client fail:%v-%v"
,
err
,
client
)
}
// 服务发现
bd
:=
&
Builder
{
addrs
:
map
[
string
][]
string
{
"/api"
:
{
userCenterAddr
}}}
if
client
!=
nil
{
cataLog
:=
client
.
Catalog
()
if
cataLog
==
nil
{
mylogrus
.
MyLog
.
Fatalln
(
"No catalog."
)
}
if
cataLog
!=
nil
{
services
,
_
,
err
:=
cataLog
.
Service
(
"userCenter"
,
""
,
nil
)
if
err
!=
nil
{
mylogrus
.
MyLog
.
Fatalln
(
err
)
mylogrus
.
MyLog
.
Errorf
(
"cataLog.Service:err%v"
,
err
)
}
if
len
(
services
)
==
0
{
mylogrus
.
MyLog
.
Fatalln
(
"userCenter not found."
)
mylogrus
.
MyLog
.
Errorf
(
"userCenter not found."
)
}
var
addrs
[]
string
for
_
,
s
:=
range
services
{
...
...
@@ -105,6 +100,9 @@ func init() {
userCenterAddr
=
"uc:///api"
}
mylogrus
.
MyLog
.
Infof
(
"userCenterAddr:%v,addr:%v"
,
userCenterAddr
,
addrs
)
}
}
mylogrus
.
MyLog
.
Infof
(
"connect userCenterAddr:%v"
,
userCenterAddr
)
resolver
.
Register
(
bd
)
go
func
()
{
address
:=
consulapi
.
DefaultConfig
()
.
Address
// 用consul api的default config
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment