Skip to content

sujoyg/pipelines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

Pipelines is simple way to build a pipeline of tasks. These tasks can be configured to run in serial, parallel or any combination thereof.

Examples

Parallel Tasks

require 'rubygems'
require 'pipelines'

class NumbersTask < Pipeline
  def run
    (1..10).each do |i|
      puts i
      sleep 0.5
    end
  end
end

class LettersTask < Pipeline
  def run
    ('A'..'J').each do |char|
      puts char
      sleep 0.5
    end
  end
end


class Tasks < Pipeline
  def run
    parallel do
      invoke NumbersTask
      invoke LettersTask
    end      
  end
end


if __FILE__ == $0
  pipeline = Tasks.new
  pipeline.run
end

Serial Tasks

class FirstTask < Pipeline
  def run
    # Do something
  end
end

class SecondTask < Pipeline
  def run
    # Do something
  end
end


class Tasks < Pipeline
  def run
    serial do
      invoke FirstTask
      invoke SecondTask
    end      
  end
end


if __FILE__ == $0
  pipeline = Tasks.new
  pipeline.run
end

Combo Task

class NumbersTask < Pipeline
  def run(start)
    # Do something
  end
end

class LettersTask < Pipeline
  def run(start)
    # Do something
  end
end


class Tasks < Pipeline
  def run
    parallel do
      serial do
        invoke NumbersTask
        invoke NumbersTask
      end

      serial do
        invoke LettersTask
        invoke LettersTask
      end
    end      
  end
end


if __FILE__ == $0
  pipeline = Tasks.new
  pipeline.run
end

About

A simple way to create a pipeline of tasks comprising parallel and serial segments or any combination thereof.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages