Skip to content

Commit

Permalink
Remove support for legacy event system
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyadsl committed Apr 19, 2023
1 parent 04a4d68 commit c4bc28f
Show file tree
Hide file tree
Showing 20 changed files with 16 additions and 948 deletions.
12 changes: 4 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,13 @@ jobs:
paperclip:
type: boolean
default: true
legacy_events:
type: boolean
default: false
executor:
name: << parameters.database >>
ruby: << parameters.ruby >>
parallelism: &parallelism 3
environment:
DISABLE_ACTIVE_STORAGE: << parameters.paperclip >>
RAILS_VERSION: "~> << parameters.rails >>"
USE_LEGACY_EVENTS: << parameters.legacy_events >>
BUILDKITE_ANALYTICS_EXECUTION_NAME_PREFIX: "(<< parameters.ruby >>:<< parameters.rails >>:<< parameters.database >>:<< parameters.paperclip >>)"
steps:
- setup
Expand Down Expand Up @@ -328,12 +324,12 @@ workflows:
# Based on supported versions for the current Solidus release and recommended versions from
# https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html.
- test_solidus:
name: &name "test-rails-<<matrix.rails>>-ruby-<<matrix.ruby>>-<<matrix.database>>-<<#matrix.paperclip>>paperclip<</matrix.paperclip>><<^matrix.paperclip>>activestorage<</matrix.paperclip>><<#matrix.legacy_events>>-legacy_events<</matrix.legacy_events>>"
matrix: { parameters: { rails: ['7.0'], ruby: ['3.1', '3.2'], database: ['mysql', 'sqlite', 'postgres'], paperclip: [true, false], legacy_events: [false] } }
name: &name "test-rails-<<matrix.rails>>-ruby-<<matrix.ruby>>-<<matrix.database>>-<<#matrix.paperclip>>paperclip<</matrix.paperclip>><<^matrix.paperclip>>activestorage<</matrix.paperclip>>"
matrix: { parameters: { rails: ['7.0'], ruby: ['3.1', '3.2'], database: ['mysql', 'sqlite', 'postgres'], paperclip: [true, false] } }
- test_solidus:
name: *name
matrix: { parameters: { rails: ['6.1'], ruby: ['2.7', '3.0', '3.1'], database: ['sqlite'], paperclip: [false], legacy_events: [false] } }
matrix: { parameters: { rails: ['6.1'], ruby: ['2.7', '3.0', '3.1'], database: ['sqlite'], paperclip: [false] } }
- test_solidus:
name: *name
matrix: { parameters: { rails: ['6.0'], ruby: ['2.7'], database: ['sqlite'], paperclip: [true], legacy_events: [true] } }
matrix: { parameters: { rails: ['6.0'], ruby: ['2.7'], database: ['sqlite'], paperclip: [true] } }
- dev_tools
29 changes: 0 additions & 29 deletions core/app/subscribers/spree/mailer_subscriber.rb

This file was deleted.

12 changes: 0 additions & 12 deletions core/lib/spree/app_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,6 @@ def mails_from=(value)
# @return [] Track on_hand values for variants / products. (default: true)
preference :track_inventory_levels, :boolean, default: true

# @!attribute [rw] use_legacy_events
# Before v3.2, Solidus used a custom pub/sub implementation based on
# ActiveSupport::Notifications. Now, we internally use and recommend
# [Omnes](https://github.com/nebulab/omnes). This preference allows falling
# back to the old system.
# @return [Boolean]
versioned_preference :use_legacy_events, :boolean, initial_value: true, boundaries: { "3.2.0.alpha" => false }

# Other configurations

# Allows restricting what currencies will be available.
Expand Down Expand Up @@ -676,10 +668,6 @@ def roles
end
end

def events
@events_configuration ||= Spree::Event::Configuration.new
end

def user_last_url_storer_rules
@user_last_url_storer_rules ||= ::Spree::Core::ClassConstantizer::Set.new.tap do |set|
set << 'Spree::UserLastUrlStorer::Rules::AuthenticationRule'
Expand Down
11 changes: 0 additions & 11 deletions core/lib/spree/bus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,5 @@ module Spree
#
# This is used for internal events, while host applications are also able to
# use it.
#
# It has some modifications to support internal usage of the legacy event
# system {see Spree::AppConfiguration#use_legacy_events}.
Bus = Omnes::Bus.new
def Bus.publish(event, **kwargs)
if Spree::Config.use_legacy_events
Spree::Event.fire(event, **kwargs)
else
# Override caller_location to point to the actual event publisher
super(event, **kwargs, caller_location: caller_locations(1)[0])
end
end
end
1 change: 0 additions & 1 deletion core/lib/spree/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class GatewayError < RuntimeError; end
require 'spree/core/environment'
require 'spree/migrations'
require 'spree/migration_helpers'
require 'spree/event'
require 'spree/bus'
require 'spree/core/engine'

Expand Down
42 changes: 11 additions & 31 deletions core/lib/spree/core/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,17 @@ class Engine < ::Rails::Engine

# Setup pub/sub
initializer 'spree.core.pub_sub' do |app|
if Spree::Config.use_legacy_events
app.reloader.to_prepare do
Spree::Event.activate_autoloadable_subscribers
end

app.reloader.before_class_unload do
Spree::Event.deactivate_all_subscribers
end
else
app.reloader.to_prepare do
Spree::Bus.clear

%i[
order_finalized
order_recalculated
reimbursement_reimbursed
reimbursement_errored
].each { |event_name| Spree::Bus.register(event_name) }

Spree::OrderMailerSubscriber.new.subscribe_to(Spree::Bus)
end
app.reloader.to_prepare do
Spree::Bus.clear

%i[
order_finalized
order_recalculated
reimbursement_reimbursed
reimbursement_errored
].each { |event_name| Spree::Bus.register(event_name) }

Spree::OrderMailerSubscriber.new.subscribe_to(Spree::Bus)
end
end

Expand All @@ -97,16 +87,6 @@ class Engine < ::Rails::Engine
Spree::UsersController.protect_from_forgery with: :exception
end
end

config.after_initialize do
if Spree::Config.use_legacy_events && !ENV['CI']
Spree::Deprecation.warn <<~MSG
Your Solidus store is using the legacy event system. You're
encouraged to switch to the new event bus. After you're done, you
can remove the `use_legacy_events` setting from `spree.rb`.
MSG
end
end
end
end
end
119 changes: 0 additions & 119 deletions core/lib/spree/event.rb

This file was deleted.

67 changes: 0 additions & 67 deletions core/lib/spree/event/adapters/active_support_notifications.rb

This file was deleted.

25 changes: 0 additions & 25 deletions core/lib/spree/event/configuration.rb

This file was deleted.

Loading

0 comments on commit c4bc28f

Please sign in to comment.