0.0
No commit activity in last 3 years
No release in over 3 years
Chain together code tasks similar to Unix pipes
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10.0
~> 0.54.0

Runtime

 Project Readme

depth_first

Depth-first search code organization gem allowing for sequential and concurrent code execution using concurrent-ruby.

Tasks

A task accepts an input hash and merges in a results hash.

Examples

class A < DepthFirst::Task
  def perform
    { a: 1 }
  end
end

class B < DepthFirst::Task
  def perform
    { b: 2 }
  end
end

class C < DepthFirst::Task
  def perform
    { c: 3 }
  end
end

Usage

> A.new(test: true).perform
 => { test: true, a: 1 }

> B.new(test: true).perform
 => { test: true, b: 2 }

Organizers

An organizer chains together tasks, piping a hash through each subtask.

SequentialOrganizer

Data is passed through A, B, and C sequentially. The input hash { testing: true } is piped through A. The resulting hash { testing: true, a: 1 } is then piped through B. And so on.

Example

class SequentialAbc < DepthFirst::SequentialOrganizer
  TASKS = [A, B, C].freeze
end

Usage

> SequentialAbc.new(testing: true).perform
 => { testing: true, a: 1, b: 2, c: 3 }

ParallelOrganizer

Data is passed through A, B, and C concurrently. All three classes execute in parallel. The input hash { testing: true } is passed to all three classes and all three intermediate result hashes are merged into the final result hash once their promises are resolved.

Example

class ParallelAbc < DepthFirst::ParallelOrganizer
  TASKS = [A, B, C].freeze
end

Usage

> ParallelAbc.new(testing: true).perform
 => { testing: true, a: 1, b: 2, c: 3}

Note

An organizer can have a subtask which is itself another organizer. In this manner, code can be organized in an arbitrarily-deep tree structure with order of execution roughly matching a Depth First Search algorithm.