ntl-actor 1.0.1 → 1.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 +5 -3
- data/lib/actor/messaging/address/controls.rb +1 -1
- data/lib/actor/messaging/publish.rb +3 -3
- data/lib/actor/messaging/{write.rb → send.rb} +1 -1
- data/lib/actor/messaging/send/dependency.rb +13 -0
- data/lib/actor/messaging/{write → send}/substitute.rb +2 -2
- data/lib/actor/module/dependencies.rb +2 -2
- data/lib/actor/module/dependencies/assertions.rb +3 -3
- data/lib/actor/module/handler.rb +1 -1
- data/lib/actor/module/suspend_resume.rb +1 -1
- data/lib/actor/start.rb +6 -6
- data/lib/actor/supervisor.rb +11 -0
- data/lib/actor/supervisor/observer.rb +15 -0
- metadata +6 -5
- data/lib/actor/messaging/write/dependency.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34237e060f184d1c210821d69dd254831d659e8a
|
4
|
+
data.tar.gz: 4c7b69ea47f9697489b6532dbbc1685a08d5696e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 894647ffcc52aa656d4f91054ef2bfe175fafd45d9e9ffa54504624c1f87f51e3fa84131efb2e689a573e4364a031d224332b62b76c275bc5f57625da3e64043
|
7
|
+
data.tar.gz: 804cbe31ba1d237e699a90cb6291281daebaca721c1395ba8389aafdb85e721fa6f8652e1e7ae55bdac0582d491babf335cd09b38098a698d4c346118a22929f
|
data/lib/actor.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'observer'
|
1
2
|
require 'securerandom'
|
2
3
|
require 'set'
|
3
4
|
|
@@ -19,9 +20,9 @@ require 'actor/messaging/read/assertions'
|
|
19
20
|
require 'actor/messaging/read/dependency'
|
20
21
|
require 'actor/messaging/read/substitute'
|
21
22
|
|
22
|
-
require 'actor/messaging/
|
23
|
-
require 'actor/messaging/
|
24
|
-
require 'actor/messaging/
|
23
|
+
require 'actor/messaging/send'
|
24
|
+
require 'actor/messaging/send/dependency'
|
25
|
+
require 'actor/messaging/send/substitute'
|
25
26
|
|
26
27
|
require 'actor/messaging/publish'
|
27
28
|
require 'actor/messaging/publish/assertions'
|
@@ -54,5 +55,6 @@ require 'actor/supervisor/address/get'
|
|
54
55
|
require 'actor/supervisor/address/put'
|
55
56
|
require 'actor/supervisor/address/registry'
|
56
57
|
require 'actor/supervisor/assertions'
|
58
|
+
require 'actor/supervisor/observer'
|
57
59
|
|
58
60
|
require 'actor/actor'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Actor
|
2
2
|
module Messaging
|
3
3
|
class Publish
|
4
|
-
include
|
4
|
+
include Send::Dependency
|
5
5
|
|
6
6
|
attr_reader :addresses
|
7
7
|
|
@@ -16,7 +16,7 @@ module Actor
|
|
16
16
|
instance.register address
|
17
17
|
end
|
18
18
|
|
19
|
-
instance.
|
19
|
+
instance.send = Send.new
|
20
20
|
|
21
21
|
instance
|
22
22
|
end
|
@@ -31,7 +31,7 @@ module Actor
|
|
31
31
|
|
32
32
|
def call message, wait: nil
|
33
33
|
addresses.each do |address|
|
34
|
-
|
34
|
+
send.(message, address, wait: wait)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Actor
|
2
2
|
module Messaging
|
3
|
-
class
|
3
|
+
class Send
|
4
4
|
class Substitute
|
5
5
|
attr_reader :records
|
6
6
|
|
@@ -27,7 +27,7 @@ module Actor
|
|
27
27
|
end
|
28
28
|
|
29
29
|
module Assertions
|
30
|
-
def
|
30
|
+
def sent? message=nil, address: nil, wait: nil
|
31
31
|
records.each do |record|
|
32
32
|
next unless message.nil? or record.message? message
|
33
33
|
next unless address.nil? or record.address == address
|
@@ -5,7 +5,7 @@ module Actor
|
|
5
5
|
receiver.class_exec do
|
6
6
|
include Messaging::Address::Dependency
|
7
7
|
include Messaging::Read::Dependency
|
8
|
-
include Messaging::
|
8
|
+
include Messaging::Send::Dependency
|
9
9
|
|
10
10
|
prepend Configure
|
11
11
|
|
@@ -20,7 +20,7 @@ module Actor
|
|
20
20
|
def configure
|
21
21
|
self.address = Messaging::Address.build
|
22
22
|
self.read = Messaging::Read.build address
|
23
|
-
self.
|
23
|
+
self.send = Messaging::Send.new
|
24
24
|
|
25
25
|
super
|
26
26
|
end
|
@@ -3,7 +3,7 @@ module Actor
|
|
3
3
|
module Dependencies
|
4
4
|
module Assertions
|
5
5
|
def dependencies_configured?
|
6
|
-
address_configured? and reader_configured? and
|
6
|
+
address_configured? and reader_configured? and send_configured?
|
7
7
|
end
|
8
8
|
|
9
9
|
def address_configured?
|
@@ -14,8 +14,8 @@ module Actor
|
|
14
14
|
read.instance_of? Messaging::Read
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
|
17
|
+
def send_configured?
|
18
|
+
send.instance_of? Messaging::Send
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/lib/actor/module/handler.rb
CHANGED
data/lib/actor/start.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Actor
|
2
2
|
class Start
|
3
|
-
include Messaging::
|
3
|
+
include Messaging::Send::Dependency
|
4
4
|
|
5
5
|
attr_reader :actor
|
6
6
|
attr_accessor :supervisor_address
|
@@ -13,13 +13,13 @@ module Actor
|
|
13
13
|
actor = Build.(actor_class, *arguments, &block)
|
14
14
|
|
15
15
|
instance = new actor
|
16
|
-
instance.
|
16
|
+
instance.send = Messaging::Send.new
|
17
17
|
instance.supervisor_address = Supervisor::Address::Get.()
|
18
18
|
instance.()
|
19
19
|
end
|
20
20
|
|
21
21
|
def call
|
22
|
-
|
22
|
+
send.(Messages::Start, address)
|
23
23
|
|
24
24
|
thread = Thread.new do
|
25
25
|
actor_started
|
@@ -37,17 +37,17 @@ module Actor
|
|
37
37
|
|
38
38
|
def actor_crashed error
|
39
39
|
actor_crashed = Messages::ActorCrashed.new error
|
40
|
-
|
40
|
+
send.(actor_crashed, supervisor_address)
|
41
41
|
end
|
42
42
|
|
43
43
|
def actor_started
|
44
44
|
actor_started = Messages::ActorStarted.new address
|
45
|
-
|
45
|
+
send.(actor_started, supervisor_address)
|
46
46
|
end
|
47
47
|
|
48
48
|
def actor_stopped
|
49
49
|
actor_stopped = Messages::ActorStopped.new address
|
50
|
-
|
50
|
+
send.(actor_stopped, supervisor_address)
|
51
51
|
end
|
52
52
|
|
53
53
|
def address
|
data/lib/actor/supervisor.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Actor
|
2
2
|
class Supervisor
|
3
|
+
include Observable
|
4
|
+
|
3
5
|
include Module::Dependencies
|
4
6
|
include Module::Handler
|
5
7
|
include Module::RunLoop
|
@@ -49,6 +51,15 @@ module Actor
|
|
49
51
|
self.publish = Messaging::Publish.build
|
50
52
|
end
|
51
53
|
|
54
|
+
def handle message
|
55
|
+
result = super
|
56
|
+
|
57
|
+
changed
|
58
|
+
notify_observers message
|
59
|
+
|
60
|
+
result
|
61
|
+
end
|
62
|
+
|
52
63
|
handle Messages::ActorStarted do |message|
|
53
64
|
publish.register message.address
|
54
65
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ntl-actor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Ladd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Implementation of actor pattern for ruby
|
14
14
|
email: nathanladd+github@gmail.com
|
@@ -38,9 +38,9 @@ files:
|
|
38
38
|
- lib/actor/messaging/read/assertions.rb
|
39
39
|
- lib/actor/messaging/read/dependency.rb
|
40
40
|
- lib/actor/messaging/read/substitute.rb
|
41
|
-
- lib/actor/messaging/
|
42
|
-
- lib/actor/messaging/
|
43
|
-
- lib/actor/messaging/
|
41
|
+
- lib/actor/messaging/send.rb
|
42
|
+
- lib/actor/messaging/send/dependency.rb
|
43
|
+
- lib/actor/messaging/send/substitute.rb
|
44
44
|
- lib/actor/module/dependencies.rb
|
45
45
|
- lib/actor/module/dependencies/assertions.rb
|
46
46
|
- lib/actor/module/handler.rb
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- lib/actor/supervisor/address/put.rb
|
62
62
|
- lib/actor/supervisor/address/registry.rb
|
63
63
|
- lib/actor/supervisor/assertions.rb
|
64
|
+
- lib/actor/supervisor/observer.rb
|
64
65
|
homepage: https://github.com/ntl/actor
|
65
66
|
licenses:
|
66
67
|
- MIT
|