Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making it easier to use EM's callback chain #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rbriski
Copy link

@rbriski rbriski commented Aug 7, 2011

I've made 2 small changes.

First, the deferrable object is passed back after execute is called. Second, I've set the deferred state appropriately after each internal callback. Together these changes allow someone to create a much richer callback chain than is currently possible with on_success and on_error.

Here's an example of what I'm doing with it

s = Sssnake.new
s.on_message do | file |
  bname = File.basename(local)
  item = Happening::S3::Item.new(
    'a.bucket', 
    "some/path/#{bname}",
    :aws_access_key_id => Settings[:aws][:aws_access_key_id], 
    :aws_secret_access_key => Settings[:aws][:aws_secret_key]
  )
  df = item.put(File.read(local))

  df
end

In this example, the file upload is wrapped in a "message received" event from a queue. Is this something that fits how this library is being used?

@jweiss
Copy link
Collaborator

jweiss commented Aug 7, 2011

I just merged another pull requests that already returns the response/deferrable object.

Your addition of decorating the response/deferrable objects sounds great.

Could you please update your patch to work with the latest master and add some tests for this functionality?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants