diff --git a/REFACTOR.md b/REFACTOR.md new file mode 100644 index 00000000..8eb7a41c --- /dev/null +++ b/REFACTOR.md @@ -0,0 +1 @@ +20200703113000: `require "celluloid/current"` is removed. use `require "celluloid"` diff --git a/examples/configurations.rb b/examples/configurations.rb index 121bf25f..76bc1416 100644 --- a/examples/configurations.rb +++ b/examples/configurations.rb @@ -1,4 +1,4 @@ -require "celluloid/current" +require "celluloid" puts "Use Supervision::Configuration objects!" diff --git a/examples/timers.rb b/examples/timers.rb index e5c523ab..ec5d01fd 100755 --- a/examples/timers.rb +++ b/examples/timers.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby $LOAD_PATH.push File.expand_path("../lib", __dir__) -require "celluloid/current" +require "celluloid" class TimerExample include Celluloid diff --git a/lib/celluloid/backported.rb b/lib/celluloid/backported.rb deleted file mode 100644 index fb4526aa..00000000 --- a/lib/celluloid/backported.rb +++ /dev/null @@ -1,6 +0,0 @@ -raise NotImplementedError, <<-MSG.strip.gsub(/\s+/, " ") - Celluloid 0.18 no-longer supports the "backported" API. - Please switch to using: `require 'celluloid'` - For more information, see: - https://github.com/celluloid/celluloid/wiki/0.18-API-changes -MSG diff --git a/lib/celluloid/current.rb b/lib/celluloid/current.rb deleted file mode 100644 index 2a02693c..00000000 --- a/lib/celluloid/current.rb +++ /dev/null @@ -1,4 +0,0 @@ -# Legacy support for the prescribed 0.17 API -# TODO: remove this in a future release - -require "celluloid" diff --git a/lib/celluloid/managed.rb b/lib/celluloid/managed.rb deleted file mode 100644 index 32956ba0..00000000 --- a/lib/celluloid/managed.rb +++ /dev/null @@ -1,6 +0,0 @@ -raise NotImplementedError, <<-MSG.strip.gsub(/\s+/, " ") - Celluloid 0.18 no-longer supports the "managed" API. - Please switch to using: `require 'celluloid'` - For more information, see: - https://github.com/celluloid/celluloid/wiki/0.18-API-changes -MSG diff --git a/lib/celluloid/supervision/container/tree.rb b/lib/celluloid/supervision/container/tree.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/celluloid/supervision/deprecate.rb b/lib/celluloid/supervision/deprecate.rb deleted file mode 100644 index 1990eb62..00000000 --- a/lib/celluloid/supervision/deprecate.rb +++ /dev/null @@ -1,9 +0,0 @@ -# TODO: Remove at 0.19.0 -module Celluloid - SupervisionGroup = Supervision::Container - Supervision::Group = Supervision::Container - Supervision::Member = Supervision::Container::Instance -end - -require "celluloid/supervision/deprecate/supervise" -require "celluloid/supervision/deprecate/validation" diff --git a/lib/celluloid/supervision/deprecate/supervise.rb b/lib/celluloid/supervision/deprecate/supervise.rb deleted file mode 100644 index 29932491..00000000 --- a/lib/celluloid/supervision/deprecate/supervise.rb +++ /dev/null @@ -1,105 +0,0 @@ -# TODO: Remove at 0.19.0 -module Celluloid - class << self - undef supervise rescue nil - def supervise(*args, &block) - supervisor = Supervision.router(*args) - supervisor.supervise(*args, &block) - end - undef supervise_as rescue nil - def supervise_as(name, *args, &block) - supervisor = Supervision.router(*args) - supervisor.supervise_as(name, *args, &block) - end - end - module ClassMethods - undef supervise rescue nil - def supervise(*args, &block) - args.unshift(self) - Celluloid.supervise(*args, &block) - end - undef supervise_as rescue nil - def supervise_as(name, *args, &block) - args.unshift(self) - Celluloid.supervise_as(name, *args, &block) - end - end - - # Supervisors are actors that watch over other actors and restart them if - # they crash - class Supervisor - class << self - # Define the root of the supervision tree - attr_accessor :root - - undef supervise rescue nil - def supervise(klass, *args, &block) - args.unshift(klass) - Celluloid.supervise(*args, &block) - end - - undef supervise_as rescue nil - def supervise_as(name, klass, *args, &block) - args.unshift(klass) - Celluloid.supervise_as(name, *args, &block) - end - end - end - - module Supervision - class << self - undef router rescue nil - def router(*_args) - # TODO: Actually route, based on :branch, if present; or else: - Celluloid.services - end - end - class Container - class << self - undef run! rescue nil - def run!(*args) - container = new(*args) do |g| - blocks.each do |block| - block.call(g) - end - end - container - end - - undef run rescue nil - def run(*args) - loop do - supervisor = run!(*args) - # Take five, toplevel supervisor - sleep 5 while supervisor.alive? # Why 5? - Internals::Logger.error "!!! Celluloid::Supervision::Container #{self} crashed. Restarting..." - end - end - - undef supervise rescue nil - def supervise(*args, &block) - blocks << lambda do |container| - container.supervise(*args, &block) - end - end - - undef supervise_as rescue nil - def supervise_as(name, *args, &block) - blocks << lambda do |container| - container.supervise_as(name, *args, &block) - end - end - end - - undef supervise rescue nil - def supervise(*args, &block) - add(Configuration.options(args, block: block)) - end - - undef supervise_as rescue nil - def supervise_as(name, *args, &block) - add(Configuration.options(args, block: block, as: name)) - end - end - end -end diff --git a/lib/celluloid/supervision/deprecate/validation.rb b/lib/celluloid/supervision/deprecate/validation.rb deleted file mode 100644 index 8c5df685..00000000 --- a/lib/celluloid/supervision/deprecate/validation.rb +++ /dev/null @@ -1,54 +0,0 @@ -module Celluloid - module Supervision - class Configuration - class << self - # argument scenarios: - # * only class ( becomes :type ) - # * class ( becomes :type ), hash* - # * hash ( *with :type, and perhaps :as, :size, :args, :block, :registry ) - # ( any keys expected are pulled out: may want to check on arity? ) - # ( the pulling out of keys is where danger mentioned above comes ) - undef parse rescue nil - def parse(args) - return args if args.is_a? Configuration::Instance - options = { args: [] } - return { type: args } if args.is_a? Class - if args.is_a? Hash - return args - elsif args.is_a? Array - if args.length == 1 - return args[0] if args.first.is_a? Configuration::Instance - return { type: args.first } if args.first.is_a? Class - if args.first.is_a?(Hash) && args = args.pop - return args - end - options[:args] = args if args.any? - elsif args.length > 1 - # TODO: don't use each - options.merge! args.pop if args.last.is_a? Hash - options[:type] = args.shift if args.first.is_a? Class - options[:args] += args if args.any? - end - end - options - end - - # This is dangerous. It is temporary, until `Supervision::Configuration` is entrenched. - # Since :type, :as, etc are used by the supervision group/member to initialize, - # those will not appear in the resulting actor's initialize call. - undef options rescue nil - def options(args, options = {}) - return args.merge!(options) if args.is_a? Configuration::Instance - # Not a Supervision:Configuration? - # Try to guess its structure and build one: - options = parse(args).merge(options) - options[:configuration] = Container::Behavior.configure(options) - options[:args].compact! if options[:args].is_a? Array - options.reject! { |_k, v| v.nil? } - Configuration.valid? options, true - options - end - end - end - end -end