Class: Petra::PersistenceAdapters::Adapter

Inherits:
Object
  • Object
show all
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

FileAdapter

Instance Method Summary collapse

Methods included from Util::Registrable

included

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.

Parameters:



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>

This method is abstract.

Returns All log entries which were previously persisted for the given section.

Parameters:

Returns:



74
75
76
# File 'lib/petra/persistence_adapters/adapter.rb', line 74

def log_entries(_section)
  not_implemented
end

#persist!Object

This method is abstract.

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>

This method is abstract.

Returns the names of all savepoints which were previously persisted for the given transaction.

Parameters:

Returns:

  • (Array<String>)

    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_identifiersArray<String>

This method is abstract.

Returns the identifiers of all transactions which are currently persisted (>= one section finished, but not committed).

Returns:

  • (Array<String>)

    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

This method is abstract.

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!

Parameters:

  • suspend (Boolean) (defaults to: true)

    If set to false, the method will not suspend if the global lock could not be acquired. Instead, a Petra::LockError is thrown

Raises:



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

This method is abstract.

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!

Parameters:

Raises:



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

This method is 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

The actual implementation must ensure that an acquired lock is released in case of an exception!

Parameters:

  • suspend (Boolean) (defaults to: true)

    If set to false, the method will not suspend if the transaction lock could not be acquired. Instead, a Petra::LockError is thrown

Raises:



119
120
121
# File 'lib/petra/persistence_adapters/adapter.rb', line 119

def with_transaction_lock(_identifier, suspend: true)
  not_implemented
end