Class: Celluloid::SyncCall

Inherits:
Call show all
Defined in:
lib/vendor/celluloid/lib/celluloid/calls.rb

Overview

Synchronous calls wait for a response

Instance Attribute Summary

Attributes inherited from Call

#arguments, #block, #caller, #id, #method

Instance Method Summary collapse

Methods inherited from Call

#check_signature, #initialize

Constructor Details

This class inherits a constructor from Celluloid::Call

Instance Method Details

#cleanupObject



60
61
62
63
# File 'lib/vendor/celluloid/lib/celluloid/calls.rb', line 60

def cleanup
  exception = DeadActorError.new("attempted to call a dead actor")
  respond ErrorResponse.new(@id, exception)
end

#dispatch(obj) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/vendor/celluloid/lib/celluloid/calls.rb', line 32

def dispatch(obj)
  begin
    check_signature(obj)
  rescue Exception => ex
    respond ErrorResponse.new(@id, AbortError.new(ex))
    return
  end

  begin
    result = obj.send @method, *@arguments, &@block
  rescue Exception => exception
    # Exceptions that occur during synchronous calls are reraised in the
    # context of the caller
    respond ErrorResponse.new(@id, exception)

    if exception.is_a? AbortError
      # Aborting indicates a protocol error on the part of the caller
      # It should crash the caller, but the exception isn't reraised
      return
    else
      # Otherwise, it's a bug in this actor and should be reraised
      raise exception
    end
  end

  respond SuccessResponse.new(@id, result)
end