CommitMongoDBStorage
Hierarchy
- CommitMongoDBStorage
Implements
- CommitStorage
- CommitStorage
Index
Methods
- findById
- findLastVersionById
- findOneAndUpdate
- flagAndResolveCommitAsTimeouted
- flagCommitAsFailed
- flagCommitAsPublished
- generateId
- getAllCommits
- getCommits
- hasBySourceId
- lockCommit
- save
Methods
findById
▸ findById(commitId
: string): Promise‹Commit | undefined›
Implementation of CommitStorage
Returns commit by id from MongoDB collection.
Parameters:
Name | Type | Description |
---|---|---|
commitId | string | Identifier of Commit . |
Returns: Promise‹Commit | undefined›
Instance implementing Commit
interface, else undefined
.
findLastVersionById
▸ findLastVersionById(eventSourceableId
: string | Guid): Promise‹number | undefined›
Implementation of CommitStorage
Returns last version of commit by event sourceable's id from MongoDB collection.
async
Parameters:
Name | Type | Description |
---|---|---|
eventSourceableId | string | Guid | Identifier as string or Guid instance. |
Returns: Promise‹number | undefined›
Last commit version as number, else undefined
.
findOneAndUpdate
▸ findOneAndUpdate(filter?
: FilterQuery‹any›, update?
: UpdateQuery‹any›, options?
: FindOneAndUpdateOption): Promise‹Commit | undefined›
Find one document and updates it on MongoDB collection.
async
Parameters:
Name | Type | Description |
---|---|---|
filter? | FilterQuery‹any› | The Filter used to select the document to update |
update? | UpdateQuery‹any› | The update operations to be applied to the document |
options? | FindOneAndUpdateOption | Optional settings |
Returns: Promise‹Commit | undefined›
Updated instance implementing Commit
interface, else undefined
.
flagAndResolveCommitAsTimeouted
▸ flagAndResolveCommitAsTimeouted(commitId
: string, appId
: string, workerId
: string, failedAt
: Date): Promise‹Commit | undefined›
Implementation of CommitStorage
Flags commit as timeouted on MongoDB collection.
async
Parameters:
Name | Type | Description |
---|---|---|
commitId | string | Identifier for Commit that should be locked. |
appId | string | Application identifer on which commit timeouted. |
workerId | string | Worker identifer on which commit timeouted. |
failedAt | Date | Date of commit processing timeout. |
Returns: Promise‹Commit | undefined›
Instance implementing Commit
interface, else undefined
.
flagCommitAsFailed
▸ flagCommitAsFailed(commitId
: string, appId
: string, workerId
: string, failedAt
: Date): Promise‹boolean›
Implementation of CommitStorage
Flags commit as failed on MongoDB collection.
async
throws
{UpdatingCommitError}
Thrown if update operation on MongoDB is not successful.
Parameters:
Name | Type | Description |
---|---|---|
commitId | string | Identifier for Commit that should be locked. |
appId | string | Application identifer on which commit failed. |
workerId | string | Worker identifer on which commit failed. |
failedAt | Date | Date of commit processing fail. |
Returns: Promise‹boolean›
Returns true
if commit was flagged successfully, else false
.
flagCommitAsPublished
▸ flagCommitAsPublished(commitId
: string, appId
: string, workerId
: string, publishedAt
: Date): Promise‹boolean›
Implementation of CommitStorage
Flags commit as published on MongoDB collection.
async
throws
{UpdatingCommitError}
Thrown if update operation on MongoDB is not successful.
Parameters:
Name | Type | Description |
---|---|---|
commitId | string | Identifier for Commit that should be locked. |
appId | string | Application identifer on which commit is published. |
workerId | string | Worker identifer on which commit is published. |
publishedAt | Date | Date of commit publication. |
Returns: Promise‹boolean›
Returns true
if commit was flagged successfully, else false
.
generateId
▸ generateId(): Promise‹string›
Implementation of CommitStorage
Generates commit's id.
Returns: Promise‹string›
Identifier for Commit
compatible with MongoDB.
getAllCommits
▸ getAllCommits(): Promise‹Commit[]›
Implementation of CommitStorage
Returns all commits from MongoDB collection.
async
Returns: Promise‹Commit[]›
List of instances implementing Commit
interface.
getCommits
▸ getCommits(eventSourceableId
: string | Stringifiable, versionOffset
: number): Promise‹Commit[]›
Implementation of CommitStorage
Returns commit from MongoDB collection if exists by event sourceable's id for specific version offset.
async
Parameters:
Name | Type | Description |
---|---|---|
eventSourceableId | string | Stringifiable | Identifier as string or Guid instance. |
versionOffset | number | Version number from which version events should be returned. |
Returns: Promise‹Commit[]›
List of instances implementing Commit
interface.
hasBySourceId
▸ hasBySourceId(eventSourceableId
: string | Guid): Promise‹boolean›
Implementation of CommitStorage
Evaluates whether event sourceable with id already exists.
async
Parameters:
Name | Type | Description |
---|---|---|
eventSourceableId | string | Guid | Identifier as string or Guid instance. |
Returns: Promise‹boolean›
Returns true
if event sourceable exists, else false
.
lockCommit
▸ lockCommit(commitId
: string, appId
: string, workerId
: string, registeredAndNotReceivedYetFilter
: Record‹string, any›): Promise‹Commit | undefined›
Implementation of CommitStorage
Locks(changes state to received) commit on MongoDB and publishes it through CommitPublisher
async
Parameters:
Name | Type | Description |
---|---|---|
commitId | string | Identifier for Commit that should be locked. |
appId | string | Application identifer that is handling(locking) Commit. |
workerId | string | Worker identifer that is handling(locking) Commit. |
registeredAndNotReceivedYetFilter | Record‹string, any› | Filter for MongoDB query argument which selects only commits that have not been yet received by current application. |
Returns: Promise‹Commit | undefined›
Instance implementing Commit
interface, else undefined
.
save
▸ save(commit
: Commit): Promise‹string›
Implementation of CommitStorage
Adds commit to MongoDB collection.
async
throws
{CommitConcurrencyError}
Thrown if commit with same id already exists on MongoDB collection.
throws
{AddingCommitFailedError}
Thrown if commit with same id already exists on MongoDB collection.
Parameters:
Name | Type | Description |
---|---|---|
commit | Commit | Instance implementing Commit interface. |
Returns: Promise‹string›
Identifier for document(as Commit's id) on MongoDB collection.