Skip to content
This repository was archived by the owner on Dec 7, 2018. It is now read-only.
This repository was archived by the owner on Dec 7, 2018. It is now read-only.

Instantiating Redis from inside a Celluloid::IO actor causes missing constructor error #10

Description

@orospakr

I think the name "Redis" may be overridden in the local scope.

Example code:

#!/usr/bin/env ruby

require "redis"
require "celluloid"
require "celluloid/io"
require 'celluloid/redis'

class MyActor
  # comment this out to prevent the error.
  include Celluloid::IO

  def initialize
    @redis = Redis.new(:driver => :celluloid) 

    puts "Success."
  end
end

ma = MyActor.new
sleep

Error produced:

$ bundle exec ./bin/redis_spike.rb
E, [2013-07-19T10:49:33.717153 #26935] ERROR -- : MyActor crashed!
NoMethodError: undefined method `new' for Celluloid::Redis:Module
        ./bin/redis_spike.rb:13:in `initialize'
        /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/calls.rb:25:in `public_send'
        /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/calls.rb:25:in `dispatch'
        /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/calls.rb:67:in `dispatch'
        /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/actor.rb:326:in `block in handle_message'
        /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/tasks.rb:42:in `block in initialize'
        /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/tasks/task_fiber.rb:11:in `block in create'
D, [2013-07-19T10:49:33.718139 #26935] DEBUG -- : Terminating 1 actors...
D, [2013-07-19T10:49:33.718526 #26935] DEBUG -- : Shutdown completed cleanly
./bin/redis_spike.rb:13:in `initialize': undefined method `new' for Celluloid::Redis:Module (NoMethodError)
        from /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/calls.rb:25:in `public_send'
        from /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/calls.rb:25:in `dispatch'
        from /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/calls.rb:67:in `dispatch'
        from /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/actor.rb:326:in `block in handle_message'
        from /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/tasks.rb:42:in `block in initialize'
        from /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/tasks/task_fiber.rb:11:in `block in create'
        from (celluloid):0:in `remote procedure call'
        from /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/calls.rb:95:in `value'
        from /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/proxies/sync_proxy.rb:28:in `method_missing'
        from /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/legacy.rb:14:in `method_missing'
        from /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid/proxies/actor_proxy.rb:25:in `_send_'
        from /home/orospakr/.gem/ruby/2.0.0/gems/celluloid-0.14.1/lib/celluloid.rb:129:in `new'
        from ./bin/redis_spike.rb:19:in `<main>'

Commenting out include Celluloid::IO prevents the error.

Is it unreasonable for me to want to use Celluloid::Redis from inside a Celluloid::IO actor? I would have thought that a Celluloid::IO Actor is just the right place to use Celluloid::Redis from, since it needs the IO reactor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions