Class: Petra::PersistenceAdapters::Adapter
- Inherits:
-
Object
- Object
- Petra::PersistenceAdapters::Adapter
- Includes:
- Util::Registrable
- Defined in:
- lib/petra/persistence_adapters/adapter.rb
Overview
This class acts as an interface and specifies the methods that a transaction adapter has to implement.
Direct Known Subclasses
Instance Method Summary collapse
-
#enqueue(log_entry) ⇒ Object
Adds the given log entry to the queue to be persisted next.
-
#log_entries(_section) ⇒ Array<Petra::Components::LogEntry>
abstract
All log entries which were previously persisted for the given section.
-
#persist! ⇒ Object
abstract
Persists the transaction steps which happened after the last changes were persisted.
-
#reset_transaction(_transaction) ⇒ Object
Resets the given transaction, meaning that all persisted information is removed.
-
#savepoints(_transaction) ⇒ Array<String>
abstract
The names of all savepoints which were previously persisted for the given transaction.
-
#transaction_identifiers ⇒ Array<String>
abstract
The identifiers of all transactions which are currently persisted (>= one section finished, but not committed).
-
#with_global_lock(suspend: true) ⇒ Object
abstract
Executes the given block after acquiring a global lock.
-
#with_object_lock(_proxy, suspend: true) ⇒ Object
abstract
Executes the given block after acquiring the lock for the given proxy (object).
-
#with_transaction_lock(_identifier, suspend: true) ⇒ Object
abstract
Executes the given block after acquiring a transaction based lock, meaning that other processes which execute something in the same transaction’s context have to wait / abort.
Methods included from Util::Registrable
Instance Method Details
#enqueue(log_entry) ⇒ Object
Adds the given log entry to the queue to be persisted next. Fails if the queue already contains the log entry.
37 38 39 40 41 42 |
# File 'lib/petra/persistence_adapters/adapter.rb', line 37 def enqueue(log_entry) if queue.include?(log_entry) fail Petra::PersistenceError, 'A log entry can only be added to a persistence queue once' end queue << log_entry end |
#log_entries(_section) ⇒ Array<Petra::Components::LogEntry>
Returns All log entries which were previously persisted for the given section.
74 75 76 |
# File 'lib/petra/persistence_adapters/adapter.rb', line 74 def log_entries(_section) not_implemented end |
#persist! ⇒ Object
Persists the transaction steps which happened after the last changes were persisted.
27 28 29 |
# File 'lib/petra/persistence_adapters/adapter.rb', line 27 def persist! not_implemented end |
#reset_transaction(_transaction) ⇒ Object
Resets the given transaction, meaning that all persisted information is removed
81 82 83 |
# File 'lib/petra/persistence_adapters/adapter.rb', line 81 def reset_transaction(_transaction) not_implemented end |
#savepoints(_transaction) ⇒ Array<String>
Returns the names of all savepoints which were previously persisted for the given transaction.
62 63 64 |
# File 'lib/petra/persistence_adapters/adapter.rb', line 62 def savepoints(_transaction) not_implemented end |
#transaction_identifiers ⇒ Array<String>
Returns the identifiers of all transactions which are currently persisted (>= one section finished, but not committed).
50 51 52 |
# File 'lib/petra/persistence_adapters/adapter.rb', line 50 def transaction_identifiers not_implemented end |
#with_global_lock(suspend: true) ⇒ Object
Executes the given block after acquiring a global lock
The actual implementation must ensure that an acquired lock is released in case of an exception!
99 100 101 |
# File 'lib/petra/persistence_adapters/adapter.rb', line 99 def with_global_lock(suspend: true) not_implemented end |
#with_object_lock(_proxy, suspend: true) ⇒ Object
Executes the given block after acquiring the lock for the given proxy (object)
The actual implementation must ensure that an acquired lock is released in case of an exception!
138 139 140 |
# File 'lib/petra/persistence_adapters/adapter.rb', line 138 def with_object_lock(_proxy, suspend: true) not_implemented end |
#with_transaction_lock(_identifier, suspend: true) ⇒ Object
Executes the given block after acquiring a transaction based lock, meaning that other processes which execute something in the same transaction’s context have to wait / abort
The actual implementation must ensure that an acquired lock is released in case of an exception!
119 120 121 |
# File 'lib/petra/persistence_adapters/adapter.rb', line 119 def with_transaction_lock(_identifier, suspend: true) not_implemented end |