Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
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
tsai
CAP
Commits
4457e98d
Commit
4457e98d
authored
Sep 26, 2017
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add CapCache to cache server nodes.
parent
7766d408
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
324 additions
and
14 deletions
+324
-14
SqlServerMonitoringApi.cs
src/DotNetCore.CAP.SqlServer/SqlServerMonitoringApi.cs
+0
-1
CapCache.cs
src/DotNetCore.CAP/CapCache.cs
+299
-0
RazorPage.cs
src/DotNetCore.CAP/Dashboard/RazorPage.cs
+8
-1
INodeDiscoveryProvider.Consul.cs
...etCore.CAP/NodeDiscovery/INodeDiscoveryProvider.Consul.cs
+17
-12
No files found.
src/DotNetCore.CAP.SqlServer/SqlServerMonitoringApi.cs
View file @
4457e98d
...
...
@@ -55,7 +55,6 @@ _options.Schema);
}
return
stats
;
});
statistics
.
Servers
=
1
;
return
statistics
;
}
...
...
src/DotNetCore.CAP/CapCache.cs
0 → 100644
View file @
4457e98d
This diff is collapsed.
Click to expand it.
src/DotNetCore.CAP/Dashboard/RazorPage.cs
View file @
4457e98d
...
...
@@ -84,7 +84,14 @@ namespace DotNetCore.CAP.Dashboard
_statisticsLazy
=
new
Lazy
<
StatisticsDto
>(()
=>
{
var
monitoring
=
Storage
.
GetMonitoringApi
();
return
monitoring
.
GetStatistics
();
var
dto
=
monitoring
.
GetStatistics
();
if
(
CapCache
.
Global
.
TryGet
(
"cap.nodes.count"
,
out
object
count
))
{
dto
.
Servers
=
(
int
)
count
;
}
return
dto
;
});
}
...
...
src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.Consul.cs
View file @
4457e98d
using
System
;
using
System.Linq
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Consul
;
using
System.Net
;
namespace
DotNetCore.CAP.NodeDiscovery
{
...
...
@@ -24,24 +22,31 @@ namespace DotNetCore.CAP.NodeDiscovery
{
_consul
=
new
ConsulClient
(
config
=>
{
config
.
WaitTime
=
TimeSpan
.
FromSeconds
(
5
);
config
.
Address
=
new
Uri
(
$"http://
{
_options
.
DiscoveryServerHostName
}
:
{
_options
.
DiscoveryServerProt
}
"
);
});
}
public
async
Task
<
IList
<
Node
>>
GetNodes
()
{
var
services
=
await
_consul
.
Agent
.
Services
();
try
{
var
services
=
await
_consul
.
Agent
.
Services
();
var
nodes
=
services
.
Response
.
Select
(
x
=>
new
Node
{
Id
=
x
.
Key
,
Name
=
x
.
Value
.
Service
,
Address
=
x
.
Value
.
Address
,
Port
=
x
.
Value
.
Port
,
Tags
=
string
.
Join
(
", "
,
x
.
Value
.
Tags
)
});
var
nodes
=
services
.
Response
.
Select
(
x
=>
new
Node
{
Id
=
x
.
Key
,
Name
=
x
.
Value
.
Service
,
Address
=
x
.
Value
.
Address
,
Port
=
x
.
Value
.
Port
,
Tags
=
string
.
Join
(
", "
,
x
.
Value
.
Tags
)
});
CapCache
.
Global
.
AddOrUpdate
(
"cap.nodes.count"
,
nodes
.
Count
(),
TimeSpan
.
FromSeconds
(
30
),
true
);
return
nodes
.
ToList
();
return
nodes
.
ToList
();
}
catch
(
Exception
)
{
return
null
;
}
}
public
Task
RegisterNode
()
...
...
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