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
6cdfc50c
Commit
6cdfc50c
authored
Oct 31, 2017
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring
parent
3f7d9e12
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
23 deletions
+23
-23
IBootstrapper.Default.cs
src/DotNetCore.CAP/IBootstrapper.Default.cs
+18
-18
LoggerExtensions.cs
src/DotNetCore.CAP/LoggerExtensions.cs
+5
-5
No files found.
src/DotNetCore.CAP/IBootstrapper.Default.cs
View file @
6cdfc50c
...
...
@@ -19,6 +19,10 @@ namespace DotNetCore.CAP
private
readonly
ILogger
<
DefaultBootstrapper
>
_logger
;
private
Task
_bootstrappingTask
;
private
IStorage
Storage
{
get
;
}
private
IEnumerable
<
IProcessingServer
>
Processors
{
get
;
}
public
DefaultBootstrapper
(
ILogger
<
DefaultBootstrapper
>
logger
,
IStorage
storage
,
...
...
@@ -45,10 +49,6 @@ namespace DotNetCore.CAP
});
}
protected
IStorage
Storage
{
get
;
}
protected
IEnumerable
<
IProcessingServer
>
Processors
{
get
;
}
public
Task
BootstrapAsync
()
{
return
_bootstrappingTask
=
BootstrapTaskAsync
();
...
...
@@ -60,10 +60,22 @@ namespace DotNetCore.CAP
if
(
_cts
.
IsCancellationRequested
)
return
;
await
BootstrapCoreAsync
();
_appLifetime
.
ApplicationStopping
.
Register
(()
=>
{
foreach
(
var
item
in
Processors
)
item
.
Dispose
();
});
if
(
_cts
.
IsCancellationRequested
)
return
;
await
BootstrapCoreAsync
();
_ctsRegistration
.
Dispose
();
_cts
.
Dispose
();
}
protected
virtual
Task
BootstrapCoreAsync
()
{
foreach
(
var
item
in
Processors
)
try
{
...
...
@@ -71,20 +83,8 @@ namespace DotNetCore.CAP
}
catch
(
Exception
ex
)
{
_logger
.
Server
StartedError
(
ex
);
_logger
.
Processors
StartedError
(
ex
);
}
_ctsRegistration
.
Dispose
();
_cts
.
Dispose
();
}
public
virtual
Task
BootstrapCoreAsync
()
{
_appLifetime
.
ApplicationStopping
.
Register
(()
=>
{
foreach
(
var
item
in
Processors
)
item
.
Dispose
();
});
return
Task
.
CompletedTask
;
}
}
...
...
src/DotNetCore.CAP/LoggerExtensions.cs
View file @
6cdfc50c
...
...
@@ -6,7 +6,7 @@ namespace DotNetCore.CAP
internal
static
class
LoggerExtensions
{
private
static
readonly
Action
<
ILogger
,
int
,
int
,
Exception
>
_serverStarting
;
private
static
readonly
Action
<
ILogger
,
Exception
>
_
server
StartingError
;
private
static
readonly
Action
<
ILogger
,
Exception
>
_
processors
StartingError
;
private
static
readonly
Action
<
ILogger
,
Exception
>
_serverShuttingDown
;
private
static
readonly
Action
<
ILogger
,
string
,
Exception
>
_expectedOperationCanceledException
;
...
...
@@ -31,10 +31,10 @@ namespace DotNetCore.CAP
1
,
"Starting the processing server. Detected {MachineProcessorCount} machine processor(s). Initiating {ProcessorCount} job processor(s)."
);
_
server
StartingError
=
LoggerMessage
.
Define
(
_
processors
StartingError
=
LoggerMessage
.
Define
(
LogLevel
.
Error
,
5
,
"Starting the process
ing server
throw an exception."
);
"Starting the process
ors
throw an exception."
);
_serverShuttingDown
=
LoggerMessage
.
Define
(
LogLevel
.
Debug
,
...
...
@@ -149,9 +149,9 @@ namespace DotNetCore.CAP
_serverStarting
(
logger
,
machineProcessorCount
,
processorCount
,
null
);
}
public
static
void
Server
StartedError
(
this
ILogger
logger
,
Exception
ex
)
public
static
void
Processors
StartedError
(
this
ILogger
logger
,
Exception
ex
)
{
_
server
StartingError
(
logger
,
ex
);
_
processors
StartingError
(
logger
,
ex
);
}
public
static
void
ServerShuttingDown
(
this
ILogger
logger
)
...
...
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