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
3785b696
Commit
3785b696
authored
Sep 06, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Plain Diff
resolving conflicts
parents
f30c905f
d646c518
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
55 additions
and
51 deletions
+55
-51
.gitignore
.gitignore
+2
-2
Program.cs
samples/Sample.RabbitMQ.SqlServer/Program.cs
+20
-11
CAP.KafkaCapOptionsExtension.cs
src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs
+1
-1
CAP.RabbitMQCapOptionsExtension.cs
...otNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs
+1
-2
PublishQueueExecutor.cs
src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs
+5
-4
RabbitMQConsumerClientFactory.cs
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs
+2
-2
CAP.SqlServerCapOptionsExtension.cs
...NetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs
+13
-5
CAP.ServiceCollectionExtensions.cs
src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs
+0
-9
IBootstrapper.Default.cs
src/DotNetCore.CAP/IBootstrapper.Default.cs
+2
-5
IConsumerServiceSelector.Default.cs
...tNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs
+9
-10
No files found.
.gitignore
View file @
3785b696
...
...
@@ -35,7 +35,7 @@ bin/
/.idea
Properties
/pack.bat
/src/DotNetCore.CAP/DotNetCore.CAP.Net47.csproj
/src/DotNetCore.CAP/packages.config
/src/DotNetCore.CAP/project.json
/src/DotNetCore.CAP/packages.config
/src/DotNetCore.CAP/DotNetCore.CAP.Net47.csproj
/NuGet.config
samples/Sample.RabbitMQ.SqlServer/Program.cs
View file @
3785b696
using
System.IO
;
using
Microsoft.AspNetCore
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.Extensions.Configuration
;
...
...
@@ -7,22 +8,30 @@ namespace Sample.RabbitMQ.SqlServer
{
public
class
Program
{
//var config = new ConfigurationBuilder()
// .AddCommandLine(args)
// .AddEnvironmentVariables("ASPNETCORE_")
// .Build();
//var host = new WebHostBuilder()
// .UseConfiguration(config)
// .UseKestrel()
// .UseContentRoot(Directory.GetCurrentDirectory())
// .UseIISIntegration()
// .UseStartup<Startup>()
// .Build();
//host.Run();
public
static
void
Main
(
string
[]
args
)
{
var
config
=
new
ConfigurationBuilder
()
.
AddCommandLine
(
args
)
.
AddEnvironmentVariables
(
"ASPNETCORE_"
)
.
Build
();
BuildWebHost
(
args
).
Run
();
}
var
host
=
new
WebHostBuilder
()
.
UseConfiguration
(
config
)
.
UseKestrel
()
.
UseContentRoot
(
Directory
.
GetCurrentDirectory
())
.
UseIISIntegration
()
public
static
IWebHost
BuildWebHost
(
string
[]
args
)
=>
WebHost
.
CreateDefaultBuilder
(
args
)
.
UseStartup
<
Startup
>()
.
Build
();
host
.
Run
();
}
}
}
\ No newline at end of file
src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs
View file @
3785b696
...
...
@@ -21,7 +21,7 @@ namespace DotNetCore.CAP
services
.
AddSingleton
(
kafkaOptions
);
services
.
AddSingleton
<
IConsumerClientFactory
,
KafkaConsumerClientFactory
>();
services
.
Add
Transient
<
IQueueExecutor
,
PublishQueueExecutor
>();
services
.
Add
Singleton
<
IQueueExecutor
,
PublishQueueExecutor
>();
}
}
}
\ No newline at end of file
src/DotNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs
View file @
3785b696
...
...
@@ -23,9 +23,8 @@ namespace DotNetCore.CAP
services
.
AddSingleton
<
IConsumerClientFactory
,
RabbitMQConsumerClientFactory
>();
services
.
AddSingleton
<
ConnectionPool
>();
services
.
AddScoped
(
x
=>
x
.
GetService
<
ConnectionPool
>().
Rent
());
services
.
Add
Transient
<
IQueueExecutor
,
PublishQueueExecutor
>();
services
.
Add
Singleton
<
IQueueExecutor
,
PublishQueueExecutor
>();
}
}
}
\ No newline at end of file
src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs
View file @
3785b696
...
...
@@ -10,19 +10,19 @@ namespace DotNetCore.CAP.RabbitMQ
internal
sealed
class
PublishQueueExecutor
:
BasePublishQueueExecutor
{
private
readonly
ILogger
_logger
;
private
readonly
IConnection
_connection
;
private
readonly
ConnectionPool
_connectionPool
;
private
readonly
RabbitMQOptions
_rabbitMQOptions
;
public
PublishQueueExecutor
(
CapOptions
options
,
IStateChanger
stateChanger
,
IConnection
connection
,
ConnectionPool
connectionPool
,
RabbitMQOptions
rabbitMQOptions
,
ILogger
<
PublishQueueExecutor
>
logger
)
:
base
(
options
,
stateChanger
,
logger
)
{
_logger
=
logger
;
_connection
=
connection
;
_connection
Pool
=
connectionPool
;
_rabbitMQOptions
=
rabbitMQOptions
;
}
...
...
@@ -30,7 +30,8 @@ namespace DotNetCore.CAP.RabbitMQ
{
try
{
using
(
var
channel
=
_connection
.
CreateModel
())
var
connection
=
_connectionPool
.
Rent
();
using
(
var
channel
=
connection
.
CreateModel
())
{
var
body
=
Encoding
.
UTF8
.
GetBytes
(
content
);
...
...
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs
View file @
3785b696
...
...
@@ -9,10 +9,10 @@ namespace DotNetCore.CAP.RabbitMQ
private
readonly
IConnection
_connection
;
public
RabbitMQConsumerClientFactory
(
RabbitMQOptions
rabbitMQOptions
,
IConnection
connection
)
public
RabbitMQConsumerClientFactory
(
RabbitMQOptions
rabbitMQOptions
,
ConnectionPool
pool
)
{
_rabbitMQOptions
=
rabbitMQOptions
;
_connection
=
connection
;
_connection
=
pool
.
Rent
()
;
}
public
IConsumerClient
Create
(
string
groupId
)
...
...
src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs
View file @
3785b696
...
...
@@ -19,11 +19,15 @@ namespace DotNetCore.CAP
public
void
AddServices
(
IServiceCollection
services
)
{
services
.
AddSingleton
<
IStorage
,
SqlServerStorage
>();
services
.
AddS
coped
<
IStorageConnection
,
SqlServerStorageConnection
>();
services
.
Add
Scoped
<
ICapPublisher
,
CapPublisher
>();
services
.
AddS
ingleton
<
IStorageConnection
,
SqlServerStorageConnection
>();
services
.
Add
Transient
<
ICapPublisher
,
CapPublisher
>();
services
.
AddTransient
<
ICallbackPublisher
,
CapPublisher
>();
services
.
AddTransient
<
IAdditionalProcessor
,
DefaultAdditionalProcessor
>();
AddSqlServerOptions
(
services
);
}
private
void
AddSqlServerOptions
(
IServiceCollection
services
)
{
var
sqlServerOptions
=
new
SqlServerOptions
();
_configure
(
sqlServerOptions
);
...
...
@@ -32,9 +36,13 @@ namespace DotNetCore.CAP
{
services
.
AddSingleton
(
x
=>
{
var
dbContext
=
(
DbContext
)
x
.
GetService
(
sqlServerOptions
.
DbContextType
);
sqlServerOptions
.
ConnectionString
=
dbContext
.
Database
.
GetDbConnection
().
ConnectionString
;
return
sqlServerOptions
;
using
(
var
scope
=
x
.
CreateScope
())
{
var
provider
=
scope
.
ServiceProvider
;
var
dbContext
=
(
DbContext
)
provider
.
GetService
(
sqlServerOptions
.
DbContextType
);
sqlServerOptions
.
ConnectionString
=
dbContext
.
Database
.
GetDbConnection
().
ConnectionString
;
return
sqlServerOptions
;
}
});
}
else
...
...
src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs
View file @
3785b696
...
...
@@ -82,15 +82,6 @@ namespace Microsoft.Extensions.DependencyInjection
{
services
.
AddTransient
(
service
.
Key
,
service
.
Value
);
}
var
types
=
Assembly
.
GetEntryAssembly
().
ExportedTypes
;
foreach
(
var
type
in
types
)
{
if
(
Helper
.
IsController
(
type
.
GetTypeInfo
()))
{
services
.
AddTransient
(
typeof
(
object
),
type
);
}
}
}
}
}
\ No newline at end of file
src/DotNetCore.CAP/IBootstrapper.Default.cs
View file @
3785b696
...
...
@@ -25,14 +25,13 @@ namespace DotNetCore.CAP
IOptions
<
CapOptions
>
options
,
IStorage
storage
,
IApplicationLifetime
appLifetime
,
I
ServiceProvider
provider
)
I
Enumerable
<
IProcessingServer
>
servers
)
{
_logger
=
logger
;
_appLifetime
=
appLifetime
;
Options
=
options
.
Value
;
Storage
=
storage
;
Provider
=
provider
;
Servers
=
Provider
.
GetServices
<
IProcessingServer
>();
Servers
=
servers
;
_cts
=
new
CancellationTokenSource
();
_ctsRegistration
=
appLifetime
.
ApplicationStopping
.
Register
(()
=>
...
...
@@ -55,8 +54,6 @@ namespace DotNetCore.CAP
protected
IEnumerable
<
IProcessingServer
>
Servers
{
get
;
}
public
IServiceProvider
Provider
{
get
;
private
set
;
}
public
Task
BootstrapAsync
()
{
return
(
_bootstrappingTask
=
BootstrapTaskAsync
());
...
...
src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs
View file @
3785b696
...
...
@@ -67,17 +67,16 @@ namespace DotNetCore.CAP.Internal
IServiceProvider
provider
)
{
var
executorDescriptorList
=
new
List
<
ConsumerExecutorDescriptor
>();
// at cap startup time, find all Controller into the DI container,the type is object.
var
controllers
=
provider
.
GetServices
<
object
>();
foreach
(
var
controller
in
controllers
)
{
var
typeInfo
=
controller
.
GetType
().
GetTypeInfo
();
//double check
if
(!
Helper
.
IsController
(
typeInfo
))
continue
;
executorDescriptorList
.
AddRange
(
GetTopicAttributesDescription
(
typeInfo
));
}
var
types
=
Assembly
.
GetEntryAssembly
().
ExportedTypes
;
foreach
(
var
type
in
types
)
{
var
typeInfo
=
type
.
GetTypeInfo
();
if
(
Helper
.
IsController
(
typeInfo
))
{
executorDescriptorList
.
AddRange
(
GetTopicAttributesDescription
(
typeInfo
));
}
}
return
executorDescriptorList
;
}
...
...
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