ntl-actor 1.0.0.pre1 → 1.0.0.pre2
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 +13 -13
- data/lib/actor/controls.rb +1 -1
- data/lib/actor/messaging/{publisher.rb → publish.rb} +5 -5
- data/lib/actor/messaging/{publisher → publish}/assertions.rb +2 -2
- data/lib/actor/messaging/publish/dependency.rb +13 -0
- data/lib/actor/messaging/{publisher → publish}/substitute.rb +14 -10
- data/lib/actor/messaging/{reader.rb → read.rb} +3 -3
- data/lib/actor/messaging/{reader → read}/assertions.rb +2 -2
- data/lib/actor/messaging/read/dependency.rb +13 -0
- data/lib/actor/messaging/{reader → read}/substitute.rb +7 -7
- data/lib/actor/messaging/{writer.rb → write.rb} +3 -3
- data/lib/actor/messaging/write/dependency.rb +13 -0
- data/lib/actor/messaging/{writer → write}/substitute.rb +6 -4
- data/lib/actor/module/dependencies.rb +4 -4
- data/lib/actor/module/dependencies/assertions.rb +2 -2
- data/lib/actor/module/handler.rb +1 -1
- data/lib/actor/module/run_loop.rb +1 -1
- data/lib/actor/module/suspend_resume.rb +1 -1
- data/lib/actor/start.rb +6 -6
- data/lib/actor/supervisor.rb +7 -7
- data/lib/actor/supervisor/assertions.rb +4 -4
- metadata +12 -12
- data/lib/actor/messaging/publisher/dependency.rb +0 -13
- data/lib/actor/messaging/reader/dependency.rb +0 -13
- data/lib/actor/messaging/writer/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: 896e0c8cdd1845e3ad71c931366a1930e3a21acc
|
4
|
+
data.tar.gz: 38e01ef89b6417ac6c19e536f3a1b0c0101089e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e97f640579eb0444b6e65621151cfafa669c7656a18757d1ff09e5e521f482e0c2508196e35f6333053100eb5b126ccb0f567f4709a49fb7548ace41f3d1d62
|
7
|
+
data.tar.gz: 91a38416a0837219be3791f4162ba3e37aecfa5f1970252045ef89c850bcb939e5e0a5335fed156d2304b0d2f476e20e02587c55479436995b03b9ee6f56c892
|
data/lib/actor.rb
CHANGED
@@ -13,19 +13,19 @@ require 'actor/messaging/address/none'
|
|
13
13
|
require 'actor/messaging/message'
|
14
14
|
require 'actor/messaging/message/name'
|
15
15
|
|
16
|
-
require 'actor/messaging/
|
17
|
-
require 'actor/messaging/
|
18
|
-
require 'actor/messaging/
|
19
|
-
require 'actor/messaging/
|
20
|
-
|
21
|
-
require 'actor/messaging/
|
22
|
-
require 'actor/messaging/
|
23
|
-
require 'actor/messaging/
|
24
|
-
|
25
|
-
require 'actor/messaging/
|
26
|
-
require 'actor/messaging/
|
27
|
-
require 'actor/messaging/
|
28
|
-
require 'actor/messaging/
|
16
|
+
require 'actor/messaging/read'
|
17
|
+
require 'actor/messaging/read/assertions'
|
18
|
+
require 'actor/messaging/read/dependency'
|
19
|
+
require 'actor/messaging/read/substitute'
|
20
|
+
|
21
|
+
require 'actor/messaging/write'
|
22
|
+
require 'actor/messaging/write/dependency'
|
23
|
+
require 'actor/messaging/write/substitute'
|
24
|
+
|
25
|
+
require 'actor/messaging/publish'
|
26
|
+
require 'actor/messaging/publish/assertions'
|
27
|
+
require 'actor/messaging/publish/dependency'
|
28
|
+
require 'actor/messaging/publish/substitute'
|
29
29
|
|
30
30
|
require 'actor/messages'
|
31
31
|
|
data/lib/actor/controls.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Actor
|
2
2
|
module Messaging
|
3
|
-
class
|
4
|
-
include
|
3
|
+
class Publish
|
4
|
+
include Write::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.write = Write.new
|
20
20
|
|
21
21
|
instance
|
22
22
|
end
|
@@ -29,9 +29,9 @@ module Actor
|
|
29
29
|
addresses.delete address
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def call message, wait: nil
|
33
33
|
addresses.each do |address|
|
34
|
-
|
34
|
+
write.(message, address, wait: wait)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -1,7 +1,11 @@
|
|
1
1
|
module Actor
|
2
2
|
module Messaging
|
3
|
-
class
|
3
|
+
class Publish
|
4
4
|
class Substitute
|
5
|
+
attr_reader :records
|
6
|
+
attr_reader :registered_addresses
|
7
|
+
attr_reader :unregistered_addresses
|
8
|
+
|
5
9
|
def initialize
|
6
10
|
@registered_addresses = Set.new
|
7
11
|
@unregistered_addresses = Set.new
|
@@ -9,19 +13,19 @@ module Actor
|
|
9
13
|
end
|
10
14
|
|
11
15
|
def register address
|
12
|
-
|
16
|
+
registered_addresses << address
|
13
17
|
end
|
14
18
|
|
15
19
|
def unregister address
|
16
|
-
|
20
|
+
unregistered_addresses << address
|
17
21
|
end
|
18
22
|
|
19
|
-
def
|
23
|
+
def call message, wait: nil
|
20
24
|
wait = true if wait.nil?
|
21
25
|
|
22
26
|
record = Record.new message, wait
|
23
27
|
|
24
|
-
|
28
|
+
records << record
|
25
29
|
end
|
26
30
|
|
27
31
|
Record = Struct.new :message, :wait
|
@@ -29,22 +33,22 @@ module Actor
|
|
29
33
|
module Assertions
|
30
34
|
def registered? address=nil
|
31
35
|
if address.nil?
|
32
|
-
|
36
|
+
registered_addresses.any?
|
33
37
|
else
|
34
|
-
|
38
|
+
registered_addresses.include? address
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
38
42
|
def unregistered? address=nil
|
39
43
|
if address.nil?
|
40
|
-
|
44
|
+
unregistered_addresses.any?
|
41
45
|
else
|
42
|
-
|
46
|
+
unregistered_addresses.include? address
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
46
50
|
def published? message=nil, wait: nil
|
47
|
-
|
51
|
+
records.each do |record|
|
48
52
|
next unless message.nil? or record.message == message
|
49
53
|
next unless wait.nil? or record.wait == wait
|
50
54
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Actor
|
2
2
|
module Messaging
|
3
|
-
class
|
3
|
+
class Read
|
4
4
|
attr_reader :queue
|
5
5
|
|
6
6
|
def initialize queue
|
@@ -16,10 +16,10 @@ module Actor
|
|
16
16
|
def self.call address, wait: nil
|
17
17
|
instance = build address
|
18
18
|
|
19
|
-
instance.
|
19
|
+
instance.(wait: wait)
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def call wait: nil
|
23
23
|
non_block = wait == false
|
24
24
|
|
25
25
|
queue.deq non_block
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Actor
|
2
2
|
module Messaging
|
3
|
-
class
|
3
|
+
class Read
|
4
4
|
module Assertions
|
5
5
|
def address? address
|
6
6
|
queue? address.queue
|
@@ -17,7 +17,7 @@ module Actor
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def queue? queue
|
20
|
-
|
20
|
+
self.queue == queue
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Actor
|
2
2
|
module Messaging
|
3
|
-
class
|
4
|
-
class Substitute <
|
5
|
-
|
3
|
+
class Read
|
4
|
+
class Substitute < Read
|
5
|
+
attr_accessor :next_message
|
6
6
|
|
7
7
|
def self.build
|
8
8
|
queue = Queue::Substitute.new
|
@@ -12,17 +12,17 @@ module Actor
|
|
12
12
|
instance
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
if
|
15
|
+
def call wait: nil
|
16
|
+
if next_message.nil?
|
17
17
|
super
|
18
18
|
else
|
19
|
-
|
19
|
+
next_message
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
module Controls
|
24
24
|
def add message
|
25
|
-
|
25
|
+
self.next_message = message
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Actor
|
2
2
|
module Messaging
|
3
|
-
class
|
4
|
-
def
|
3
|
+
class Write
|
4
|
+
def call message, address, wait: nil
|
5
5
|
non_block = wait == false
|
6
6
|
|
7
7
|
queue = address.queue
|
@@ -21,7 +21,7 @@ module Actor
|
|
21
21
|
|
22
22
|
def self.call *arguments
|
23
23
|
instance = new
|
24
|
-
instance.
|
24
|
+
instance.(*arguments)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
module Actor
|
2
2
|
module Messaging
|
3
|
-
class
|
3
|
+
class Write
|
4
4
|
class Substitute
|
5
|
+
attr_reader :records
|
6
|
+
|
5
7
|
def initialize
|
6
8
|
@records = []
|
7
9
|
end
|
8
10
|
|
9
|
-
def
|
11
|
+
def call message, address, wait: nil
|
10
12
|
wait = true if wait.nil?
|
11
13
|
|
12
14
|
record = Record.new message, address, wait
|
13
15
|
|
14
|
-
|
16
|
+
records << record
|
15
17
|
end
|
16
18
|
|
17
19
|
Record = Struct.new :message, :address, :wait do
|
@@ -26,7 +28,7 @@ module Actor
|
|
26
28
|
|
27
29
|
module Assertions
|
28
30
|
def written? message=nil, address: nil, wait: nil
|
29
|
-
|
31
|
+
records.each do |record|
|
30
32
|
next unless message.nil? or record.message? message
|
31
33
|
next unless address.nil? or record.address == address
|
32
34
|
next unless wait.nil? or record.wait == wait
|
@@ -4,8 +4,8 @@ module Actor
|
|
4
4
|
def self.included receiver
|
5
5
|
receiver.class_exec do
|
6
6
|
include Messaging::Address::Dependency
|
7
|
-
include Messaging::
|
8
|
-
include Messaging::
|
7
|
+
include Messaging::Read::Dependency
|
8
|
+
include Messaging::Write::Dependency
|
9
9
|
|
10
10
|
prepend Configure
|
11
11
|
|
@@ -19,8 +19,8 @@ module Actor
|
|
19
19
|
module Configure
|
20
20
|
def configure
|
21
21
|
self.address = Messaging::Address.build
|
22
|
-
self.
|
23
|
-
self.
|
22
|
+
self.read = Messaging::Read.build address
|
23
|
+
self.write = Messaging::Write.new
|
24
24
|
|
25
25
|
super
|
26
26
|
end
|
@@ -11,11 +11,11 @@ module Actor
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def reader_configured?
|
14
|
-
|
14
|
+
read.instance_of? Messaging::Read
|
15
15
|
end
|
16
16
|
|
17
17
|
def writer_configured?
|
18
|
-
|
18
|
+
write.instance_of? Messaging::Write
|
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::Write::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.write = Messaging::Write.new
|
17
17
|
instance.supervisor_address = Supervisor::Address::Get.()
|
18
18
|
instance.()
|
19
19
|
end
|
20
20
|
|
21
21
|
def call
|
22
|
-
|
22
|
+
write.(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
|
+
write.(actor_crashed, supervisor_address)
|
41
41
|
end
|
42
42
|
|
43
43
|
def actor_started
|
44
44
|
actor_started = Messages::ActorStarted.new address
|
45
|
-
|
45
|
+
write.(actor_started, supervisor_address)
|
46
46
|
end
|
47
47
|
|
48
48
|
def actor_stopped
|
49
49
|
actor_stopped = Messages::ActorStopped.new address
|
50
|
-
|
50
|
+
write.(actor_stopped, supervisor_address)
|
51
51
|
end
|
52
52
|
|
53
53
|
def address
|
data/lib/actor/supervisor.rb
CHANGED
@@ -4,7 +4,7 @@ module Actor
|
|
4
4
|
include Module::Handler
|
5
5
|
include Module::RunLoop
|
6
6
|
|
7
|
-
include Messaging::
|
7
|
+
include Messaging::Publish::Dependency
|
8
8
|
|
9
9
|
attr_accessor :actor_count
|
10
10
|
attr_writer :assembly_block
|
@@ -49,17 +49,17 @@ module Actor
|
|
49
49
|
|
50
50
|
assembly_block.(self)
|
51
51
|
|
52
|
-
self.
|
52
|
+
self.publish = Messaging::Publish.build
|
53
53
|
end
|
54
54
|
|
55
55
|
handle Messages::ActorStarted do |message|
|
56
|
-
|
56
|
+
publish.register message.address
|
57
57
|
|
58
58
|
self.actor_count += 1
|
59
59
|
end
|
60
60
|
|
61
61
|
handle Messages::ActorStopped do |message|
|
62
|
-
|
62
|
+
publish.unregister message.address
|
63
63
|
|
64
64
|
self.actor_count -= 1
|
65
65
|
|
@@ -77,15 +77,15 @@ module Actor
|
|
77
77
|
end
|
78
78
|
|
79
79
|
handle Messages::Shutdown do
|
80
|
-
|
80
|
+
publish.(Messages::Stop)
|
81
81
|
end
|
82
82
|
|
83
83
|
handle Messages::Suspend do |message|
|
84
|
-
|
84
|
+
publish.(message)
|
85
85
|
end
|
86
86
|
|
87
87
|
handle Messages::Resume do |message|
|
88
|
-
|
88
|
+
publish.(message)
|
89
89
|
end
|
90
90
|
|
91
91
|
handle Messages::Stop do |stop|
|
@@ -3,17 +3,17 @@ module Actor
|
|
3
3
|
module Assertions
|
4
4
|
def self.extended supervisor
|
5
5
|
supervisor.instance_exec do
|
6
|
-
assertions_module =
|
7
|
-
|
6
|
+
assertions_module = publish.class::Assertions
|
7
|
+
publish.extend assertions_module
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
def registered_actor? actor
|
12
|
-
|
12
|
+
publish.registered? actor.address
|
13
13
|
end
|
14
14
|
|
15
15
|
def unregistered_actor? actor
|
16
|
-
|
16
|
+
publish.unregistered? actor.address
|
17
17
|
end
|
18
18
|
end
|
19
19
|
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: 1.0.0.
|
4
|
+
version: 1.0.0.pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Ladd
|
@@ -27,19 +27,19 @@ files:
|
|
27
27
|
- lib/actor/messaging/address/none.rb
|
28
28
|
- lib/actor/messaging/message.rb
|
29
29
|
- lib/actor/messaging/message/name.rb
|
30
|
-
- lib/actor/messaging/
|
31
|
-
- lib/actor/messaging/
|
32
|
-
- lib/actor/messaging/
|
33
|
-
- lib/actor/messaging/
|
30
|
+
- lib/actor/messaging/publish.rb
|
31
|
+
- lib/actor/messaging/publish/assertions.rb
|
32
|
+
- lib/actor/messaging/publish/dependency.rb
|
33
|
+
- lib/actor/messaging/publish/substitute.rb
|
34
34
|
- lib/actor/messaging/queue.rb
|
35
35
|
- lib/actor/messaging/queue/substitute.rb
|
36
|
-
- lib/actor/messaging/
|
37
|
-
- lib/actor/messaging/
|
38
|
-
- lib/actor/messaging/
|
39
|
-
- lib/actor/messaging/
|
40
|
-
- lib/actor/messaging/
|
41
|
-
- lib/actor/messaging/
|
42
|
-
- lib/actor/messaging/
|
36
|
+
- lib/actor/messaging/read.rb
|
37
|
+
- lib/actor/messaging/read/assertions.rb
|
38
|
+
- lib/actor/messaging/read/dependency.rb
|
39
|
+
- lib/actor/messaging/read/substitute.rb
|
40
|
+
- lib/actor/messaging/write.rb
|
41
|
+
- lib/actor/messaging/write/dependency.rb
|
42
|
+
- lib/actor/messaging/write/substitute.rb
|
43
43
|
- lib/actor/module/dependencies.rb
|
44
44
|
- lib/actor/module/dependencies/assertions.rb
|
45
45
|
- lib/actor/module/handler.rb
|