Class: Phronomy::StateStore::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/phronomy/state_store/base.rb

Overview

Abstract base class for state persistence backends. Subclasses must implement save, load, and clear.

The state object passed to save must include Phronomy::Graph::State and have a non-nil thread_id (set automatically by CompiledGraph#invoke).

Direct Known Subclasses

ActiveRecord, InMemory, Redis

Instance Method Summary collapse

Instance Method Details

#clear(thread_id) ⇒ self

Removes the saved state for the given thread_id.

Parameters:

  • thread_id (String)

Returns:

  • (self)

Raises:

  • (NotImplementedError)


30
31
32
# File 'lib/phronomy/state_store/base.rb', line 30

def clear(thread_id)
  raise NotImplementedError, "#{self.class}#clear is not implemented"
end

#load(thread_id) ⇒ Object?

Loads the state for the given thread_id.

Parameters:

  • thread_id (String)

Returns:

  • (Object, nil)

    state object or nil if not found

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/phronomy/state_store/base.rb', line 23

def load(thread_id)
  raise NotImplementedError, "#{self.class}#load is not implemented"
end

#save(state) ⇒ self

Persists the state. The thread_id is read from state.thread_id.

Parameters:

  • state (Object)

    object including Phronomy::Graph::State

Returns:

  • (self)

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/phronomy/state_store/base.rb', line 16

def save(state)
  raise NotImplementedError, "#{self.class}#save is not implemented"
end