Class: Kiqchestra::WorkflowStore

Inherits:
Object
  • Object
show all
Defined in:
lib/kiqchestra/workflow_store.rb

Overview

The WorkflowStore class serves as an abstract base class for implementing custom storage mechanisms for workflow progress, dependencies, and arguments. It defines abstract methods that must be implemented by subclasses.

By default, Kiqchestra uses DefaultWorkflowStore. Users are free to create their own custom implementation of WorkflowStore to change storage system (file-based, database, etc.) or specific details of implementations.

Direct Known Subclasses

DefaultWorkflowStore

Instance Method Summary collapse

Constructor Details

#initialize(*_args) ⇒ WorkflowStore

Ensures subclasses properly implement required methods.



13
14
15
# File 'lib/kiqchestra/workflow_store.rb', line 13

def initialize(*_args)
  # No initialization logic here
end

Instance Method Details

#read_metadataHash

Reads the workflow data for a workflow.

Returns:

  • (Hash)

    A hash representing the metadata for the workflow, where each key is a task ID and the value is a hash with keys ‘:deps` and `:args`.

Raises:

  • (NotImplementedError)

    This method must be implemented by a subclass.



22
23
24
# File 'lib/kiqchestra/workflow_store.rb', line 22

def 
  raise NotImplementedError, "Subclasses must implement the read_workflow_data method"
end

#read_progressHash

Reads the progress of a workflow.

Returns:

  • (Hash)

    A hash representing the progress of the workflow, where each key is a task ID and the value indicates the completion status.

Raises:

  • (NotImplementedError)

    This method must be implemented by a subclass.



41
42
43
# File 'lib/kiqchestra/workflow_store.rb', line 41

def read_progress
  raise NotImplementedError, "Subclasses must implement the read_progress method"
end

#write_metadata(_metadata) ⇒ Object

Writes the workflow data for a workflow to the store.

Examples:

{ a_job: { deps: [], args: [1, 2, 3] }, b_job: { deps: [:a_job], args: nil } }


Parameters:

  • workflow_data (Hash)

    A hash representing the workflow data to store, where each key is a task ID and the value is a hash with keys ‘:deps` and `:args`.

Raises:

  • (NotImplementedError)

    This method must be implemented by a subclass.



32
33
34
# File 'lib/kiqchestra/workflow_store.rb', line 32

def ()
  raise NotImplementedError, "Subclasses must implement the write_workflow_data method"
end

#write_progress(_progress) ⇒ Object

Writes the progress of a workflow to the store.

Examples:

{ a_worker: ‘complete’, b_worker: ‘in_progress’ }


Parameters:

  • progress (Hash)

    A hash representing the progress to store, where each key is a task ID and the value indicates the completion status.

Raises:

  • (NotImplementedError)

    This method must be implemented by a subclass.



51
52
53
# File 'lib/kiqchestra/workflow_store.rb', line 51

def write_progress(_progress)
  raise NotImplementedError, "Subclasses must implement the write_progress method"
end