ruby-concurrency / concurrent-ruby

Modern concurrency tools including agents, futures, promises, thread pools, supervisors, and more. Inspired by Erlang, Clojure, Scala, Go, Java, JavaScript, and classic concurrency patterns.
https://ruby-concurrency.github.io/concurrent-ruby/
Other
5.71k stars 420 forks source link

Deprecate require ‘concurrent-ruby’ #948

Closed chrisseaton closed 2 years ago

eregon commented 2 years ago

I'm not sure it's worth the trouble, this seems used by several gems, and the name of this gem kind of implies require 'concurrent-ruby' should work. Also the cost to keep this seems close to zero. I personally feel weird every time I see require 'concurrent'.

$ gem-codesearch 'require.+concurrent-ruby' | grep -v vendor/bundle
/srv/gems/apollo-studio-tracing-1.1.0/lib/apollo-studio-tracing/shutdown_barrier.rb:require 'concurrent-ruby'
/srv/gems/back_run-0.1.0/lib/back_run/worker.rb:require 'concurrent-ruby'
/srv/gems/backtor-0.1.0/lib/backtor.rb:require 'concurrent-ruby'
/srv/gems/cem_acpt-0.1.0/lib/cem_acpt/context.rb:require 'concurrent-ruby'
/srv/gems/cem_acpt-0.1.0/lib/cem_acpt/platform.rb:require 'concurrent-ruby'
/srv/gems/cem_acpt-0.1.0/lib/cem_acpt/runner.rb:require 'concurrent-ruby'
/srv/gems/cem_acpt-0.1.0/lib/cem_acpt/shared_objects.rb:require 'concurrent-ruby'
/srv/gems/cobra_commander-0.14.0/lib/cobra_commander/cli.rb:require "concurrent-ruby"
/srv/gems/cobra_commander-0.14.0/lib/cobra_commander/executor/concurrent.rb:require "concurrent-ruby"
/srv/gems/concurrent-ruby-1.1.9/Gemfile:require File.join(File.dirname(__FILE__), 'lib/concurrent-ruby/concurrent/version')
/srv/gems/concurrent-ruby-1.1.9/Gemfile:require File.join(File.dirname(__FILE__ ), 'lib/concurrent-ruby-edge/concurrent/edge/version')
/srv/gems/concurrent-ruby-1.1.9/Gemfile:require File.join(File.dirname(__FILE__ ), 'lib/concurrent-ruby/concurrent/utility/engine')
/srv/gems/concurrent-ruby-1.1.9/Rakefile:require_relative 'lib/concurrent-ruby/concurrent/version'
/srv/gems/concurrent-ruby-1.1.9/Rakefile:require_relative 'lib/concurrent-ruby-edge/concurrent/edge/version'
/srv/gems/concurrent-ruby-1.1.9/Rakefile:require_relative 'lib/concurrent-ruby/concurrent/utility/engine'
/srv/gems/context_provider-0.0.1/lib/context_provider.rb:require 'concurrent-ruby'
/srv/gems/countonce-0.1.0/lib/countonce.rb:require "concurrent-ruby"
/srv/gems/cutoff-0.4.2/lib/cutoff/timer.rb:      require 'concurrent-ruby'
/srv/gems/elastic-apm-4.5.0/CHANGELOG.asciidoc:- Laxed version requirement of concurrent-ruby
/srv/gems/etna-0.1.44/lib/etna/filesystem.rb:require 'concurrent-ruby'
/srv/gems/fancybox2-0.0.12/lib/fancybox2/module/base.rb:require 'concurrent-ruby'
/srv/gems/ferrum-0.11/lib/ferrum/browser/client.rb:require "concurrent-ruby"
/srv/gems/ferrum-0.11/lib/ferrum/browser/subscriber.rb:require "concurrent-ruby"
/srv/gems/ff-ruby-server-sdk-1.0.0/lib/ff/ruby/server/sdk/api/metrics_processor.rb:require "concurrent-ruby"
/srv/gems/ff-ruby-server-sdk-1.0.0/lib/ff/ruby/server/sdk/api/update_processor.rb:require "concurrent-ruby"
/srv/gems/foot_traffic-0.1.0/README.md:require "concurrent" # concurrent-ruby
/srv/gems/foot_traffic-0.1.0/examples/cookies.rb:require "concurrent" # concurrent-ruby
/srv/gems/gene_pool-1.5.0/lib/gene_pool.rb:require 'concurrent-ruby'
/srv/gems/glimmer-dsl-jfx-0.0.1/lib/glimmer-dsl-jfx.rb:require 'concurrent-ruby' # ensures glimmer relies on Concurrent data-structure classes (e.g. Concurrent::Array)
/srv/gems/glimmer-dsl-swing-0.0.5/lib/glimmer-dsl-swing.rb:require 'concurrent-ruby' # ensures glimmer relies on Concurrent data-structure classes (e.g. Concurrent::Array)
/srv/gems/gush-2.0.2/lib/gush/client.rb:require 'concurrent-ruby'
/srv/gems/heartcheck-2.0.0/lib/heartcheck.rb:    # requires 'concurrent-ruby'
/srv/gems/ib_ruby_proxy-0.0.3/lib/ib_ruby_proxy.rb:require 'concurrent-ruby'
/srv/gems/legion-transport-1.2.0/lib/legion/transport/connection.rb:require 'concurrent-ruby'
/srv/gems/legion-transport-java-1.1.4/lib/legion/transport/connection.rb:require 'concurrent-ruby'
/srv/gems/lexicon-common-0.2.0/lib/lexicon-common.rb:require 'concurrent-ruby'
/srv/gems/mongo-2.17.0/spec/lite_spec_helper.rb:  require 'concurrent-ruby'
/srv/gems/nanoc-core-4.12.5/lib/nanoc/core.rb:require 'concurrent-ruby'
/srv/gems/nanoc-github-1.2.0/lib/nanoc/github.rb:require "concurrent-ruby"
/srv/gems/paradin-0.1.2/lib/paradin/task.rb:require "concurrent-ruby"
/srv/gems/promoted-ruby-client-0.1.24/lib/promoted/ruby/client.rb:require "concurrent-ruby"
/srv/gems/renalware-core-2.1.1/lib/renalware/engine.rb:require "concurrent-ruby"
/srv/gems/rjob-0.5.1/lib/rjob.rb:require 'concurrent-ruby'
/srv/gems/rocketjob-6.1.0/lib/rocket_job/event.rb:require "concurrent-ruby"
/srv/gems/rocketjob-6.1.0/lib/rocket_job/worker_pool.rb:require "concurrent-ruby"
/srv/gems/s3_zipper-3.0.0/lib/s3_zipper/spinner.rb:require "concurrent-ruby"
/srv/gems/schdlr-0.1.1/lib/schdlr.rb:require 'concurrent-ruby'
/srv/gems/secret_config-1.0.0/lib/secret_config/registry.rb:require "concurrent-ruby"
/srv/gems/secrets-manager-1.1.0/lib/secrets-manager.rb:require "concurrent-ruby"
/srv/gems/signalwire-2.3.4/lib/signalwire/blade/connection.rb:require 'concurrent-ruby'
/srv/gems/signalwire-2.3.4/lib/signalwire/relay/calling.rb:require 'concurrent-ruby'
/srv/gems/signalwire-2.3.4/lib/signalwire/relay/messaging.rb:require 'concurrent-ruby'
/srv/gems/tac_scribe-0.8.1/lib/tac_scribe/cache.rb:require 'concurrent-ruby'
/srv/gems/tac_scribe-0.8.1/lib/tac_scribe/event_processor.rb:require 'concurrent-ruby'
/srv/gems/tdlib-ruby-3.0.2/lib/tdlib-ruby.rb:require 'concurrent-ruby'
/srv/gems/telemetry-amqp-0.1.0/lib/telemetry/amqp/base.rb:require 'concurrent-ruby'
/srv/gems/tomo-1.11.0/lib/tomo/runtime/concurrent_ruby_load_error.rb:          Running tasks on multiple hosts requires the #{yellow('concurrent-ruby')} gem.
/srv/gems/turbo_test_constant_tracer-0.1.12/lib/turbo_test_constant_tracer/event_publisher.rb:require "concurrent-ruby"
/srv/gems/vessel-0.2.0/lib/vessel/scheduler.rb:require "concurrent-ruby"
/srv/gems/vessel-0.2.0/lib/vessel.rb:require "concurrent-ruby"
/srv/gems/victory-0.5.2/lib/victory.rb:require 'concurrent-ruby'
chrisseaton commented 2 years ago

Seems like it was only added as some kind of workaround?

https://github.com/ruby-concurrency/concurrent-ruby/commit/714d9196850c7157297975e2c88db5cc4fd881e0

Not sure how we ended up with two ways to do the same thing. One would be better.

eregon commented 2 years ago

https://github.com/ruby-concurrency/concurrent-ruby/pull/709 seems a valuable feature, and breaking Bundler.require is probably unacceptable for Rails or other projects with concurrent-ruby in the Gemfile and using Bundler.require.

And it's still needed for Bundler.require:

source 'https://rubygems.org'

gem 'concurrent-ruby'
$ bundle
$ bundle exec ruby -e 'Bundler.require; puts $"' | grep concurrent-ruby
...
/home/eregon/.rubies/ruby-3.0.2/lib/ruby/gems/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent.rb
/home/eregon/.rubies/ruby-3.0.2/lib/ruby/gems/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent-ruby.rb

If I remove concurrent-ruby.rb:

$ bundle exec ruby -de 'p Bundler.require; p Concurrent'
-e:1:in `<main>': uninitialized constant Concurrent (NameError)

So maybe the only missing thing here is a test for require 'concurrent-ruby'.