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
612c63d1
Commit
612c63d1
authored
Dec 20, 2016
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addserver
parent
31006371
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
21 deletions
+74
-21
ConsistencyServer.cs
src/Cap.Consistency.Server/ConsistencyServer.cs
+56
-15
project.json
src/Cap.Consistency.Server/project.json
+7
-6
ConsistencyOptionsTest.cs
test/Cap.Consistency.Test/ConsistencyOptionsTest.cs
+11
-0
No files found.
src/Cap.Consistency.Server/ConsistencyServer.cs
View file @
612c63d1
...
@@ -6,35 +6,76 @@ using Microsoft.AspNetCore.Hosting;
...
@@ -6,35 +6,76 @@ using Microsoft.AspNetCore.Hosting;
using
Microsoft.AspNetCore.Hosting.Server
;
using
Microsoft.AspNetCore.Hosting.Server
;
using
Microsoft.AspNetCore.Http.Features
;
using
Microsoft.AspNetCore.Http.Features
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Options
;
using
Microsoft.AspNetCore.Hosting.Server.Features
;
using
System.Reflection
;
using
Cap.Consistency.Server.Internal.Infrastructure
;
using
Microsoft.Extensions.DependencyInjection
;
namespace
Cap.Consistency.Server
namespace
Cap.Consistency.Server
{
{
public
class
ConsistencyServer
:
IServer
public
class
ConsistencyServer
:
IServer
{
{
public
ConsistencyServer
(
IApplicationLifetime
applicationLifetime
,
ILoggerFactory
loggerFactory
)
private
Stack
<
IDisposable
>
_disposables
;
{
private
readonly
IApplicationLifetime
_applicationLifetime
;
if
(
applicationLifetime
==
null
)
private
readonly
ILogger
_logger
;
{
private
readonly
IServerAddressesFeature
_serverAddresses
;
private
readonly
IConsumer
_consumer
;
public
ConsistencyServer
(
IOptions
<
ConsistencyServerOptions
>
options
,
IApplicationLifetime
applicationLifetime
,
ILoggerFactory
loggerFactory
)
{
if
(
options
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
options
));
}
if
(
applicationLifetime
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
applicationLifetime
));
throw
new
ArgumentNullException
(
nameof
(
applicationLifetime
));
}
}
if
(
loggerFactory
==
null
)
if
(
loggerFactory
==
null
)
{
{
throw
new
ArgumentNullException
(
nameof
(
loggerFactory
));
throw
new
ArgumentNullException
(
nameof
(
loggerFactory
));
}
}
}
public
void
Start
<
TContext
>(
IHttpApplication
<
TContext
>
application
)
Options
=
options
.
Value
??
new
ConsistencyServerOptions
();
{
_applicationLifetime
=
applicationLifetime
;
throw
new
NotImplementedException
();
_logger
=
loggerFactory
.
CreateLogger
(
typeof
(
ConsistencyServer
).
GetTypeInfo
().
Namespace
);
_consumer
=
Options
.
ApplicationServices
.
GetService
<
IConsumer
>();
Features
=
new
FeatureCollection
();
_serverAddresses
=
new
ServerAddressesFeature
();
Features
.
Set
(
_serverAddresses
);
}
}
public
IFeatureCollection
Features
{
get
;
}
public
IFeatureCollection
Features
{
get
;
}
public
void
Dispose
()
public
ConsistencyServerOptions
Options
{
get
;
}
{
public
void
Start
<
TContext
>(
IHttpApplication
<
TContext
>
application
)
{
throw
new
NotImplementedException
();
if
(
_disposables
!=
null
)
{
// The server has already started and/or has not been cleaned up yet
throw
new
InvalidOperationException
(
"Server has already started."
);
}
_disposables
=
new
Stack
<
IDisposable
>();
var
trace
=
new
ConsistencyTrace
(
_logger
);
_disposables
.
Push
(
_consumer
);
var
threadCount
=
Options
.
ThreadCount
;
if
(
threadCount
<=
0
)
{
throw
new
ArgumentOutOfRangeException
(
nameof
(
threadCount
),
threadCount
,
"ThreadCount must be positive."
);
}
_consumer
.
Start
();
}
public
void
Dispose
()
{
if
(
_disposables
!=
null
)
{
while
(
_disposables
.
Count
>
0
)
{
_disposables
.
Pop
().
Dispose
();
}
_disposables
=
null
;
}
}
}
}
}
}
}
\ No newline at end of file
src/Cap.Consistency.Server/project.json
View file @
612c63d1
{
{
"version"
:
"1.0.0-*"
,
"version"
:
"1.0.0-*"
,
"buildOptions"
:
{
"buildOptions"
:
{
"debugType"
:
"portable"
"debugType"
:
"portable"
},
},
"dependencies"
:
{
"dependencies"
:
{
"Microsoft.AspNetCore.Hosting"
:
"1.1.0-*"
,
"Microsoft.AspNetCore.Hosting"
:
"1.1.0-*"
,
"Microsoft.Extensions.Logging.Abstractions"
:
"1.1.0-*"
,
"Microsoft.Extensions.Logging.Abstractions"
:
"1.1.0-*"
,
"NETStandard.Library"
:
"1.6.1"
"Microsoft.Extensions.Options"
:
"1.1.0"
,
},
"NETStandard.Library"
:
"1.6.1"
},
"frameworks"
:
{
"frameworks"
:
{
"netstandard1.6"
:
{
"netstandard1.6"
:
{
"imports"
:
"dnxcore50"
"imports"
:
"dnxcore50"
...
...
test/Cap.Consistency.Test/ConsistencyOptionsTest.cs
0 → 100644
View file @
612c63d1
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Cap.Consistency.Test
{
public
class
ConsistencyOptionsTest
{
}
}
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