ntl-actor 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/actor.rb +2 -1
- data/lib/actor/actor.rb +6 -6
- data/lib/actor/system_message.rb +23 -0
- data/lib/actor/test_fixtures/sample_actor_status.rb +1 -1
- metadata +2 -2
- data/lib/actor/messaging/system_message.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2b5f7cf07905fa84e2e93b37a742242ac7c2982
|
4
|
+
data.tar.gz: dcd77334376788d56811794cefc073a1061ae456
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e56e7002e0373277cb7b97806c51e3fe3ae03799434da4cc075b1131bf9ac08dca6f0d5bae65c1b0f9d282df1ac37d32e0a96f5735aa4db786572faf6ee61c30
|
7
|
+
data.tar.gz: d01a30b07b5224b7a41fae562e35f90383cef8a17711ba97308ddba576d7d338a63a655d31371f2a7b01907934ea32f94b954ffef3a6e7a0d6ab06ef861754fc
|
data/lib/actor.rb
CHANGED
@@ -15,6 +15,7 @@ require 'actor/messaging/reader'
|
|
15
15
|
require 'actor/messaging/reader/substitute'
|
16
16
|
require 'actor/messaging/writer'
|
17
17
|
require 'actor/messaging/writer/substitute'
|
18
|
-
|
18
|
+
|
19
|
+
require 'actor/system_message'
|
19
20
|
|
20
21
|
require 'actor/actor'
|
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 SystemMessage::Pause then
|
29
29
|
self.actor_state = State::Paused
|
30
30
|
|
31
|
-
when
|
31
|
+
when SystemMessage::Resume then
|
32
32
|
self.actor_state = State::Running
|
33
33
|
|
34
|
-
when
|
34
|
+
when SystemMessage::Stop then
|
35
35
|
self.actor_state = State::Stopped
|
36
36
|
raise StopIteration
|
37
37
|
|
38
|
-
when
|
38
|
+
when SystemMessage::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? SystemMessage
|
59
59
|
handle_system_message message
|
60
60
|
end
|
61
61
|
end
|
@@ -118,7 +118,7 @@ module Actor
|
|
118
118
|
)
|
119
119
|
|
120
120
|
Messaging::Writer.write(
|
121
|
-
|
121
|
+
SystemMessage::Resume.new,
|
122
122
|
address
|
123
123
|
)
|
124
124
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Actor
|
2
|
+
module SystemMessage
|
3
|
+
Pause = Class.new { include SystemMessage }
|
4
|
+
Resume = Class.new { include SystemMessage }
|
5
|
+
Stop = Class.new { include SystemMessage }
|
6
|
+
|
7
|
+
class RecordStatus
|
8
|
+
include SystemMessage
|
9
|
+
|
10
|
+
attr_reader :reply_address
|
11
|
+
attr_reader :status
|
12
|
+
|
13
|
+
def initialize reply_address
|
14
|
+
@reply_address = reply_address
|
15
|
+
@status = Status.new
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Status < OpenStruct
|
20
|
+
include SystemMessage
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ntl-actor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Ladd
|
@@ -33,7 +33,6 @@ files:
|
|
33
33
|
- lib/actor/messaging/address.rb
|
34
34
|
- lib/actor/messaging/reader.rb
|
35
35
|
- lib/actor/messaging/reader/substitute.rb
|
36
|
-
- lib/actor/messaging/system_message.rb
|
37
36
|
- lib/actor/messaging/writer.rb
|
38
37
|
- lib/actor/messaging/writer/substitute.rb
|
39
38
|
- lib/actor/queue.rb
|
@@ -42,6 +41,7 @@ files:
|
|
42
41
|
- lib/actor/statistics.rb
|
43
42
|
- lib/actor/statistics/copy.rb
|
44
43
|
- lib/actor/statistics/timer.rb
|
44
|
+
- lib/actor/system_message.rb
|
45
45
|
- lib/actor/test_fixtures.rb
|
46
46
|
- lib/actor/test_fixtures/parallel_iteration.rb
|
47
47
|
- lib/actor/test_fixtures/sample_actor_status.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Actor
|
2
|
-
module Messaging
|
3
|
-
module SystemMessage
|
4
|
-
Pause = Class.new { include SystemMessage }
|
5
|
-
Resume = Class.new { include SystemMessage }
|
6
|
-
Stop = Class.new { include SystemMessage }
|
7
|
-
|
8
|
-
class RecordStatus
|
9
|
-
include SystemMessage
|
10
|
-
|
11
|
-
attr_reader :reply_address
|
12
|
-
attr_reader :status
|
13
|
-
|
14
|
-
def initialize reply_address
|
15
|
-
@reply_address = reply_address
|
16
|
-
@status = Status.new
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class Status < OpenStruct
|
21
|
-
include SystemMessage
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|