Module: TorqueBox::Messaging::Backgroundable::BackgroundableClassMethods
- Included in:
- TorqueBox::Messaging::Backgroundable
- Defined in:
- lib/torquebox/messaging/backgroundable.rb
Instance Method Summary collapse
- #__enable_backgroundable_newrelic_tracing(method) ⇒ Object private
-
#always_background(*methods) ⇒ Object
Marks methods to always be backgrounded.
-
#background(options = { }) ⇒ Future
Allows you to background any method that has not been marked as a backgrounded method via #always_background.
- #method_added(method) ⇒ Object private
- #singleton_method_added(method) ⇒ Object private
Instance Method Details
#__enable_backgroundable_newrelic_tracing(method) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/torquebox/messaging/backgroundable.rb', line 102 def __enable_backgroundable_newrelic_tracing(method) method = method.to_s if Backgroundable.newrelic_available? TorqueBox::Messaging::Backgroundable::MUTEX.synchronize do @__enabled_bg_tracing_methods ||= {} if !@__enabled_bg_tracing_methods[method] include(NewRelic::Agent::Instrumentation::ControllerInstrumentation) unless include?(NewRelic::Agent::Instrumentation::ControllerInstrumentation) begin add_transaction_tracer(method, :name => method.sub("__sync_", ""), :category => :task) rescue Exception => e TorqueBox::Logger.new( Backgroundable ).error "Error loading New Relic for backgrounded method #{method.sub("__sync_", "")}: #{e}" end @__enabled_bg_tracing_methods[method] = true end end end end |
#always_background(*methods) ⇒ Object
Marks methods to always be backgrounded. Takes one or more method symbols, and an optional options hash as the final argument. The options allow you to set publish options for each call. see TorqueBox::Messaging::Destination#publish
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/torquebox/messaging/backgroundable.rb', line 63 def always_background(*methods) = methods.last.is_a?(Hash) ? methods.pop : {} @__backgroundable_methods ||= {} methods.each do |method| method = method.to_s if !@__backgroundable_methods[method] @__backgroundable_methods[method] ||= { } @__backgroundable_methods[method][:options] = if Util.singleton_methods_include?(self, method) || Util.instance_methods_include?(self, method) __enable_backgrounding(method) end end end end |
#background(options = { }) ⇒ Future
Allows you to background any method that has not been marked as a backgrounded method via #always_background.
85 86 87 |
# File 'lib/torquebox/messaging/backgroundable.rb', line 85 def background( = { }) BackgroundProxy.new(self, ) end |
#method_added(method) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
90 91 92 93 |
# File 'lib/torquebox/messaging/backgroundable.rb', line 90 def method_added(method) super __method_added(method) end |
#singleton_method_added(method) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
96 97 98 99 |
# File 'lib/torquebox/messaging/backgroundable.rb', line 96 def singleton_method_added(method) super __method_added(method) end |