diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2016-03-14 14:38:45 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2016-03-17 12:59:35 +0300 |
commit | 0b6b57f9acaa2ec648bf582ff67851331f8e6eef (patch) | |
tree | 7ce5da6a1c37f3674762d5514b0a34bf05e38df7 /brep/database-module | |
parent | 637d5650b91cb1da2605e5f7049ccc8bab5591f3 (diff) |
Use serializable transaction isolation level
Diffstat (limited to 'brep/database-module')
-rw-r--r-- | brep/database-module | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/brep/database-module b/brep/database-module new file mode 100644 index 0000000..64d5aaf --- /dev/null +++ b/brep/database-module @@ -0,0 +1,55 @@ +// file : brep/database-module -*- C++ -*- +// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BREP_DATABASE_MODULE +#define BREP_DATABASE_MODULE + +#include <odb/forward.hxx> // database + +#include <brep/types> +#include <brep/utility> + +#include <brep/module> +#include <brep/options> + +namespace brep +{ + // A module that utilises the database. Specifically, it will retry the + // request in the face of recoverable database failures (deadlock, loss of + // connection, etc) up to a certain number of times. + // + class database_module: public module + { + protected: + database_module () = default; + + // Create a shallow copy (handling instance) if initialized and a deep + // copy (context exemplar) otherwise. + // + explicit + database_module (const database_module&); + + // Required to avoid getting warning from clang that + // database_module::init() hides module::init() virtual functions. This + // way all functions get to the same scope and become overloaded set. + // + using module::init; + + void + init (const options::db&); + + virtual bool + handle (request&, response&) = 0; + + protected: + size_t retry_; + shared_ptr<odb::core::database> db_; + + private: + virtual bool + handle (request&, response&, log&); + }; +} + +#endif // BREP_DATABASE_MODULE |