mirror of
https://github.com/github/rails.git
synced 2026-01-09 22:58:02 -05:00
Renamed Orchestra to Notifications once again [#3321 state:resolved]
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -28,6 +28,9 @@ railties/guides/output
|
|||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
actionpack/bin
|
actionpack/bin
|
||||||
|
activerecord/bin
|
||||||
vendor/gems/
|
vendor/gems/
|
||||||
*/vendor/gems/
|
*/vendor/gems/
|
||||||
railties/tmp
|
railties/tmp
|
||||||
|
activerecord/vendor
|
||||||
|
actionpack/vendor
|
||||||
|
|||||||
@@ -481,7 +481,7 @@ module ActionMailer #:nodoc:
|
|||||||
# Initialize the mailer via the given +method_name+. The body will be
|
# Initialize the mailer via the given +method_name+. The body will be
|
||||||
# rendered and a new TMail::Mail object created.
|
# rendered and a new TMail::Mail object created.
|
||||||
def create!(method_name, *parameters) #:nodoc:
|
def create!(method_name, *parameters) #:nodoc:
|
||||||
ActiveSupport::Orchestra.instrument(:create_mail, :name => method_name) do
|
ActiveSupport::Notifications.instrument(:create_mail, :name => method_name) do
|
||||||
initialize_defaults(method_name)
|
initialize_defaults(method_name)
|
||||||
__send__(method_name, *parameters)
|
__send__(method_name, *parameters)
|
||||||
|
|
||||||
@@ -550,7 +550,7 @@ module ActionMailer #:nodoc:
|
|||||||
logger.debug "\n#{mail.encoded}"
|
logger.debug "\n#{mail.encoded}"
|
||||||
end
|
end
|
||||||
|
|
||||||
ActiveSupport::Orchestra.instrument(:deliver_mail, :mail => @mail) do
|
ActiveSupport::Notifications.instrument(:deliver_mail, :mail => @mail) do
|
||||||
begin
|
begin
|
||||||
__send__("perform_delivery_#{delivery_method}", mail) if perform_deliveries
|
__send__("perform_delivery_#{delivery_method}", mail) if perform_deliveries
|
||||||
rescue Exception => e # Net::SMTP errors or sendmail pipe errors
|
rescue Exception => e # Net::SMTP errors or sendmail pipe errors
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ module AbstractController
|
|||||||
# Override process_action in the AbstractController::Base
|
# Override process_action in the AbstractController::Base
|
||||||
# to log details about the method.
|
# to log details about the method.
|
||||||
def process_action(action)
|
def process_action(action)
|
||||||
result = ActiveSupport::Orchestra.instrument(:process_action,
|
result = ActiveSupport::Notifications.instrument(:process_action,
|
||||||
:controller => self, :action => action) do
|
:controller => self, :action => action) do
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ module ActionController #:nodoc:
|
|||||||
return content unless cache_configured?
|
return content unless cache_configured?
|
||||||
key = fragment_cache_key(key)
|
key = fragment_cache_key(key)
|
||||||
|
|
||||||
ActiveSupport::Orchestra.instrument(:write_fragment, :key => key) do
|
ActiveSupport::Notifications.instrument(:write_fragment, :key => key) do
|
||||||
cache_store.write(key, content, options)
|
cache_store.write(key, content, options)
|
||||||
end
|
end
|
||||||
content
|
content
|
||||||
@@ -64,7 +64,7 @@ module ActionController #:nodoc:
|
|||||||
return unless cache_configured?
|
return unless cache_configured?
|
||||||
key = fragment_cache_key(key)
|
key = fragment_cache_key(key)
|
||||||
|
|
||||||
ActiveSupport::Orchestra.instrument(:read_fragment, :key => key) do
|
ActiveSupport::Notifications.instrument(:read_fragment, :key => key) do
|
||||||
cache_store.read(key, options)
|
cache_store.read(key, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -74,7 +74,7 @@ module ActionController #:nodoc:
|
|||||||
return unless cache_configured?
|
return unless cache_configured?
|
||||||
key = fragment_cache_key(key)
|
key = fragment_cache_key(key)
|
||||||
|
|
||||||
ActiveSupport::Orchestra.instrument(:fragment_exist?, :key => key) do
|
ActiveSupport::Notifications.instrument(:fragment_exist?, :key => key) do
|
||||||
cache_store.exist?(key, options)
|
cache_store.exist?(key, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -101,7 +101,7 @@ module ActionController #:nodoc:
|
|||||||
key = fragment_cache_key(key) unless key.is_a?(Regexp)
|
key = fragment_cache_key(key) unless key.is_a?(Regexp)
|
||||||
message = nil
|
message = nil
|
||||||
|
|
||||||
ActiveSupport::Orchestra.instrument(:expire_fragment, :key => key) do
|
ActiveSupport::Notifications.instrument(:expire_fragment, :key => key) do
|
||||||
if key.is_a?(Regexp)
|
if key.is_a?(Regexp)
|
||||||
message = "Expired fragments matching: #{key.source}"
|
message = "Expired fragments matching: #{key.source}"
|
||||||
cache_store.delete_matched(key, options)
|
cache_store.delete_matched(key, options)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ module ActionController #:nodoc:
|
|||||||
return unless perform_caching
|
return unless perform_caching
|
||||||
path = page_cache_path(path)
|
path = page_cache_path(path)
|
||||||
|
|
||||||
ActiveSupport::Orchestra.instrument(:expire_page, :path => path) do
|
ActiveSupport::Notifications.instrument(:expire_page, :path => path) do
|
||||||
File.delete(path) if File.exist?(path)
|
File.delete(path) if File.exist?(path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -75,7 +75,7 @@ module ActionController #:nodoc:
|
|||||||
return unless perform_caching
|
return unless perform_caching
|
||||||
path = page_cache_path(path)
|
path = page_cache_path(path)
|
||||||
|
|
||||||
ActiveSupport::Orchestra.instrument(:cache_page, :path => path) do
|
ActiveSupport::Notifications.instrument(:cache_page, :path => path) do
|
||||||
FileUtils.makedirs(File.dirname(path))
|
FileUtils.makedirs(File.dirname(path))
|
||||||
File.open(path, "wb+") { |f| f.write(content) }
|
File.open(path, "wb+") { |f| f.write(content) }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
require 'active_support/orchestra'
|
require 'active_support/notifications'
|
||||||
|
|
||||||
ActiveSupport::Orchestra.subscribe(/(read|write|cache|expire|exist)_(fragment|page)\??/) do |event|
|
ActiveSupport::Notifications.subscribe(/(read|write|cache|expire|exist)_(fragment|page)\??/) do |event|
|
||||||
if logger = ActionController::Base.logger
|
if logger = ActionController::Base.logger
|
||||||
human_name = event.name.to_s.humanize
|
human_name = event.name.to_s.humanize
|
||||||
logger.info("#{human_name} (%.1fms)" % event.duration)
|
logger.info("#{human_name} (%.1fms)" % event.duration)
|
||||||
@@ -27,7 +27,7 @@ module ActionView
|
|||||||
end
|
end
|
||||||
|
|
||||||
def render(view, locals, &block)
|
def render(view, locals, &block)
|
||||||
ActiveSupport::Orchestra.instrument(:render_template, :identifier => identifier) do
|
ActiveSupport::Notifications.instrument(:render_template, :identifier => identifier) do
|
||||||
method_name = compile(locals, view)
|
method_name = compile(locals, view)
|
||||||
view.send(method_name, locals, &block)
|
view.send(method_name, locals, &block)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -628,7 +628,7 @@ class FragmentCachingTest < ActionController::TestCase
|
|||||||
|
|
||||||
def test_fragment_for_logging
|
def test_fragment_for_logging
|
||||||
fragment_computed = false
|
fragment_computed = false
|
||||||
ActiveSupport::Orchestra.queue.expects(:publish).times(2)
|
ActiveSupport::Notifications.queue.expects(:publish).times(2)
|
||||||
|
|
||||||
buffer = 'generated till now -> '
|
buffer = 'generated till now -> '
|
||||||
@controller.fragment_for(buffer, 'expensive') { fragment_computed = true }
|
@controller.fragment_for(buffer, 'expensive') { fragment_computed = true }
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ module ActiveRecord
|
|||||||
|
|
||||||
protected
|
protected
|
||||||
def log(sql, name, &block)
|
def log(sql, name, &block)
|
||||||
ActiveSupport::Orchestra.instrument(:sql, :sql => sql, :name => name, &block)
|
ActiveSupport::Notifications.instrument(:sql, :sql => sql, :name => name, &block)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
# Log message and raise exception.
|
# Log message and raise exception.
|
||||||
# Set last_verification to 0, so that connection gets verified
|
# Set last_verification to 0, so that connection gets verified
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
require 'active_support/orchestra'
|
require 'active_support/notifications'
|
||||||
|
|
||||||
ActiveSupport::Orchestra.subscribe("sql") do |event|
|
ActiveSupport::Notifications.subscribe("sql") do |event|
|
||||||
ActiveRecord::Base.connection.log_info(event.payload[:sql], event.payload[:name], event.duration)
|
ActiveRecord::Base.connection.log_info(event.payload[:sql], event.payload[:name], event.duration)
|
||||||
end
|
end
|
||||||
@@ -18,9 +18,9 @@ module ActiveSupport
|
|||||||
autoload :MessageVerifier, 'active_support/message_verifier'
|
autoload :MessageVerifier, 'active_support/message_verifier'
|
||||||
autoload :Multibyte, 'active_support/multibyte'
|
autoload :Multibyte, 'active_support/multibyte'
|
||||||
autoload :OptionMerger, 'active_support/option_merger'
|
autoload :OptionMerger, 'active_support/option_merger'
|
||||||
autoload :Orchestra, 'active_support/orchestra'
|
|
||||||
autoload :OrderedHash, 'active_support/ordered_hash'
|
autoload :OrderedHash, 'active_support/ordered_hash'
|
||||||
autoload :OrderedOptions, 'active_support/ordered_options'
|
autoload :OrderedOptions, 'active_support/ordered_options'
|
||||||
|
autoload :Notifications, 'active_support/notifications'
|
||||||
autoload :Rescuable, 'active_support/rescuable'
|
autoload :Rescuable, 'active_support/rescuable'
|
||||||
autoload :SecureRandom, 'active_support/secure_random'
|
autoload :SecureRandom, 'active_support/secure_random'
|
||||||
autoload :StringInquirer, 'active_support/string_inquirer'
|
autoload :StringInquirer, 'active_support/string_inquirer'
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ module ActiveSupport
|
|||||||
if self.class.instrument
|
if self.class.instrument
|
||||||
payload = { :key => key }
|
payload = { :key => key }
|
||||||
payload.merge!(options) if options.is_a?(Hash)
|
payload.merge!(options) if options.is_a?(Hash)
|
||||||
ActiveSupport::Orchestra.instrument(:"cache_#{operation}", payload, &block)
|
ActiveSupport::Notifications.instrument(:"cache_#{operation}", payload, &block)
|
||||||
else
|
else
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ require 'active_support/core_ext/module/delegation'
|
|||||||
require 'active_support/core_ext/module/attribute_accessors'
|
require 'active_support/core_ext/module/attribute_accessors'
|
||||||
|
|
||||||
module ActiveSupport
|
module ActiveSupport
|
||||||
# Orchestra provides an instrumentation API for Ruby. To instrument an action
|
# Notifications provides an instrumentation API for Ruby. To instrument an
|
||||||
# in Ruby you just need to do:
|
# action in Ruby you just need to do:
|
||||||
#
|
#
|
||||||
# ActiveSupport::Orchestra.instrument(:render, :extra => :information) do
|
# ActiveSupport::Notifications.instrument(:render, :extra => :information) do
|
||||||
# render :text => "Foo"
|
# render :text => "Foo"
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
@@ -15,39 +15,39 @@ module ActiveSupport
|
|||||||
#
|
#
|
||||||
# @events = []
|
# @events = []
|
||||||
#
|
#
|
||||||
# ActiveSupport::Orchestra.subscribe do |event|
|
# ActiveSupport::Notifications.subscribe do |event|
|
||||||
# @events << event
|
# @events << event
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# ActiveSupport::Orchestra.instrument(:render, :extra => :information) do
|
# ActiveSupport::Notifications.instrument(:render, :extra => :information) do
|
||||||
# render :text => "Foo"
|
# render :text => "Foo"
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# event = @events.first
|
# event = @events.first
|
||||||
# event.class #=> ActiveSupport::Orchestra::Event
|
# event.class #=> ActiveSupport::Notifications::Event
|
||||||
# event.name #=> :render
|
# event.name #=> :render
|
||||||
# event.duration #=> 10 (in miliseconds)
|
# event.duration #=> 10 (in miliseconds)
|
||||||
# event.result #=> "Foo"
|
# event.result #=> "Foo"
|
||||||
# event.payload #=> { :extra => :information }
|
# event.payload #=> { :extra => :information }
|
||||||
#
|
#
|
||||||
# When subscribing to Orchestra, you can pass a pattern, to only consume
|
# When subscribing to Notifications, you can pass a pattern, to only consume
|
||||||
# events that match the pattern:
|
# events that match the pattern:
|
||||||
#
|
#
|
||||||
# ActiveSupport::Orchestra.subscribe(/render/) do |event|
|
# ActiveSupport::Notifications.subscribe(/render/) do |event|
|
||||||
# @render_events << event
|
# @render_events << event
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# Orchestra ships with a queue implementation that consumes and publish events
|
# Notifications ships with a queue implementation that consumes and publish events
|
||||||
# to subscribers in a thread. You can use any queue implementation you want.
|
# to subscribers in a thread. You can use any queue implementation you want.
|
||||||
#
|
#
|
||||||
module Orchestra
|
module Notifications
|
||||||
mattr_accessor :queue
|
mattr_accessor :queue
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
delegate :instrument, :to => :instrumenter
|
delegate :instrument, :to => :instrumenter
|
||||||
|
|
||||||
def instrumenter
|
def instrumenter
|
||||||
Thread.current[:orchestra_instrumeter] ||= Instrumenter.new(publisher)
|
Thread.current[:notifications_instrumeter] ||= Instrumenter.new(publisher)
|
||||||
end
|
end
|
||||||
|
|
||||||
def publisher
|
def publisher
|
||||||
@@ -119,7 +119,7 @@ module ActiveSupport
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# This is a default queue implementation that ships with Orchestra. It
|
# This is a default queue implementation that ships with Notifications. It
|
||||||
# consumes events in a thread and publish them to all registered subscribers.
|
# consumes events in a thread and publish them to all registered subscribers.
|
||||||
#
|
#
|
||||||
class LittleFanout
|
class LittleFanout
|
||||||
@@ -167,5 +167,5 @@ module ActiveSupport
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Orchestra.queue = Orchestra::LittleFanout.new
|
Notifications.queue = Notifications::LittleFanout.new
|
||||||
end
|
end
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
require 'abstract_unit'
|
require 'abstract_unit'
|
||||||
|
|
||||||
# Allow LittleFanout to be cleaned.
|
# Allow LittleFanout to be cleaned.
|
||||||
class ActiveSupport::Orchestra::LittleFanout
|
class ActiveSupport::Notifications::LittleFanout
|
||||||
def clear
|
def clear
|
||||||
@listeners.clear
|
@listeners.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class OrchestraEventTest < Test::Unit::TestCase
|
class NotificationsEventTest < Test::Unit::TestCase
|
||||||
def test_events_are_initialized_with_name_and_payload
|
def test_events_are_initialized_with_name_and_payload
|
||||||
event = event(:foo, :payload => :bar)
|
event = event(:foo, :payload => :bar)
|
||||||
assert_equal :foo, event.name
|
assert_equal :foo, event.name
|
||||||
@@ -37,24 +37,24 @@ class OrchestraEventTest < Test::Unit::TestCase
|
|||||||
protected
|
protected
|
||||||
|
|
||||||
def event(*args)
|
def event(*args)
|
||||||
ActiveSupport::Orchestra::Event.new(*args)
|
ActiveSupport::Notifications::Event.new(*args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class OrchestraMainTest < Test::Unit::TestCase
|
class NotificationsMainTest < Test::Unit::TestCase
|
||||||
def setup
|
def setup
|
||||||
@events = []
|
@events = []
|
||||||
Thread.abort_on_exception = true
|
Thread.abort_on_exception = true
|
||||||
ActiveSupport::Orchestra.subscribe { |event| @events << event }
|
ActiveSupport::Notifications.subscribe { |event| @events << event }
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
Thread.abort_on_exception = false
|
Thread.abort_on_exception = false
|
||||||
ActiveSupport::Orchestra.queue.clear
|
ActiveSupport::Notifications.queue.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_orchestra_returns_action_result
|
def test_notifications_returns_action_result
|
||||||
result = ActiveSupport::Orchestra.instrument(:awesome, :payload => "orchestra") do
|
result = ActiveSupport::Notifications.instrument(:awesome, :payload => "notifications") do
|
||||||
1 + 1
|
1 + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ class OrchestraMainTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_events_are_published_to_a_listener
|
def test_events_are_published_to_a_listener
|
||||||
ActiveSupport::Orchestra.instrument(:awesome, :payload => "orchestra") do
|
ActiveSupport::Notifications.instrument(:awesome, :payload => "notifications") do
|
||||||
1 + 1
|
1 + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -70,12 +70,12 @@ class OrchestraMainTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
assert_equal 1, @events.size
|
assert_equal 1, @events.size
|
||||||
assert_equal :awesome, @events.last.name
|
assert_equal :awesome, @events.last.name
|
||||||
assert_equal Hash[:payload => "orchestra"], @events.last.payload
|
assert_equal Hash[:payload => "notifications"], @events.last.payload
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_nested_events_can_be_instrumented
|
def test_nested_events_can_be_instrumented
|
||||||
ActiveSupport::Orchestra.instrument(:awesome, :payload => "orchestra") do
|
ActiveSupport::Notifications.instrument(:awesome, :payload => "notifications") do
|
||||||
ActiveSupport::Orchestra.instrument(:wot, :payload => "child") do
|
ActiveSupport::Notifications.instrument(:wot, :payload => "child") do
|
||||||
1 + 1
|
1 + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -90,12 +90,12 @@ class OrchestraMainTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
assert_equal 2, @events.size
|
assert_equal 2, @events.size
|
||||||
assert_equal :awesome, @events.last.name
|
assert_equal :awesome, @events.last.name
|
||||||
assert_equal Hash[:payload => "orchestra"], @events.last.payload
|
assert_equal Hash[:payload => "notifications"], @events.last.payload
|
||||||
assert_in_delta 100, @events.last.duration, 70
|
assert_in_delta 100, @events.last.duration, 70
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_event_is_pushed_even_if_block_fails
|
def test_event_is_pushed_even_if_block_fails
|
||||||
ActiveSupport::Orchestra.instrument(:awesome, :payload => "orchestra") do
|
ActiveSupport::Notifications.instrument(:awesome, :payload => "notifications") do
|
||||||
raise "OMG"
|
raise "OMG"
|
||||||
end rescue RuntimeError
|
end rescue RuntimeError
|
||||||
|
|
||||||
@@ -103,22 +103,22 @@ class OrchestraMainTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
assert_equal 1, @events.size
|
assert_equal 1, @events.size
|
||||||
assert_equal :awesome, @events.last.name
|
assert_equal :awesome, @events.last.name
|
||||||
assert_equal Hash[:payload => "orchestra"], @events.last.payload
|
assert_equal Hash[:payload => "notifications"], @events.last.payload
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_event_is_pushed_even_without_block
|
def test_event_is_pushed_even_without_block
|
||||||
ActiveSupport::Orchestra.instrument(:awesome, :payload => "orchestra")
|
ActiveSupport::Notifications.instrument(:awesome, :payload => "notifications")
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
|
|
||||||
assert_equal 1, @events.size
|
assert_equal 1, @events.size
|
||||||
assert_equal :awesome, @events.last.name
|
assert_equal :awesome, @events.last.name
|
||||||
assert_equal Hash[:payload => "orchestra"], @events.last.payload
|
assert_equal Hash[:payload => "notifications"], @events.last.payload
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_subscriber_with_pattern
|
def test_subscriber_with_pattern
|
||||||
@another = []
|
@another = []
|
||||||
ActiveSupport::Orchestra.subscribe("cache"){ |event| @another << event }
|
ActiveSupport::Notifications.subscribe("cache"){ |event| @another << event }
|
||||||
ActiveSupport::Orchestra.instrument(:cache){ 1 }
|
ActiveSupport::Notifications.instrument(:cache){ 1 }
|
||||||
|
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
|
|
||||||
@@ -129,10 +129,10 @@ class OrchestraMainTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_subscriber_with_pattern_as_regexp
|
def test_subscriber_with_pattern_as_regexp
|
||||||
@another = []
|
@another = []
|
||||||
ActiveSupport::Orchestra.subscribe(/cache/){ |event| @another << event }
|
ActiveSupport::Notifications.subscribe(/cache/){ |event| @another << event }
|
||||||
|
|
||||||
ActiveSupport::Orchestra.instrument(:something){ 0 }
|
ActiveSupport::Notifications.instrument(:something){ 0 }
|
||||||
ActiveSupport::Orchestra.instrument(:cache){ 1 }
|
ActiveSupport::Notifications.instrument(:cache){ 1 }
|
||||||
|
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
|
|
||||||
@@ -143,10 +143,10 @@ class OrchestraMainTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_with_several_consumers_and_several_events
|
def test_with_several_consumers_and_several_events
|
||||||
@another = []
|
@another = []
|
||||||
ActiveSupport::Orchestra.subscribe { |event| @another << event }
|
ActiveSupport::Notifications.subscribe { |event| @another << event }
|
||||||
|
|
||||||
1.upto(100) do |i|
|
1.upto(100) do |i|
|
||||||
ActiveSupport::Orchestra.instrument(:value){ i }
|
ActiveSupport::Notifications.instrument(:value){ i }
|
||||||
end
|
end
|
||||||
|
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
@@ -488,12 +488,12 @@ module Rails
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# For each framework, search for instrument file with Orchestra hooks.
|
# For each framework, search for instrument file with Notifications hooks.
|
||||||
#
|
#
|
||||||
initializer :load_orchestra_instrumentation do
|
initializer :load_notifications_hooks do
|
||||||
config.frameworks.each do |framework|
|
config.frameworks.each do |framework|
|
||||||
begin
|
begin
|
||||||
require "#{framework}/instrument"
|
require "#{framework}/notifications"
|
||||||
rescue LoadError => e
|
rescue LoadError => e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -290,12 +290,12 @@ module Rails
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Allows Orchestra queue to be modified.
|
# Allows Notifications queue to be modified.
|
||||||
#
|
#
|
||||||
# config.orchestra.queue = MyNewQueue.new
|
# config.notifications.queue = MyNewQueue.new
|
||||||
#
|
#
|
||||||
def orchestra
|
def notifications
|
||||||
ActiveSupport::Orchestra
|
ActiveSupport::Notifications
|
||||||
end
|
end
|
||||||
|
|
||||||
class Generators #:nodoc:
|
class Generators #:nodoc:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
require "isolation/abstract_unit"
|
require "isolation/abstract_unit"
|
||||||
|
|
||||||
module ApplicationTests
|
module ApplicationTests
|
||||||
class OrchestraTest < Test::Unit::TestCase
|
class NotificationsTest < Test::Unit::TestCase
|
||||||
include ActiveSupport::Testing::Isolation
|
include ActiveSupport::Testing::Isolation
|
||||||
|
|
||||||
class MyQueue
|
class MyQueue
|
||||||
@@ -25,26 +25,26 @@ module ApplicationTests
|
|||||||
build_app
|
build_app
|
||||||
boot_rails
|
boot_rails
|
||||||
|
|
||||||
require "active_support/orchestra"
|
require "active_support/notifications"
|
||||||
Rails::Initializer.run do |c|
|
Rails::Initializer.run do |c|
|
||||||
c.orchestra.queue = MyQueue.new
|
c.notifications.queue = MyQueue.new
|
||||||
c.orchestra.subscribe(/listening/) do
|
c.notifications.subscribe(/listening/) do
|
||||||
puts "Cool"
|
puts "Cool"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "new queue is set" do
|
test "new queue is set" do
|
||||||
ActiveSupport::Orchestra.instrument(:foo)
|
ActiveSupport::Notifications.instrument(:foo)
|
||||||
assert_equal :foo, ActiveSupport::Orchestra.queue.events.first
|
assert_equal :foo, ActiveSupport::Notifications.queue.events.first
|
||||||
end
|
end
|
||||||
|
|
||||||
test "frameworks subscribers are loaded" do
|
test "frameworks subscribers are loaded" do
|
||||||
assert_equal 1, ActiveSupport::Orchestra.queue.subscribers.count { |s| s == "sql" }
|
assert_equal 1, ActiveSupport::Notifications.queue.subscribers.count { |s| s == "sql" }
|
||||||
end
|
end
|
||||||
|
|
||||||
test "configuration subscribers are loaded" do
|
test "configuration subscribers are loaded" do
|
||||||
assert_equal 1, ActiveSupport::Orchestra.queue.subscribers.count { |s| s == /listening/ }
|
assert_equal 1, ActiveSupport::Notifications.queue.subscribers.count { |s| s == /listening/ }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user