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
9765e35c
Commit
9765e35c
authored
Jun 20, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename class.
parent
30e52966
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
12 deletions
+26
-12
IConsumerHandler.cs
src/Cap.Consistency/Consumer/IConsumerHandler.cs
+2
-1
IBootstrapper.Default.cs
src/Cap.Consistency/IBootstrapper.Default.cs
+23
-10
IProcessingServer.cs
src/Cap.Consistency/IProcessingServer.cs
+1
-1
No files found.
src/Cap.Consistency/Consumer/IConsumerHandler.cs
View file @
9765e35c
namespace
Cap.Consistency.Consumer
namespace
Cap.Consistency.Consumer
{
{
public
interface
IConsumerHandler
:
I
Topic
Server
public
interface
IConsumerHandler
:
I
Processing
Server
{
{
}
}
}
}
\ No newline at end of file
src/Cap.Consistency/IBootstrapper.
Base
.cs
→
src/Cap.Consistency/IBootstrapper.
Default
.cs
View file @
9765e35c
using
System
;
using
System
;
using
System.Linq
;
using
System.Collections.Generic
;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Cap.Consistency.Infrastructure
;
using
Cap.Consistency.Infrastructure
;
using
Cap.Consistency.Store
;
using
Cap.Consistency.Store
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Options
;
namespace
Cap.Consistency
namespace
Cap.Consistency
{
{
public
abstract
class
BootstrapperBase
:
IBootstrapper
public
class
DefaultBootstrapper
:
IBootstrapper
{
{
private
IApplicationLifetime
_appLifetime
;
private
IApplicationLifetime
_appLifetime
;
private
CancellationTokenSource
_cts
;
private
CancellationTokenSource
_cts
;
private
CancellationTokenRegistration
_ctsRegistration
;
private
CancellationTokenRegistration
_ctsRegistration
;
private
Task
_bootstrappingTask
;
private
Task
_bootstrappingTask
;
public
BootstrapperBase
(
public
DefaultBootstrapper
(
ConsistencyOptions
options
,
IOptions
<
ConsistencyOptions
>
options
,
ConsistencyMessageManager
storage
,
ConsistencyMessageManager
storage
,
ITopicServer
server
,
IApplicationLifetime
appLifetime
,
IApplicationLifetime
appLifetime
,
IServiceProvider
provider
)
{
IServiceProvider
provider
)
{
Options
=
options
;
Options
=
options
.
Value
;
Storage
=
storage
;
Storage
=
storage
;
Server
=
server
;
_appLifetime
=
appLifetime
;
_appLifetime
=
appLifetime
;
Provider
=
provider
;
Provider
=
provider
;
Servers
=
Provider
.
GetServices
<
IProcessingServer
>();
_cts
=
new
CancellationTokenSource
();
_cts
=
new
CancellationTokenSource
();
_ctsRegistration
=
appLifetime
.
ApplicationStopping
.
Register
(()
=>
{
_ctsRegistration
=
appLifetime
.
ApplicationStopping
.
Register
(()
=>
{
_cts
.
Cancel
();
_cts
.
Cancel
();
...
@@ -41,7 +44,7 @@ namespace Cap.Consistency
...
@@ -41,7 +44,7 @@ namespace Cap.Consistency
protected
ConsistencyMessageManager
Storage
{
get
;
}
protected
ConsistencyMessageManager
Storage
{
get
;
}
protected
I
TopicServer
Server
{
get
;
}
protected
I
Enumerable
<
IProcessingServer
>
Servers
{
get
;
}
public
IServiceProvider
Provider
{
get
;
private
set
;
}
public
IServiceProvider
Provider
{
get
;
private
set
;
}
...
@@ -57,14 +60,24 @@ namespace Cap.Consistency
...
@@ -57,14 +60,24 @@ namespace Cap.Consistency
await
BootstrapCoreAsync
();
await
BootstrapCoreAsync
();
if
(
_cts
.
IsCancellationRequested
)
return
;
if
(
_cts
.
IsCancellationRequested
)
return
;
Server
.
Start
();
foreach
(
var
item
in
Servers
)
{
try
{
item
.
Start
();
}
catch
(
Exception
)
{
}
}
_ctsRegistration
.
Dispose
();
_ctsRegistration
.
Dispose
();
_cts
.
Dispose
();
_cts
.
Dispose
();
}
}
public
virtual
Task
BootstrapCoreAsync
()
{
public
virtual
Task
BootstrapCoreAsync
()
{
_appLifetime
.
ApplicationStopping
.
Register
(()
=>
Server
.
Dispose
());
_appLifetime
.
ApplicationStopping
.
Register
(()
=>
{
foreach
(
var
item
in
Servers
)
{
item
.
Dispose
();
}
});
return
Task
.
FromResult
(
0
);
return
Task
.
FromResult
(
0
);
}
}
}
}
...
...
src/Cap.Consistency/I
Topic
Server.cs
→
src/Cap.Consistency/I
Processing
Server.cs
View file @
9765e35c
...
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
...
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
namespace
Cap.Consistency
namespace
Cap.Consistency
{
{
public
interface
I
Topic
Server
:
IDisposable
public
interface
I
Processing
Server
:
IDisposable
{
{
void
Start
();
void
Start
();
}
}
...
...
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