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
7d1fe75b
Commit
7d1fe75b
authored
Aug 26, 2018
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename mongdb publisher
parent
b136e21d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
14 deletions
+20
-14
CAP.MongoDBCapOptionsExtension.cs
src/DotNetCore.CAP.MongoDB/CAP.MongoDBCapOptionsExtension.cs
+2
-2
ICapPublisher.MongoDB.cs
src/DotNetCore.CAP.MongoDB/ICapPublisher.MongoDB.cs
+18
-12
No files found.
src/DotNetCore.CAP.MongoDB/CAP.MongoDBCapOptionsExtension.cs
View file @
7d1fe75b
...
@@ -23,8 +23,8 @@ namespace DotNetCore.CAP.MongoDB
...
@@ -23,8 +23,8 @@ namespace DotNetCore.CAP.MongoDB
services
.
AddSingleton
<
IStorage
,
MongoDBStorage
>();
services
.
AddSingleton
<
IStorage
,
MongoDBStorage
>();
services
.
AddSingleton
<
IStorageConnection
,
MongoDBStorageConnection
>();
services
.
AddSingleton
<
IStorageConnection
,
MongoDBStorageConnection
>();
services
.
AddScoped
<
ICapPublisher
,
Cap
Publisher
>();
services
.
AddScoped
<
ICapPublisher
,
MongoDB
Publisher
>();
services
.
AddScoped
<
ICallbackPublisher
,
Cap
Publisher
>();
services
.
AddScoped
<
ICallbackPublisher
,
MongoDB
Publisher
>();
services
.
AddTransient
<
ICollectProcessor
,
MongoDBCollectProcessor
>();
services
.
AddTransient
<
ICollectProcessor
,
MongoDBCollectProcessor
>();
services
.
AddTransient
<
CapTransactionBase
,
MongoDBCapTransaction
>();
services
.
AddTransient
<
CapTransactionBase
,
MongoDBCapTransaction
>();
...
...
src/DotNetCore.CAP.MongoDB/
CapPublisher
.cs
→
src/DotNetCore.CAP.MongoDB/
ICapPublisher.MongoDB
.cs
View file @
7d1fe75b
...
@@ -11,14 +11,16 @@ using MongoDB.Driver;
...
@@ -11,14 +11,16 @@ using MongoDB.Driver;
namespace
DotNetCore.CAP.MongoDB
namespace
DotNetCore.CAP.MongoDB
{
{
public
class
Cap
Publisher
:
CapPublisherBase
,
ICallbackPublisher
public
class
MongoDB
Publisher
:
CapPublisherBase
,
ICallbackPublisher
{
{
private
readonly
MongoDBOptions
_options
;
private
readonly
MongoDBOptions
_options
;
private
readonly
IMongoClient
_client
;
public
Cap
Publisher
(
IServiceProvider
provider
,
MongoDBOptions
options
)
public
MongoDB
Publisher
(
IServiceProvider
provider
,
MongoDBOptions
options
)
:
base
(
provider
)
:
base
(
provider
)
{
{
_options
=
options
;
_options
=
options
;
_client
=
ServiceProvider
.
GetRequiredService
<
IMongoClient
>();
}
}
public
async
Task
PublishCallbackAsync
(
CapPublishedMessage
message
)
public
async
Task
PublishCallbackAsync
(
CapPublishedMessage
message
)
...
@@ -29,22 +31,26 @@ namespace DotNetCore.CAP.MongoDB
...
@@ -29,22 +31,26 @@ namespace DotNetCore.CAP.MongoDB
protected
override
Task
ExecuteAsync
(
CapPublishedMessage
message
,
ICapTransaction
transaction
,
protected
override
Task
ExecuteAsync
(
CapPublishedMessage
message
,
ICapTransaction
transaction
,
CancellationToken
cancel
=
default
(
CancellationToken
))
CancellationToken
cancel
=
default
(
CancellationToken
))
{
{
var
dbTrans
=
(
IClientSessionHandle
)
transaction
.
DbTransaction
;
var
insertOptions
=
new
InsertOneOptions
{
BypassDocumentValidation
=
false
}
;
var
collection
=
dbTrans
.
C
lient
var
collection
=
_c
lient
.
GetDatabase
(
_options
.
DatabaseName
)
.
GetDatabase
(
_options
.
DatabaseName
)
.
GetCollection
<
CapPublishedMessage
>(
_options
.
PublishedCollection
);
.
GetCollection
<
CapPublishedMessage
>(
_options
.
PublishedCollection
);
var
insertOptions
=
new
InsertOneOptions
{
BypassDocumentValidation
=
false
};
if
(
NotUseTransaction
)
{
return
collection
.
InsertOneAsync
(
message
,
insertOptions
,
cancel
);
}
var
dbTrans
=
(
IClientSessionHandle
)
transaction
.
DbTransaction
;
return
collection
.
InsertOneAsync
(
dbTrans
,
message
,
insertOptions
,
cancel
);
return
collection
.
InsertOneAsync
(
dbTrans
,
message
,
insertOptions
,
cancel
);
}
}
protected
override
object
GetDbTransaction
()
//
protected override object GetDbTransaction()
{
//
{
var
client
=
ServiceProvider
.
GetRequiredService
<
IMongoClient
>();
//
var client = ServiceProvider.GetRequiredService<IMongoClient>();
var
session
=
client
.
StartSession
(
new
ClientSessionOptions
());
//
var session = client.StartSession(new ClientSessionOptions());
session
.
StartTransaction
();
//
session.StartTransaction();
return
session
;
//
return session;
}
//
}
}
}
}
}
\ No newline at end of file
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