Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
ShopERP
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杜龙飞
ShopERP
Commits
a173fcf6
Commit
a173fcf6
authored
Jul 29, 2025
by
PC-20220610JUCQ\Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
<develop>:(ShopERP 端)<无> ApiGateWay 参数 Datacenter 优化。
parent
be311504
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
ShopERP.Ocelot.ApiGateWay/Infrastructure/ConsulServiceDiscover.cs
+9
-5
No files found.
ShopERP.Ocelot.ApiGateWay/Infrastructure/ConsulServiceDiscover.cs
View file @
a173fcf6
...
...
@@ -27,18 +27,22 @@ namespace ShopERP.Ocelot.ApiGateWay.Infrastructure
using
(
ConsulClient
client
=
new
ConsulClient
(
c
=>
{
c
.
Address
=
new
Uri
(
_configuration
[
"Consul:consulAddress"
]);
c
.
Datacenter
=
"
apiService
"
;
c
.
Datacenter
=
"
dc1
"
;
}))
{
//根据服务名获取健康的服务
var
queryResult
=
client
.
Health
.
Service
(
serviceName
,
string
.
Empty
,
true
);
var
len
=
queryResult
.
Result
.
Response
.
Length
;
//平均策略-多个负载中随机获取一个
var
node
=
queryResult
.
Result
.
Response
[
new
Random
().
Next
(
len
)];
if
(
queryResult
!=
null
&&
queryResult
.
Result
!=
null
)
{
var
len
=
queryResult
.
Result
.
Response
.
Length
;
domain
=
$"http://
{
node
.
Service
.
Address
}
:
{
node
.
Service
.
Port
}
"
;
//平均策略-多个负载中随机获取一个
var
node
=
queryResult
.
Result
.
Response
[
new
Random
().
Next
(
len
)];
domain
=
$"http://
{
node
.
Service
.
Address
}
:
{
node
.
Service
.
Port
}
"
;
}
}
return
domain
;
...
...
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