README.md in gush-0.0.1 vs README.md in gush-0.1
- old
+ new
@@ -1,6 +1,6 @@
-# Gush
+# Gush [![Build Status](https://travis-ci.org/pokonski/gush.svg?branch=master)](https://travis-ci.org/pokonski/gush)
Gush is a parallel workflow runner using only Redis as its message broker and Sidekiq for workers.
## Installation
@@ -16,25 +16,13 @@
$ gem install gush
## Usage
-Your project should contain a file called `Gushfile.rb` which loads all the necessary workflows for Sidekiq to use.
-
-Example:
-
-```ruby
-require_relative './lib/your_project'
-
-Dir[Rowlf.root.join("workflows/**/*.rb")].each do |file|
- require file
-end
-```
-
### Defining workflows
-The DSL for defining jobs consists of a single `run` method.
+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
@@ -61,10 +49,11 @@
```
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
@@ -74,55 +63,88 @@
# do some fetching from remote APIs
end
end
```
-### Running
+### Running workflows
-#### 1. Register workflow
+Now that we have defined our workflow we can use it:
-After you define your workflows and jobs, all you have to do is register them:
+#### 1. Initialize and save it
+```ruby
+flow = SampleWorkflow.new
+flow.save # saves workflow and its jobs to Redis
```
-bundle exec gush create SampleWorkflow
-```
-the command will return a unique workflow id you will use in later commands.
+**or:** you can also use a shortcut:
-#### 2. Run workers
+```ruby
+flow = SampleWorkflow.create
+```
-This will start Sidekiq workers responsible for processing jobs
+#### 2. Start workflow
+First you need to start Sidekiq workers:
+
```
bundle exec gush workers
```
-#### 3. Start the workflow
+and then start your workflow:
-Use your workflow_id returned by `create` command.
+```ruby
+flow.start!
+```
+Now Gush will start processing jobs in background using Sidekiq
+in the order defined in `configure` method inside Workflow.
+
+
+### Checking status:
+
+#### In Ruby:
+
+```ruby
+flow.reload
+flow.status
+#=> :running|:pending|:finished|:failed
```
-bundle gush start <workflow_id>
-```
-### 5. Check the status
+`reload` is needed to see the latest status, since workflows are updated asynchronously.
+#### Via CLI:
+
- of a specific workflow:
```
bundle gush show <workflow_id>
```
- of all created workflows:
-
+
```
bundle gush list
```
+### Requiring workflows inside your projects
+**Skip this step if using Gush inside Rails application, workflows will already be loaded**
+
+When using Gush and its CLI commands you need a Gushfile.rb in root directory.
+Gushfile should require all your Workflows and jobs, for example:
+
+```ruby
+require_relative './lib/your_project'
+
+Dir[Rails.root.join("app/workflows/**/*.rb")].each do |file|
+ require file
+end
+```
+
## Contributing
-1. Fork it ( http://github.com/lonelyplanet/gush/fork )
+1. Fork it ( http://github.com/pokonski/gush/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request