Pushed 0.3.0 Gem: Much More User Friendly

After using SimpleWorkr for a long time now, I always think to myself, “there’s gotta be some way to make this more intuitive”. I want it to feel more like it’s just like running your normal code without even really realizing that the work is actually offloaded to the cloud. So with that in mind, the gem now has a much more intuitive usage pattern, more like ActiveRecord.

The old way:

# Create a Service object
@service = SimpleWorker::Service.new(@access_key, @secret_key)
# Upload code
@service.upload(worker_class_name, path_to_file)
# Queue up jobs
@service.queue(worker_class_name, data_for_job)
# Or schedule jobs
@service.schedule(worker_class_name, data_for_job, schedule)
# Get status of jobs

Now, here’s the shiny new way of doing it:

Some one time initialization:

SimpleWorker.configure do |config|
config.access_key = @access_key
config.secret_key = @secret_key

Now throughout your app, you can do the following:

# Instantiate a new worker
worker = MyWorker.new
# Queue directly from the object
# Schedule directly from the object
# Check status directly from it as well

All data defined in instance variables in your worker will be sent along and usable in your run method.

Also, your code will automatically be uploaded if it has been changed!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.