CMDx::Parallel
Parallelization execution of workflow tasks for CMDx.
Note
The contents of this gem have been integrated in the CMDx itself and is meant for backwards compatibility between versions 1.6.1
and 1.6.2
. This gem will only receive bug and security patches.
Installation
Add this line to your application's Gemfile:
gem 'cmdx-parallel'
And then execute:
$ bundle
Or install it yourself as:
$ gem install cmdx-parallel
Usage
CMDx::Parallel task execution leverages the Parallel gem, which automatically detects the number of available processors to maximize concurrent task execution.
Important
One important caveat to note is that context cannot be altered within parallel executions. It is best to preload the context with any required data before parallelization begins.
class SendWelcomeNotifications < CMDx::Task
include CMDx::Workflow
# Default options (dynamically calculated to available processors)
tasks SendWelcomeEmail, SendWelcomeSms, SendWelcomePush, strategy: :parallel
end
Options
Reference the Parallel gem for all processing options.
class SendWelcomeNotifications < CMDx::Task
include CMDx::Workflow
# Fix number of threads
tasks SendWelcomeEmail, SendWelcomeSms, SendWelcomePush, strategy: :parallel, in_threads: 2
# Fix number of forked processes
tasks SendWelcomeEmail, SendWelcomeSms, SendWelcomePush, strategy: :parallel, in_processes: 2
# NOTE: Reactors are not supported
end
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/drexed/cmdx-parallel. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Cmdx::Parallel project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.