Module: Sidekiq::Actor

Included in:
Fetcher, Manager, Processor, Scheduled::Poller
Defined in:
lib/sidekiq/actor.rb

Overview

Celluloid has the nasty side effect of making objects very hard to test because they are immediately async upon creation. In testing we want to just treat the actors as POROs.

Instead of including Celluloid, we’ll just stub out the key methods we use so that everything works synchronously. The alternative is no test coverage.

Constant Summary collapse

TaskThread =
0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/sidekiq/actor.rb', line 51

def self.included(klass)
  class << klass
    alias_method :new_link, :new
    def trap_exit(meth)
    end
    def task_class(konstant)
    end
  end
end

Instance Method Details

#after(amount = 0) ⇒ Object



20
21
# File 'lib/sidekiq/actor.rb', line 20

def after(amount=0)
end

#alive?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/sidekiq/actor.rb', line 31

def alive?
  !@dead
end

#asyncObject



39
40
41
# File 'lib/sidekiq/actor.rb', line 39

def async
  self
end

#current_actorObject



27
28
29
# File 'lib/sidekiq/actor.rb', line 27

def current_actor
  self
end

#deferObject



23
24
25
# File 'lib/sidekiq/actor.rb', line 23

def defer
  yield
end

#signal(sym) ⇒ Object



43
44
# File 'lib/sidekiq/actor.rb', line 43

def signal(sym)
end

#sleep(amount = 0) ⇒ Object



17
18
# File 'lib/sidekiq/actor.rb', line 17

def sleep(amount=0)
end

#terminateObject



35
36
37
# File 'lib/sidekiq/actor.rb', line 35

def terminate
  @dead = true
end

#watchdog(msg) ⇒ Object

we don’t want to hide or catch failures in testing



47
48
49
# File 'lib/sidekiq/actor.rb', line 47

def watchdog(msg)
  yield
end