Skip to content

Commit

Permalink
Added asynchronous flavour
Browse files Browse the repository at this point in the history
  • Loading branch information
parolkar committed Aug 20, 2009
1 parent 8cd53b2 commit f0a52b4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
11 changes: 9 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pfeed
======

You need Pfeed when you want to automagically create fancy logs / activity updates in your rails app.
You need Pfeed when you want to automagically create fancy logs / activity updates in your rails app, asynchronously.


### What's so magical here?
Expand Down Expand Up @@ -62,7 +62,14 @@ Isn't it magical? that it guesses the identity of model object (parolkar or foo

Even more, each feed can be customized and skinned the way you want. You can easily extend the functionality to suit your requirements.

If all this excites you, check out the tutorials [here](http://wiki.github.com/parolkar/pfeed "pfeed's Wiki") or explore some more advanced techniques [here](http://wiki.github.com/parolkar/pfeed/customizing-the-pfeed-item "pfeed customisation techniques")
If all this excites you, check out the tutorials [here](http://wiki.github.com/parolkar/pfeed "pfeed's Wiki") or explore some more advanced techniques [here](http://wiki.github.com/parolkar/pfeed/customizing-the-pfeed-item "pfeed customisation techniques")


## Performance

*How efficient is feed generation and delivery?*

If your app has mechanisms for asynchronous processing, like delayed_job , pfeed plugin will automatically figure out how to schedule the delivery in the queue so that your request loop remains efficient and workers can perform deliveries. [Find out more](http://wiki.github.com/parolkar/pfeed/pfeed-delivery-as-background-job "pfeed delivery as background job")

## More Details

Expand Down
14 changes: 12 additions & 2 deletions app/models/pfeed_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,19 @@ def self.log(ar_obj,method_name,method_name_in_past_tense,returned_result,*args_

p_item.save
#puts "Trying to deliver to #{ar_obj} #{ar_obj.pfeed_audience_hash[method_name.to_sym]}"
p_item.deliver(ar_obj,ar_obj.pfeed_audience_hash[method_name.to_sym])
p_item.attempt_delivery(ar_obj,ar_obj.pfeed_audience_hash[method_name.to_sym]) # attempting the delivery of the feed

end

def attempt_delivery (ar_obj,method_name_arr)
if (defined? Delayed) == "constant" && (respond_to? :send_later) == true #this means Delayed_job exists , so make use of asynchronous delivery of pfeed
send_later(:deliver,ar_obj,method_name_arr)
else # regular instant delivery
send(:deliver,ar_obj,method_name_arr)
end


end

def deliver(ar_obj,method_name_arr)
all_receivers = Array.new
Expand Down

0 comments on commit f0a52b4

Please sign in to comment.