engineyard-serverside 2.0.4 → 2.0.5.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/engineyard-serverside.rb +2 -1
- data/lib/engineyard-serverside/about.rb +37 -0
- data/lib/engineyard-serverside/cli.rb +2 -49
- data/lib/engineyard-serverside/configuration.rb +1 -0
- data/lib/engineyard-serverside/deploy.rb +5 -8
- data/lib/engineyard-serverside/propagator.rb +75 -0
- data/lib/engineyard-serverside/server.rb +3 -2
- data/lib/engineyard-serverside/servers.rb +28 -14
- data/lib/engineyard-serverside/shell.rb +6 -6
- data/lib/engineyard-serverside/shell/command_result.rb +1 -1
- data/lib/engineyard-serverside/strategies/git.rb +9 -4
- data/lib/engineyard-serverside/version.rb +1 -1
- data/spec/propagator_spec.rb +95 -0
- data/spec/spec_helper.rb +1 -1
- metadata +47 -68
- data/lib/engineyard-serverside/future.rb +0 -35
- data/lib/engineyard-serverside/futures/celluloid.rb +0 -15
- data/lib/engineyard-serverside/futures/dataflow.rb +0 -26
- data/lib/vendor/celluloid/lib/celluloid.rb +0 -261
- data/lib/vendor/celluloid/lib/celluloid/actor.rb +0 -242
- data/lib/vendor/celluloid/lib/celluloid/actor_pool.rb +0 -54
- data/lib/vendor/celluloid/lib/celluloid/actor_proxy.rb +0 -75
- data/lib/vendor/celluloid/lib/celluloid/application.rb +0 -78
- data/lib/vendor/celluloid/lib/celluloid/calls.rb +0 -93
- data/lib/vendor/celluloid/lib/celluloid/core_ext.rb +0 -14
- data/lib/vendor/celluloid/lib/celluloid/events.rb +0 -14
- data/lib/vendor/celluloid/lib/celluloid/fiber.rb +0 -33
- data/lib/vendor/celluloid/lib/celluloid/fsm.rb +0 -141
- data/lib/vendor/celluloid/lib/celluloid/future.rb +0 -60
- data/lib/vendor/celluloid/lib/celluloid/links.rb +0 -61
- data/lib/vendor/celluloid/lib/celluloid/logger.rb +0 -32
- data/lib/vendor/celluloid/lib/celluloid/mailbox.rb +0 -124
- data/lib/vendor/celluloid/lib/celluloid/receivers.rb +0 -66
- data/lib/vendor/celluloid/lib/celluloid/registry.rb +0 -33
- data/lib/vendor/celluloid/lib/celluloid/responses.rb +0 -26
- data/lib/vendor/celluloid/lib/celluloid/rspec.rb +0 -2
- data/lib/vendor/celluloid/lib/celluloid/signals.rb +0 -50
- data/lib/vendor/celluloid/lib/celluloid/supervisor.rb +0 -57
- data/lib/vendor/celluloid/lib/celluloid/task.rb +0 -73
- data/lib/vendor/celluloid/lib/celluloid/tcp_server.rb +0 -33
- data/lib/vendor/celluloid/lib/celluloid/timers.rb +0 -109
- data/lib/vendor/celluloid/lib/celluloid/version.rb +0 -4
- data/lib/vendor/dataflow/HISTORY +0 -52
- data/lib/vendor/dataflow/LICENSE +0 -19
- data/lib/vendor/dataflow/README.textile +0 -290
- data/lib/vendor/dataflow/Rakefile +0 -36
- data/lib/vendor/dataflow/dataflow.rb +0 -124
- data/lib/vendor/dataflow/dataflow/actor.rb +0 -22
- data/lib/vendor/dataflow/dataflow/equality.rb +0 -44
- data/lib/vendor/dataflow/dataflow/future_queue.rb +0 -24
- data/lib/vendor/dataflow/dataflow/port.rb +0 -54
- data/lib/vendor/dataflow/examples/barrier.rb +0 -9
- data/lib/vendor/dataflow/examples/data_driven.rb +0 -17
- data/lib/vendor/dataflow/examples/dataflow_http_gets.rb +0 -13
- data/lib/vendor/dataflow/examples/flow.rb +0 -20
- data/lib/vendor/dataflow/examples/future_http_gets.rb +0 -12
- data/lib/vendor/dataflow/examples/future_queue.rb +0 -11
- data/lib/vendor/dataflow/examples/instance_variables.rb +0 -15
- data/lib/vendor/dataflow/examples/laziness.rb +0 -9
- data/lib/vendor/dataflow/examples/local_variables.rb +0 -11
- data/lib/vendor/dataflow/examples/messages.rb +0 -26
- data/lib/vendor/dataflow/examples/port_http_gets.rb +0 -13
- data/lib/vendor/dataflow/examples/port_send.rb +0 -10
- data/lib/vendor/dataflow/examples/ring.rb +0 -21
- data/lib/vendor/dataflow/spec/actor_spec.rb +0 -28
- data/lib/vendor/dataflow/spec/anonymous_variables_spec.rb +0 -21
- data/lib/vendor/dataflow/spec/barrier_spec.rb +0 -25
- data/lib/vendor/dataflow/spec/by_need_spec.rb +0 -55
- data/lib/vendor/dataflow/spec/dataflow_spec.rb +0 -151
- data/lib/vendor/dataflow/spec/equality_spec.rb +0 -40
- data/lib/vendor/dataflow/spec/flow_spec.rb +0 -25
- data/lib/vendor/dataflow/spec/forker_spec.rb +0 -28
- data/lib/vendor/dataflow/spec/future_queue_spec.rb +0 -31
- data/lib/vendor/dataflow/spec/inspect_spec.rb +0 -19
- data/lib/vendor/dataflow/spec/need_later_spec.rb +0 -12
- data/lib/vendor/dataflow/spec/port_spec.rb +0 -26
- data/lib/vendor/dataflow/spec/spec.opts +0 -1
- data/lib/vendor/dataflow/spec/spec_helper.rb +0 -10
data/spec/spec_helper.rb
CHANGED
@@ -117,7 +117,7 @@ Spec::Runner.configure do |config|
|
|
117
117
|
|
118
118
|
# set up EY::Serverside::Server like we're on a solo
|
119
119
|
def test_servers
|
120
|
-
EY::Serverside::Servers.from_hashes([{:hostname => 'localhost', :roles => %w[solo]}])
|
120
|
+
EY::Serverside::Servers.from_hashes([{:hostname => 'localhost', :roles => %w[solo], :user => ENV['USER']}])
|
121
121
|
end
|
122
122
|
|
123
123
|
# When a repo fixture name is specified, the files found in the specified
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engineyard-serverside
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 1113733578
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
|
9
|
+
- 5
|
10
|
+
- pre
|
11
|
+
version: 2.0.5.pre
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- EY Cloud Team
|
@@ -15,7 +16,7 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date:
|
19
|
+
date: 2013-02-07 00:00:00 Z
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -46,6 +47,13 @@ dependencies:
|
|
46
47
|
- 2
|
47
48
|
- 2
|
48
49
|
version: 0.9.2.2
|
50
|
+
- - <
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
hash: 35
|
53
|
+
segments:
|
54
|
+
- 10
|
55
|
+
- 0
|
56
|
+
version: "10.0"
|
49
57
|
prerelease: false
|
50
58
|
type: :development
|
51
59
|
name: rake
|
@@ -108,6 +116,36 @@ dependencies:
|
|
108
116
|
type: :development
|
109
117
|
name: engineyard-cloud-client
|
110
118
|
requirement: *id006
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
hash: 3
|
126
|
+
segments:
|
127
|
+
- 0
|
128
|
+
version: "0"
|
129
|
+
prerelease: false
|
130
|
+
type: :development
|
131
|
+
name: sqlite3
|
132
|
+
requirement: *id007
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - "="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
hash: 47
|
140
|
+
segments:
|
141
|
+
- 0
|
142
|
+
- 13
|
143
|
+
- 2
|
144
|
+
version: 0.13.2
|
145
|
+
prerelease: false
|
146
|
+
type: :development
|
147
|
+
name: pg
|
148
|
+
requirement: *id008
|
111
149
|
description:
|
112
150
|
email: cloud@engineyard.com
|
113
151
|
executables:
|
@@ -118,6 +156,7 @@ extra_rdoc_files: []
|
|
118
156
|
|
119
157
|
files:
|
120
158
|
- bin/engineyard-serverside
|
159
|
+
- lib/engineyard-serverside/about.rb
|
121
160
|
- lib/engineyard-serverside/cli.rb
|
122
161
|
- lib/engineyard-serverside/cli_helpers.rb
|
123
162
|
- lib/engineyard-serverside/configuration.rb
|
@@ -125,12 +164,10 @@ files:
|
|
125
164
|
- lib/engineyard-serverside/deploy.rb
|
126
165
|
- lib/engineyard-serverside/deploy_hook.rb
|
127
166
|
- lib/engineyard-serverside/deprecation.rb
|
128
|
-
- lib/engineyard-serverside/future.rb
|
129
|
-
- lib/engineyard-serverside/futures/celluloid.rb
|
130
|
-
- lib/engineyard-serverside/futures/dataflow.rb
|
131
167
|
- lib/engineyard-serverside/lockfile_parser.rb
|
132
168
|
- lib/engineyard-serverside/maintenance.rb
|
133
169
|
- lib/engineyard-serverside/paths.rb
|
170
|
+
- lib/engineyard-serverside/propagator.rb
|
134
171
|
- lib/engineyard-serverside/rails_asset_support.rb
|
135
172
|
- lib/engineyard-serverside/server.rb
|
136
173
|
- lib/engineyard-serverside/servers.rb
|
@@ -143,66 +180,6 @@ files:
|
|
143
180
|
- lib/engineyard-serverside/task.rb
|
144
181
|
- lib/engineyard-serverside/version.rb
|
145
182
|
- lib/engineyard-serverside.rb
|
146
|
-
- lib/vendor/celluloid/lib/celluloid/actor.rb
|
147
|
-
- lib/vendor/celluloid/lib/celluloid/actor_pool.rb
|
148
|
-
- lib/vendor/celluloid/lib/celluloid/actor_proxy.rb
|
149
|
-
- lib/vendor/celluloid/lib/celluloid/application.rb
|
150
|
-
- lib/vendor/celluloid/lib/celluloid/calls.rb
|
151
|
-
- lib/vendor/celluloid/lib/celluloid/core_ext.rb
|
152
|
-
- lib/vendor/celluloid/lib/celluloid/events.rb
|
153
|
-
- lib/vendor/celluloid/lib/celluloid/fiber.rb
|
154
|
-
- lib/vendor/celluloid/lib/celluloid/fsm.rb
|
155
|
-
- lib/vendor/celluloid/lib/celluloid/future.rb
|
156
|
-
- lib/vendor/celluloid/lib/celluloid/links.rb
|
157
|
-
- lib/vendor/celluloid/lib/celluloid/logger.rb
|
158
|
-
- lib/vendor/celluloid/lib/celluloid/mailbox.rb
|
159
|
-
- lib/vendor/celluloid/lib/celluloid/receivers.rb
|
160
|
-
- lib/vendor/celluloid/lib/celluloid/registry.rb
|
161
|
-
- lib/vendor/celluloid/lib/celluloid/responses.rb
|
162
|
-
- lib/vendor/celluloid/lib/celluloid/rspec.rb
|
163
|
-
- lib/vendor/celluloid/lib/celluloid/signals.rb
|
164
|
-
- lib/vendor/celluloid/lib/celluloid/supervisor.rb
|
165
|
-
- lib/vendor/celluloid/lib/celluloid/task.rb
|
166
|
-
- lib/vendor/celluloid/lib/celluloid/tcp_server.rb
|
167
|
-
- lib/vendor/celluloid/lib/celluloid/timers.rb
|
168
|
-
- lib/vendor/celluloid/lib/celluloid/version.rb
|
169
|
-
- lib/vendor/celluloid/lib/celluloid.rb
|
170
|
-
- lib/vendor/dataflow/dataflow/actor.rb
|
171
|
-
- lib/vendor/dataflow/dataflow/equality.rb
|
172
|
-
- lib/vendor/dataflow/dataflow/future_queue.rb
|
173
|
-
- lib/vendor/dataflow/dataflow/port.rb
|
174
|
-
- lib/vendor/dataflow/dataflow.rb
|
175
|
-
- lib/vendor/dataflow/examples/barrier.rb
|
176
|
-
- lib/vendor/dataflow/examples/data_driven.rb
|
177
|
-
- lib/vendor/dataflow/examples/dataflow_http_gets.rb
|
178
|
-
- lib/vendor/dataflow/examples/flow.rb
|
179
|
-
- lib/vendor/dataflow/examples/future_http_gets.rb
|
180
|
-
- lib/vendor/dataflow/examples/future_queue.rb
|
181
|
-
- lib/vendor/dataflow/examples/instance_variables.rb
|
182
|
-
- lib/vendor/dataflow/examples/laziness.rb
|
183
|
-
- lib/vendor/dataflow/examples/local_variables.rb
|
184
|
-
- lib/vendor/dataflow/examples/messages.rb
|
185
|
-
- lib/vendor/dataflow/examples/port_http_gets.rb
|
186
|
-
- lib/vendor/dataflow/examples/port_send.rb
|
187
|
-
- lib/vendor/dataflow/examples/ring.rb
|
188
|
-
- lib/vendor/dataflow/HISTORY
|
189
|
-
- lib/vendor/dataflow/LICENSE
|
190
|
-
- lib/vendor/dataflow/Rakefile
|
191
|
-
- lib/vendor/dataflow/README.textile
|
192
|
-
- lib/vendor/dataflow/spec/actor_spec.rb
|
193
|
-
- lib/vendor/dataflow/spec/anonymous_variables_spec.rb
|
194
|
-
- lib/vendor/dataflow/spec/barrier_spec.rb
|
195
|
-
- lib/vendor/dataflow/spec/by_need_spec.rb
|
196
|
-
- lib/vendor/dataflow/spec/dataflow_spec.rb
|
197
|
-
- lib/vendor/dataflow/spec/equality_spec.rb
|
198
|
-
- lib/vendor/dataflow/spec/flow_spec.rb
|
199
|
-
- lib/vendor/dataflow/spec/forker_spec.rb
|
200
|
-
- lib/vendor/dataflow/spec/future_queue_spec.rb
|
201
|
-
- lib/vendor/dataflow/spec/inspect_spec.rb
|
202
|
-
- lib/vendor/dataflow/spec/need_later_spec.rb
|
203
|
-
- lib/vendor/dataflow/spec/port_spec.rb
|
204
|
-
- lib/vendor/dataflow/spec/spec.opts
|
205
|
-
- lib/vendor/dataflow/spec/spec_helper.rb
|
206
183
|
- lib/vendor/escape/doc_include/template/qualitysmith.rb
|
207
184
|
- lib/vendor/escape/lib/escape.rb
|
208
185
|
- lib/vendor/escape/Readme
|
@@ -471,6 +448,7 @@ files:
|
|
471
448
|
- spec/git_strategy_spec.rb
|
472
449
|
- spec/lockfile_parser_spec.rb
|
473
450
|
- spec/nodejs_deploy_spec.rb
|
451
|
+
- spec/propagator_spec.rb
|
474
452
|
- spec/rails31_deploy_spec.rb
|
475
453
|
- spec/restart_spec.rb
|
476
454
|
- spec/rollback_spec.rb
|
@@ -626,6 +604,7 @@ test_files:
|
|
626
604
|
- spec/git_strategy_spec.rb
|
627
605
|
- spec/lockfile_parser_spec.rb
|
628
606
|
- spec/nodejs_deploy_spec.rb
|
607
|
+
- spec/propagator_spec.rb
|
629
608
|
- spec/rails31_deploy_spec.rb
|
630
609
|
- spec/restart_spec.rb
|
631
610
|
- spec/rollback_spec.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module EY
|
2
|
-
module Serverside
|
3
|
-
class Future
|
4
|
-
def self.map(blocks)
|
5
|
-
blocks.map { |block| new(&block) }
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.success?(futures)
|
9
|
-
futures.empty? || futures.all? {|f| f.success?}
|
10
|
-
end
|
11
|
-
|
12
|
-
def initialize(&block)
|
13
|
-
@block = block
|
14
|
-
end
|
15
|
-
|
16
|
-
def result
|
17
|
-
@result ||= call
|
18
|
-
end
|
19
|
-
|
20
|
-
def success?
|
21
|
-
result.success?
|
22
|
-
end
|
23
|
-
|
24
|
-
def error?
|
25
|
-
!success?
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
if defined?(Fiber)
|
30
|
-
require 'engineyard-serverside/futures/celluloid'
|
31
|
-
else
|
32
|
-
require 'engineyard-serverside/futures/dataflow'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module EY
|
2
|
-
module Serverside
|
3
|
-
$LOAD_PATH.unshift File.expand_path('../../vendor/celluloid/lib', File.dirname(__FILE__))
|
4
|
-
require 'celluloid'
|
5
|
-
class Future
|
6
|
-
def self.call(blocks)
|
7
|
-
map(blocks).each {|f| f.result }
|
8
|
-
end
|
9
|
-
|
10
|
-
def call
|
11
|
-
Celluloid::Future.new(&@block).call
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module EY
|
2
|
-
module Serverside
|
3
|
-
$LOAD_PATH.unshift File.expand_path('../../vendor/dataflow', File.dirname(__FILE__))
|
4
|
-
require 'dataflow'
|
5
|
-
|
6
|
-
class Future
|
7
|
-
extend Dataflow
|
8
|
-
|
9
|
-
def self.call(blocks)
|
10
|
-
futures = map(blocks)
|
11
|
-
|
12
|
-
# Dataflow needs to call `barrier` and `need_later` in the same object
|
13
|
-
need_laters = futures.map do |future|
|
14
|
-
need_later { future.result }
|
15
|
-
end
|
16
|
-
barrier(*need_laters)
|
17
|
-
|
18
|
-
futures
|
19
|
-
end
|
20
|
-
|
21
|
-
def call
|
22
|
-
@block.call
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,261 +0,0 @@
|
|
1
|
-
require 'logger'
|
2
|
-
require 'thread'
|
3
|
-
|
4
|
-
module Celluloid
|
5
|
-
@logger = Logger.new STDERR
|
6
|
-
|
7
|
-
class << self
|
8
|
-
attr_accessor :logger # Thread-safe logger class
|
9
|
-
|
10
|
-
def included(klass)
|
11
|
-
klass.send :extend, ClassMethods
|
12
|
-
end
|
13
|
-
|
14
|
-
# Are we currently inside of an actor?
|
15
|
-
def actor?
|
16
|
-
!!Thread.current[:actor]
|
17
|
-
end
|
18
|
-
|
19
|
-
# Obtain the currently running actor (if one exists)
|
20
|
-
def current_actor
|
21
|
-
actor = Thread.current[:actor]
|
22
|
-
raise NotActorError, "not in actor scope" unless actor
|
23
|
-
actor.proxy
|
24
|
-
end
|
25
|
-
alias_method :current, :current_actor
|
26
|
-
|
27
|
-
# Receive an asynchronous message
|
28
|
-
def receive(timeout = nil, &block)
|
29
|
-
actor = Thread.current[:actor]
|
30
|
-
if actor
|
31
|
-
actor.receive(timeout, &block)
|
32
|
-
else
|
33
|
-
Thread.mailbox.receive(timeout, &block)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# Sleep letting the actor continue processing messages
|
38
|
-
def sleep(interval)
|
39
|
-
actor = Thread.current[:actor]
|
40
|
-
if actor
|
41
|
-
actor.sleep(interval)
|
42
|
-
else
|
43
|
-
Kernel.sleep interval
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Obtain a hash of active tasks to their current activities
|
48
|
-
def tasks
|
49
|
-
actor = Thread.current[:actor]
|
50
|
-
raise NotActorError, "not in actor scope" unless actor
|
51
|
-
actor.tasks
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Class methods added to classes which include Celluloid
|
56
|
-
module ClassMethods
|
57
|
-
# Create a new actor
|
58
|
-
def new(*args, &block)
|
59
|
-
proxy = Actor.new(allocate).proxy
|
60
|
-
proxy.send(:initialize, *args, &block)
|
61
|
-
proxy
|
62
|
-
end
|
63
|
-
alias_method :spawn, :new
|
64
|
-
|
65
|
-
# Create a new actor and link to the current one
|
66
|
-
def new_link(*args, &block)
|
67
|
-
current_actor = Celluloid.current_actor
|
68
|
-
raise NotActorError, "can't link outside actor context" unless current_actor
|
69
|
-
|
70
|
-
proxy = Actor.new(allocate).proxy
|
71
|
-
current_actor.link proxy
|
72
|
-
proxy.send(:initialize, *args, &block)
|
73
|
-
proxy
|
74
|
-
end
|
75
|
-
alias_method :spawn_link, :new_link
|
76
|
-
|
77
|
-
# Create a supervisor which ensures an instance of an actor will restart
|
78
|
-
# an actor if it fails
|
79
|
-
def supervise(*args, &block)
|
80
|
-
Supervisor.supervise(self, *args, &block)
|
81
|
-
end
|
82
|
-
|
83
|
-
# Create a supervisor which ensures an instance of an actor will restart
|
84
|
-
# an actor if it fails, and keep the actor registered under a given name
|
85
|
-
def supervise_as(name, *args, &block)
|
86
|
-
Supervisor.supervise_as(name, self, *args, &block)
|
87
|
-
end
|
88
|
-
|
89
|
-
# Trap errors from actors we're linked to when they exit
|
90
|
-
def trap_exit(callback)
|
91
|
-
@exit_handler = callback.to_sym
|
92
|
-
end
|
93
|
-
|
94
|
-
# Obtain the exit handler for this actor
|
95
|
-
attr_reader :exit_handler
|
96
|
-
|
97
|
-
# Configure a custom mailbox factory
|
98
|
-
def use_mailbox(klass = nil, &block)
|
99
|
-
if block
|
100
|
-
define_method(:mailbox_factory, &block)
|
101
|
-
else
|
102
|
-
define_method(:mailbox_factory) { klass.new }
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
#
|
108
|
-
# Instance methods
|
109
|
-
#
|
110
|
-
|
111
|
-
# Is this actor alive?
|
112
|
-
def alive?
|
113
|
-
Thread.current[:actor].alive?
|
114
|
-
end
|
115
|
-
|
116
|
-
# Raise an exception in caller context, but stay running
|
117
|
-
def abort(cause)
|
118
|
-
raise AbortError.new(cause)
|
119
|
-
end
|
120
|
-
|
121
|
-
# Terminate this actor
|
122
|
-
def terminate
|
123
|
-
Thread.current[:actor].terminate
|
124
|
-
end
|
125
|
-
|
126
|
-
def inspect
|
127
|
-
str = "#<Celluloid::Actor(#{self.class}:0x#{object_id.to_s(16)})"
|
128
|
-
ivars = instance_variables.map do |ivar|
|
129
|
-
"#{ivar}=#{instance_variable_get(ivar).inspect}"
|
130
|
-
end
|
131
|
-
|
132
|
-
str << " " << ivars.join(' ') unless ivars.empty?
|
133
|
-
str << ">"
|
134
|
-
end
|
135
|
-
|
136
|
-
# Send a signal with the given name to all waiting methods
|
137
|
-
def signal(name, value = nil)
|
138
|
-
Thread.current[:actor].signal name, value
|
139
|
-
end
|
140
|
-
|
141
|
-
# Wait for the given signal
|
142
|
-
def wait(name)
|
143
|
-
Thread.current[:actor].wait name
|
144
|
-
end
|
145
|
-
|
146
|
-
# Obtain the current_actor
|
147
|
-
def current_actor
|
148
|
-
Celluloid.current_actor
|
149
|
-
end
|
150
|
-
|
151
|
-
# Obtain the running tasks for this actor
|
152
|
-
def tasks
|
153
|
-
Celluloid.tasks
|
154
|
-
end
|
155
|
-
|
156
|
-
# Obtain the Ruby object the actor is wrapping. This should ONLY be used
|
157
|
-
# for a limited set of use cases like runtime metaprogramming. Interacting
|
158
|
-
# directly with the wrapped object foregoes any kind of thread safety that
|
159
|
-
# Celluloid would ordinarily provide you, and the object is guaranteed to
|
160
|
-
# be shared with at least the actor thread. Tread carefully.
|
161
|
-
def wrapped_object; self; end
|
162
|
-
|
163
|
-
# Obtain the Celluloid::Links for this actor
|
164
|
-
def links
|
165
|
-
Thread.current[:actor].links
|
166
|
-
end
|
167
|
-
|
168
|
-
# Link this actor to another, allowing it to crash or react to errors
|
169
|
-
def link(actor)
|
170
|
-
actor.notify_link current_actor
|
171
|
-
notify_link actor
|
172
|
-
end
|
173
|
-
|
174
|
-
# Remove links to another actor
|
175
|
-
def unlink(actor)
|
176
|
-
actor.notify_unlink current_actor
|
177
|
-
notify_unlink actor
|
178
|
-
end
|
179
|
-
|
180
|
-
def notify_link(actor)
|
181
|
-
links << actor
|
182
|
-
end
|
183
|
-
|
184
|
-
def notify_unlink(actor)
|
185
|
-
links.delete actor
|
186
|
-
end
|
187
|
-
|
188
|
-
# Is this actor linked to another?
|
189
|
-
def linked_to?(actor)
|
190
|
-
Thread.current[:actor].links.include? actor
|
191
|
-
end
|
192
|
-
|
193
|
-
# Receive an asynchronous message via the actor protocol
|
194
|
-
def receive(timeout = nil, &block)
|
195
|
-
Celluloid.receive(timeout, &block)
|
196
|
-
end
|
197
|
-
|
198
|
-
# Sleep while letting the actor continue to receive messages
|
199
|
-
def sleep(interval)
|
200
|
-
Celluloid.sleep(interval)
|
201
|
-
end
|
202
|
-
|
203
|
-
# Call a block after a given interval
|
204
|
-
def after(interval, &block)
|
205
|
-
Thread.current[:actor].after(interval, &block)
|
206
|
-
end
|
207
|
-
|
208
|
-
# Perform a blocking or computationally intensive action inside an
|
209
|
-
# asynchronous thread pool, allowing the caller to continue processing other
|
210
|
-
# messages in its mailbox in the meantime
|
211
|
-
def async(&block)
|
212
|
-
# This implementation relies on the present implementation of
|
213
|
-
# Celluloid::Future, which uses an Actor to run the block
|
214
|
-
Future.new(&block).value
|
215
|
-
end
|
216
|
-
|
217
|
-
# Process async calls via method_missing
|
218
|
-
def method_missing(meth, *args, &block)
|
219
|
-
# bang methods are async calls
|
220
|
-
if meth.to_s.match(/!$/)
|
221
|
-
unbanged_meth = meth.to_s.sub(/!$/, '')
|
222
|
-
call = AsyncCall.new(@mailbox, unbanged_meth, args, block)
|
223
|
-
|
224
|
-
begin
|
225
|
-
Thread.current[:actor].mailbox << call
|
226
|
-
rescue MailboxError
|
227
|
-
# Silently swallow asynchronous calls to dead actors. There's no way
|
228
|
-
# to reliably generate DeadActorErrors for async calls, so users of
|
229
|
-
# async calls should find other ways to deal with actors dying
|
230
|
-
# during an async call (i.e. linking/supervisors)
|
231
|
-
end
|
232
|
-
|
233
|
-
return # casts are async and return immediately
|
234
|
-
end
|
235
|
-
|
236
|
-
super
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
require 'celluloid/version'
|
241
|
-
require 'celluloid/actor_proxy'
|
242
|
-
require 'celluloid/calls'
|
243
|
-
require 'celluloid/core_ext'
|
244
|
-
require 'celluloid/events'
|
245
|
-
require 'celluloid/fiber'
|
246
|
-
require 'celluloid/fsm'
|
247
|
-
require 'celluloid/links'
|
248
|
-
require 'celluloid/logger'
|
249
|
-
require 'celluloid/mailbox'
|
250
|
-
require 'celluloid/receivers'
|
251
|
-
require 'celluloid/registry'
|
252
|
-
require 'celluloid/responses'
|
253
|
-
require 'celluloid/signals'
|
254
|
-
require 'celluloid/task'
|
255
|
-
require 'celluloid/timers'
|
256
|
-
|
257
|
-
require 'celluloid/actor'
|
258
|
-
require 'celluloid/actor_pool'
|
259
|
-
require 'celluloid/supervisor'
|
260
|
-
require 'celluloid/future'
|
261
|
-
require 'celluloid/application'
|