|
Lightweight 0.20251202.0
|
#include <SqlMigrationLock.hpp>
Public Member Functions | |
| LIGHTWEIGHT_API | MigrationLock (SqlConnection &connection, std::string_view lockName="lightweight_migration", std::chrono::milliseconds timeout=std::chrono::seconds(30)) |
| LIGHTWEIGHT_API | ~MigrationLock () |
| Releases the lock on destruction. | |
| MigrationLock (MigrationLock const &)=delete | |
| MigrationLock & | operator= (MigrationLock const &)=delete |
| LIGHTWEIGHT_API | MigrationLock (MigrationLock &&other) noexcept |
| Move constructor. | |
| LIGHTWEIGHT_API MigrationLock & | operator= (MigrationLock &&other) noexcept |
| Move assignment operator. | |
| bool | IsLocked () const noexcept |
| LIGHTWEIGHT_API void | Release () |
RAII-style migration lock to prevent concurrent migrations.
This class provides a distributed locking mechanism to ensure that only one process can run migrations at a time. The implementation uses database-specific advisory locks:
Definition at line 33 of file SqlMigrationLock.hpp.
|
explicit |
Acquire a migration lock.
| connection | Database connection to use for locking |
| lockName | Name of the lock (default: "lightweight_migration") |
| timeout | Maximum time to wait for lock acquisition |
| SqlException | if lock cannot be acquired within timeout |
|
inlinenoexcept |
Check if lock is held.
Definition at line 61 of file SqlMigrationLock.hpp.
| LIGHTWEIGHT_API void Lightweight::SqlMigration::MigrationLock::Release | ( | ) |
Release the lock early.
This is automatically called in the destructor, but can be called manually if early release is desired.