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
30853903
Commit
30853903
authored
Jul 23, 2018
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tweak database configuration name to ‘DatabaseName’
parent
b67e8ebc
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
34 additions
and
20 deletions
+34
-20
CAP.MongoDBOptions.cs
src/DotNetCore.CAP.MongoDB/CAP.MongoDBOptions.cs
+20
-6
CapPublisher.cs
src/DotNetCore.CAP.MongoDB/CapPublisher.cs
+1
-1
MongoDBCollectProcessor.cs
src/DotNetCore.CAP.MongoDB/MongoDBCollectProcessor.cs
+2
-2
MongoDBMonitoringApi.cs
src/DotNetCore.CAP.MongoDB/MongoDBMonitoringApi.cs
+1
-1
MongoDBStorage.cs
src/DotNetCore.CAP.MongoDB/MongoDBStorage.cs
+4
-4
MongoDBStorageConnection.cs
src/DotNetCore.CAP.MongoDB/MongoDBStorageConnection.cs
+1
-1
MongoDBStorageTransaction.cs
src/DotNetCore.CAP.MongoDB/MongoDBStorageTransaction.cs
+1
-1
MongoDBUtil.cs
src/DotNetCore.CAP.MongoDB/MongoDBUtil.cs
+4
-4
No files found.
src/DotNetCore.CAP.MongoDB/CAP.MongoDBOptions.cs
View file @
30853903
...
...
@@ -5,16 +5,30 @@ namespace DotNetCore.CAP.MongoDB
{
public
class
MongoDBOptions
{
public
const
string
DefaultDatabase
=
"Cap"
;
/// <summary>
/// Gets or sets the database name to use when creating database objects.
/// Default value: "cap"
/// </summary>
public
string
DatabaseName
{
get
;
set
;
}
=
"cap"
;
/// <summary>
///
Gets or sets the database to use when creating database objects
.
/// Default
is <see cref="DefaultDatabase" />.
///
MongoDB database connection string
.
/// Default
value: "mongodb://localhost:27017"
/// </summary>
public
string
Database
{
get
;
set
;
}
=
DefaultDatabase
;
public
string
Database
Connection
{
get
;
set
;
}
=
"mongodb://localhost:27017"
;
public
string
ReceivedCollection
{
get
;
}
=
"Received"
;
/// <summary>
/// MongoDB received message collection name.
/// Default value: "received"
/// </summary>
public
string
ReceivedCollection
{
get
;
set
;
}
=
"cap.received"
;
/// <summary>
/// MongoDB published message collection name.
/// Default value: "published"
/// </summary>
public
string
PublishedCollection
{
get
;
set
;
}
=
"cap.published"
;
public
string
PublishedCollection
{
get
;
}
=
"Published
"
;
internal
const
string
CounterCollection
=
"cap.counter
"
;
}
}
\ No newline at end of file
src/DotNetCore.CAP.MongoDB/CapPublisher.cs
View file @
30853903
...
...
@@ -28,7 +28,7 @@ namespace DotNetCore.CAP.MongoDB
:
base
(
logger
,
dispatcher
)
{
_options
=
options
;
_database
=
client
.
GetDatabase
(
_options
.
Database
);
_database
=
client
.
GetDatabase
(
_options
.
Database
Name
);
ServiceProvider
=
provider
;
}
...
...
src/DotNetCore.CAP.MongoDB/MongoDBCollectProcessor.cs
View file @
30853903
...
...
@@ -23,13 +23,13 @@ namespace DotNetCore.CAP.MongoDB
{
_options
=
options
;
_logger
=
logger
;
_database
=
client
.
GetDatabase
(
_options
.
Database
);
_database
=
client
.
GetDatabase
(
_options
.
Database
Name
);
}
public
async
Task
ProcessAsync
(
ProcessingContext
context
)
{
_logger
.
LogDebug
(
$"Collecting expired data from collection [
{
_options
.
Database
}
].[
{
_options
.
PublishedCollection
}
]."
);
$"Collecting expired data from collection [
{
_options
.
PublishedCollection
}
]."
);
var
publishedCollection
=
_database
.
GetCollection
<
CapPublishedMessage
>(
_options
.
PublishedCollection
);
var
receivedCollection
=
_database
.
GetCollection
<
CapReceivedMessage
>(
_options
.
ReceivedCollection
);
...
...
src/DotNetCore.CAP.MongoDB/MongoDBMonitoringApi.cs
View file @
30853903
...
...
@@ -22,7 +22,7 @@ namespace DotNetCore.CAP.MongoDB
var
mongoClient
=
client
??
throw
new
ArgumentNullException
(
nameof
(
client
));
_options
=
options
??
throw
new
ArgumentNullException
(
nameof
(
options
));
_database
=
mongoClient
.
GetDatabase
(
_options
.
Database
);
_database
=
mongoClient
.
GetDatabase
(
_options
.
Database
Name
);
}
public
StatisticsDto
GetStatistics
()
...
...
src/DotNetCore.CAP.MongoDB/MongoDBStorage.cs
View file @
30853903
...
...
@@ -46,7 +46,7 @@ namespace DotNetCore.CAP.MongoDB
return
;
}
var
database
=
_client
.
GetDatabase
(
_options
.
Database
);
var
database
=
_client
.
GetDatabase
(
_options
.
Database
Name
);
var
names
=
(
await
database
.
ListCollectionNamesAsync
(
cancellationToken
:
cancellationToken
))?.
ToList
();
if
(!
names
.
Any
(
n
=>
n
==
_options
.
ReceivedCollection
))
...
...
@@ -60,10 +60,10 @@ namespace DotNetCore.CAP.MongoDB
cancellationToken
:
cancellationToken
);
}
if
(
names
.
All
(
n
=>
n
!=
"Counter"
))
if
(
names
.
All
(
n
=>
n
!=
MongoDBOptions
.
CounterCollection
))
{
await
database
.
CreateCollectionAsync
(
"Counter"
,
cancellationToken
:
cancellationToken
);
var
collection
=
database
.
GetCollection
<
BsonDocument
>(
"Counter"
);
await
database
.
CreateCollectionAsync
(
MongoDBOptions
.
CounterCollection
,
cancellationToken
:
cancellationToken
);
var
collection
=
database
.
GetCollection
<
BsonDocument
>(
MongoDBOptions
.
CounterCollection
);
await
collection
.
InsertManyAsync
(
new
[]
{
new
BsonDocument
{{
"_id"
,
_options
.
PublishedCollection
},
{
"sequence_value"
,
0
}},
...
...
src/DotNetCore.CAP.MongoDB/MongoDBStorageConnection.cs
View file @
30853903
...
...
@@ -22,7 +22,7 @@ namespace DotNetCore.CAP.MongoDB
_capOptions
=
capOptions
;
_options
=
options
;
_client
=
client
;
_database
=
_client
.
GetDatabase
(
_options
.
Database
);
_database
=
_client
.
GetDatabase
(
_options
.
Database
Name
);
}
public
bool
ChangePublishedState
(
int
messageId
,
string
state
)
...
...
src/DotNetCore.CAP.MongoDB/MongoDBStorageTransaction.cs
View file @
30853903
...
...
@@ -17,7 +17,7 @@ namespace DotNetCore.CAP.MongoDB
public
MongoDBStorageTransaction
(
IMongoClient
client
,
MongoDBOptions
options
)
{
_options
=
options
;
_database
=
client
.
GetDatabase
(
options
.
Database
);
_database
=
client
.
GetDatabase
(
options
.
Database
Name
);
_session
=
client
.
StartSession
();
_session
.
StartTransaction
();
}
...
...
src/DotNetCore.CAP.MongoDB/MongoDBUtil.cs
View file @
30853903
...
...
@@ -19,10 +19,10 @@ namespace DotNetCore.CAP.MongoDB
IClientSessionHandle
session
=
null
)
{
//https://www.tutorialspoint.com/mongodb/mongodb_autoincrement_sequence.htm
var
collection
=
database
.
GetCollection
<
BsonDocument
>(
"Counter"
);
var
collection
=
database
.
GetCollection
<
BsonDocument
>(
MongoDBOptions
.
CounterCollection
);
var
updateDef
=
Builders
<
BsonDocument
>.
Update
.
Inc
(
"sequence_value"
,
1
);
var
filter
=
new
BsonDocument
{
{
"_id"
,
collectionName
}
};
var
filter
=
new
BsonDocument
{
{
"_id"
,
collectionName
}
};
BsonDocument
result
;
if
(
session
==
null
)
...
...
@@ -45,9 +45,9 @@ namespace DotNetCore.CAP.MongoDB
public
int
GetNextSequenceValue
(
IMongoDatabase
database
,
string
collectionName
,
IClientSessionHandle
session
=
null
)
{
var
collection
=
database
.
GetCollection
<
BsonDocument
>(
"Counter"
);
var
collection
=
database
.
GetCollection
<
BsonDocument
>(
MongoDBOptions
.
CounterCollection
);
var
filter
=
new
BsonDocument
{
{
"_id"
,
collectionName
}
};
var
filter
=
new
BsonDocument
{
{
"_id"
,
collectionName
}
};
var
updateDef
=
Builders
<
BsonDocument
>.
Update
.
Inc
(
"sequence_value"
,
1
);
var
result
=
session
==
null
...
...
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