CatapultServer  v0.5.0.1 (Elephant)
catapult::mongo::MongoErrorPolicy Class Reference

Error policy for checking mongo operation results. More...

Inheritance diagram for catapult::mongo::MongoErrorPolicy:
Collaboration diagram for catapult::mongo::MongoErrorPolicy:

Public Types

enum  Mode { Mode::Strict, Mode::Idempotent }
 Error policy modes. More...
 

Public Member Functions

 MongoErrorPolicy (const std::string &collectionName, Mode mode)
 Creates an error policy around collectionName using error policy mode. More...
 
Mode mode () const
 Gets the error policy mode. More...
 
void checkDeleted (uint64_t numExpected, const BulkWriteResult &result, const std::string &itemsDescription) const
 Checks that result indicates exactly numExpected deletions occurred given itemsDescription. More...
 
void checkDeletedAtLeast (uint64_t numExpected, const BulkWriteResult &result, const std::string &itemsDescription) const
 Checks that result indicates at least numExpected deletions occurred given itemsDescription. More...
 
void checkInserted (uint64_t numExpected, const BulkWriteResult &result, const std::string &itemsDescription) const
 Checks that result indicates exactly numExpected insertions occurred given itemsDescription. More...
 
void checkUpserted (uint64_t numExpected, const BulkWriteResult &result, const std::string &itemsDescription) const
 Checks that result indicates exactly numExpected upsertions occurred given itemsDescription. More...
 

Private Member Functions

void formatMessageAndThrow (const char *operation, uint64_t numExpected, uint64_t numActual, const std::string &itemsDescription) const
 
- Private Member Functions inherited from catapult::utils::MoveOnly
constexpr MoveOnly ()=default
 Default constructor. More...
 
 ~MoveOnly ()=default
 Default destructor. More...
 
 MoveOnly (const NonCopyable &)=delete
 Disabled copy constructor. More...
 
 MoveOnly (MoveOnly &&)=default
 Default move constructor. More...
 
MoveOnlyoperator= (const MoveOnly &)=delete
 Disabled assignment operator. More...
 
MoveOnlyoperator= (MoveOnly &&)=default
 Default move assignment operator. More...
 

Private Attributes

std::string m_collectionName
 
Mode m_mode
 

Detailed Description

Error policy for checking mongo operation results.

Member Enumeration Documentation

◆ Mode

Error policy modes.

Enumerator
Strict 

Strictest mode that requires exact matching.

Idempotent 

More forgiving mode that enables idempotent operations.

Note
This is recommended for recovery.

Constructor & Destructor Documentation

◆ MongoErrorPolicy()

catapult::mongo::MongoErrorPolicy::MongoErrorPolicy ( const std::string &  collectionName,
Mode  mode 
)
explicit

Creates an error policy around collectionName using error policy mode.

Member Function Documentation

◆ checkDeleted()

void catapult::mongo::MongoErrorPolicy::checkDeleted ( uint64_t  numExpected,
const BulkWriteResult result,
const std::string &  itemsDescription 
) const

Checks that result indicates exactly numExpected deletions occurred given itemsDescription.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkDeletedAtLeast()

void catapult::mongo::MongoErrorPolicy::checkDeletedAtLeast ( uint64_t  numExpected,
const BulkWriteResult result,
const std::string &  itemsDescription 
) const

Checks that result indicates at least numExpected deletions occurred given itemsDescription.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkInserted()

void catapult::mongo::MongoErrorPolicy::checkInserted ( uint64_t  numExpected,
const BulkWriteResult result,
const std::string &  itemsDescription 
) const

Checks that result indicates exactly numExpected insertions occurred given itemsDescription.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkUpserted()

void catapult::mongo::MongoErrorPolicy::checkUpserted ( uint64_t  numExpected,
const BulkWriteResult result,
const std::string &  itemsDescription 
) const

Checks that result indicates exactly numExpected upsertions occurred given itemsDescription.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ formatMessageAndThrow()

void catapult::mongo::MongoErrorPolicy::formatMessageAndThrow ( const char *  operation,
uint64_t  numExpected,
uint64_t  numActual,
const std::string &  itemsDescription 
) const
private
Here is the caller graph for this function:

◆ mode()

MongoErrorPolicy::Mode catapult::mongo::MongoErrorPolicy::mode ( ) const

Gets the error policy mode.

Member Data Documentation

◆ m_collectionName

std::string catapult::mongo::MongoErrorPolicy::m_collectionName
private

◆ m_mode

Mode catapult::mongo::MongoErrorPolicy::m_mode
private

The documentation for this class was generated from the following files: