<commit_before># Gush

Gush is a parallel workflow runner using only Redis as its message broker and Sidekiq for workers.

## Installation

Add this line to your application's Gemfile:

    gem 'gush'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install gush

## Usage

### Defining workflows

The DSL for defining jobs consists of a single `run` method.
Here is a complete example of a workflow you can create:

```ruby
# workflows/sample_workflow.rb
class SampleWorkflow < Gush::Workflow
  def configure
    run FetchJob1
    run FetchJob2

    run PersistJob1, after: FetchJob1
    run PersistJob2, after: FetchJob2

    run Normalize,
        after: [PersistJob1, PersistJob2],
        before: Index

    run Index
  end
end
```

**Hint:** For debugging purposes you can vizualize the graph using `viz` command:

```
bundle exec gush viz SampleWorkflow
```

For the Workflow above, the graph will look like this:

![SampleWorkflow](http://i.imgur.com/SmeRRVT.png)

### Defining jobs

Jobs are classes inheriting from `Gush::Job`:

```ruby
#workflows/sample/fetch_job1.rb
class FetchJob1 < Gush::Job
  def work
    # do some fetching from remote APIs
  end
end
```

### Running workflows

Now that we have defined our workflow we can use it:

#### 1. Initialize and save it

```ruby
flow = SampleWorkflow.new
flow.save # saves workflow and its jobs to Redis
```

**or:** ou can also use a shortcut:

```ruby
flow = SampleWorkflow.create
```

#### 2. Start workflow

First you need to start Sidekiq workers:<commit_msg>Fix typo<commit_after># Gush

Gush is a parallel workflow runner using only Redis as its message broker and Sidekiq for workers.

## Installation

Add this line to your application's Gemfile:

    gem 'gush'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install gush

## Usage

### Defining workflows

The DSL for defining jobs consists of a single `run` method.
Here is a complete example of a workflow you can create:

```ruby
# workflows/sample_workflow.rb
class SampleWorkflow < Gush::Workflow
  def configure
    run FetchJob1
    run FetchJob2

    run PersistJob1, after: FetchJob1
    run PersistJob2, after: FetchJob2

    run Normalize,
        after: [PersistJob1, PersistJob2],
        before: Index

    run Index
  end
end
```

**Hint:** For debugging purposes you can vizualize the graph using `viz` command:

```
bundle exec gush viz SampleWorkflow
```

For the Workflow above, the graph will look like this:

![SampleWorkflow](http://i.imgur.com/SmeRRVT.png)

### Defining jobs

Jobs are classes inheriting from `Gush::Job`:

```ruby
#workflows/sample/fetch_job1.rb
class FetchJob1 < Gush::Job
  def work
    # do some fetching from remote APIs
  end
end
```

### Running workflows

Now that we have defined our workflow we can use it:

#### 1. Initialize and save it

```ruby
flow = SampleWorkflow.new
flow.save # saves workflow and its jobs to Redis
```

**or:** you can also use a shortcut:

```ruby
flow = SampleWorkflow.create
```

#### 2. Start workflow

First you need to start Sidekiq workers:
{'fraction_non_alphanumeric': 0.08796895213454076, 'fraction_numerical': 0.007761966364812419, 'mean_word_length': 3.6863636363636365, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2781770', 'n_tokens_mistral': 1037, 'n_tokens_neox': 958, 'n_words': 392}