Class: Phronomy::Persistence

Inherits:
Object
  • Object
show all
Defined in:
lib/phronomy/persistence.rb,
lib/phronomy/persistence/in_memory.rb

Defined Under Namespace

Classes: ConflictError, InMemory, NotFoundError, UnsupportedBackendError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents:, agents:, journals:, executions:, workflow_states:) ⇒ Persistence

Returns a new instance of Persistence.



11
12
13
14
15
16
17
18
# File 'lib/phronomy/persistence.rb', line 11

def initialize(contents:, agents:, journals:, executions:, workflow_states:)
  @contents = contents
  @agents = agents
  @journals = journals
  @executions = executions
  @workflow_states = workflow_states
  validate_capabilities!
end

Instance Attribute Details

#agentsObject (readonly)

Returns the value of attribute agents.



9
10
11
# File 'lib/phronomy/persistence.rb', line 9

def agents
  @agents
end

#contentsObject (readonly)

Returns the value of attribute contents.



9
10
11
# File 'lib/phronomy/persistence.rb', line 9

def contents
  @contents
end

#executionsObject (readonly)

Returns the value of attribute executions.



9
10
11
# File 'lib/phronomy/persistence.rb', line 9

def executions
  @executions
end

#journalsObject (readonly)

Returns the value of attribute journals.



9
10
11
# File 'lib/phronomy/persistence.rb', line 9

def journals
  @journals
end

#workflow_statesObject (readonly)

Returns the value of attribute workflow_states.



9
10
11
# File 'lib/phronomy/persistence.rb', line 9

def workflow_states
  @workflow_states
end

Instance Method Details

#assert_agent_watermark!(agent_id:, agent_revision:, journal_position:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Verifies that a live Agent still owns the durable base it hydrated. Backends should implement this as a revision/position precondition check, not as a state reload returned to the caller.



32
33
34
35
# File 'lib/phronomy/persistence.rb', line 32

def assert_agent_watermark!(agent_id:, agent_revision:, journal_position:)
  raise UnsupportedBackendError,
    "#{self.class} does not provide Agent durable-watermark checks"
end

#capabilitiesObject



20
21
22
# File 'lib/phronomy/persistence.rb', line 20

def capabilities
  {atomic_all: false, atomic_admission: false}.freeze
end

#transactionObject



24
25
26
# File 'lib/phronomy/persistence.rb', line 24

def transaction
  raise UnsupportedBackendError, "#{self.class} does not provide atomic_all"
end