ntl-actor 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/actor.rb +1 -1
- data/lib/actor/actor.rb +14 -7
- data/lib/actor/{system_message.rb → message.rb} +6 -6
- data/lib/actor/test_fixtures/sample_actor_status.rb +1 -1
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5907994a5235c2caf3525edae99d5fe13c3cd646
|
4
|
+
data.tar.gz: 685249f008ab826d94f1740a7045ff91735f1b52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 047c45295560373e9354b846f054e7f38a6f030cfe6a03555faee89b1697c52ac83d452e394707f6c809c623fa6489319cb5bb27035f4ee95b4689664e7ea42c
|
7
|
+
data.tar.gz: a8fd3d31faf03d9db947ed8ec94aded72416c3e13f78eb3cd47025bcfb0eaa67eb030e7b03e5d4ad18332d9fce02e0912d72fc470af19bbb8275614894a65bc3
|
data/lib/actor.rb
CHANGED
data/lib/actor/actor.rb
CHANGED
@@ -25,17 +25,17 @@ module Actor
|
|
25
25
|
|
26
26
|
def handle_system_message message
|
27
27
|
case message
|
28
|
-
when
|
28
|
+
when Message::Pause then
|
29
29
|
self.actor_state = State::Paused
|
30
30
|
|
31
|
-
when
|
31
|
+
when Message::Resume then
|
32
32
|
self.actor_state = State::Running
|
33
33
|
|
34
|
-
when
|
35
|
-
self.actor_state = State::
|
34
|
+
when Message::Stop then
|
35
|
+
self.actor_state = State::Running
|
36
36
|
raise StopIteration
|
37
37
|
|
38
|
-
when
|
38
|
+
when Message::RecordStatus then
|
39
39
|
status = message.status
|
40
40
|
|
41
41
|
Statistics::Copy.(status, actor_statistics)
|
@@ -55,7 +55,7 @@ module Actor
|
|
55
55
|
while message = reader.read(wait: actor_state == State::Paused)
|
56
56
|
handle message
|
57
57
|
|
58
|
-
if message.is_a?
|
58
|
+
if message.is_a? Message
|
59
59
|
handle_system_message message
|
60
60
|
end
|
61
61
|
end
|
@@ -64,6 +64,12 @@ module Actor
|
|
64
64
|
|
65
65
|
Thread.pass
|
66
66
|
end
|
67
|
+
|
68
|
+
self.actor_state = State::Stopped
|
69
|
+
|
70
|
+
rescue => error
|
71
|
+
self.actor_state = State::Crashed
|
72
|
+
raise error
|
67
73
|
end
|
68
74
|
|
69
75
|
module Destructure
|
@@ -118,7 +124,7 @@ module Actor
|
|
118
124
|
)
|
119
125
|
|
120
126
|
Messaging::Writer.write(
|
121
|
-
|
127
|
+
Message::Resume.new,
|
122
128
|
address
|
123
129
|
)
|
124
130
|
|
@@ -127,6 +133,7 @@ module Actor
|
|
127
133
|
end
|
128
134
|
|
129
135
|
module State
|
136
|
+
Crashed = :crashed
|
130
137
|
Paused = :paused
|
131
138
|
Running = :running
|
132
139
|
Stopped = :stopped
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Actor
|
2
|
-
module
|
3
|
-
Pause = Class.new { include
|
4
|
-
Resume = Class.new { include
|
5
|
-
Stop = Class.new { include
|
2
|
+
module Message
|
3
|
+
Pause = Class.new { include Message }
|
4
|
+
Resume = Class.new { include Message }
|
5
|
+
Stop = Class.new { include Message }
|
6
6
|
|
7
7
|
class RecordStatus
|
8
|
-
include
|
8
|
+
include Message
|
9
9
|
|
10
10
|
attr_reader :reply_address
|
11
11
|
attr_reader :status
|
@@ -17,7 +17,7 @@ module Actor
|
|
17
17
|
end
|
18
18
|
|
19
19
|
class Status < OpenStruct
|
20
|
-
include
|
20
|
+
include Message
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ntl-actor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Ladd
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2016-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Implementation of actor pattern for ruby designed for simplicity and
|
14
|
-
frugality
|
13
|
+
description: Implementation of actor pattern for ruby designed for simplicity and frugality
|
15
14
|
email: nathanladd+github@gmail.com
|
16
15
|
executables: []
|
17
16
|
extensions: []
|
@@ -30,6 +29,7 @@ files:
|
|
30
29
|
- lib/actor/controls/statistics/timer.rb
|
31
30
|
- lib/actor/controls/time.rb
|
32
31
|
- lib/actor/controls/time/clock.rb
|
32
|
+
- lib/actor/message.rb
|
33
33
|
- lib/actor/messaging/address.rb
|
34
34
|
- lib/actor/messaging/reader.rb
|
35
35
|
- lib/actor/messaging/reader/substitute.rb
|
@@ -41,7 +41,6 @@ files:
|
|
41
41
|
- lib/actor/statistics.rb
|
42
42
|
- lib/actor/statistics/copy.rb
|
43
43
|
- lib/actor/statistics/timer.rb
|
44
|
-
- lib/actor/system_message.rb
|
45
44
|
- lib/actor/test_fixtures.rb
|
46
45
|
- lib/actor/test_fixtures/parallel_iteration.rb
|
47
46
|
- lib/actor/test_fixtures/sample_actor_status.rb
|
@@ -49,7 +48,7 @@ homepage: https://github.com/ntl/actor
|
|
49
48
|
licenses:
|
50
49
|
- MIT
|
51
50
|
metadata: {}
|
52
|
-
post_install_message:
|
51
|
+
post_install_message:
|
53
52
|
rdoc_options: []
|
54
53
|
require_paths:
|
55
54
|
- lib
|
@@ -64,9 +63,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
63
|
- !ruby/object:Gem::Version
|
65
64
|
version: '0'
|
66
65
|
requirements: []
|
67
|
-
rubyforge_project:
|
68
|
-
rubygems_version: 2.6.
|
69
|
-
signing_key:
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 2.6.4
|
68
|
+
signing_key:
|
70
69
|
specification_version: 4
|
71
70
|
summary: Implementation of actor pattern for ruby
|
72
71
|
test_files: []
|