ntl-actor 1.2.7 → 1.3.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 +0 -6
- data/lib/actor/messaging/publish.rb +4 -0
- data/lib/actor/messaging/publish/substitute.rb +21 -23
- data/lib/actor/messaging/queue/substitute.rb +9 -12
- data/lib/actor/messaging/read.rb +18 -0
- data/lib/actor/messaging/send/substitute.rb +12 -14
- data/lib/actor/module/dependencies.rb +16 -2
- data/lib/actor/module/suspend_resume.rb +19 -2
- data/lib/actor/supervisor.rb +9 -3
- metadata +18 -11
- data/lib/actor/messaging/publish/assertions.rb +0 -11
- data/lib/actor/messaging/read/assertions.rb +0 -25
- data/lib/actor/module/dependencies/assertions.rb +0 -23
- data/lib/actor/module/include_assertions.rb +0 -18
- data/lib/actor/module/suspend_resume/assertions.rb +0 -26
- data/lib/actor/supervisor/assertions.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ac91f6f55c430b898dc4ad968d5080ac002bce42d2d9b9015276b538bdb52db
|
4
|
+
data.tar.gz: aaad5df8588557f244bc2c98c65b5c660da7c64676907a72e65c05932a208044
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fce84972bbb8f6eaaa08ba28e04951f30722eca448323e79c675aeca93fadbab4dcc6d82f04bed0f28efbd3fd11ac9809861e724287321e308abfd7324693cb9
|
7
|
+
data.tar.gz: 5570b5bfdabbd337d5c161dd7367bae5c9b1ef6259540d41d5a32fc090e821c957034142b949962aac99322bbe2b27bb81bdc1dba33dab6c6b35445a91db89c1
|
data/lib/actor.rb
CHANGED
@@ -16,7 +16,6 @@ require 'actor/messaging/message'
|
|
16
16
|
require 'actor/messaging/message/name'
|
17
17
|
|
18
18
|
require 'actor/messaging/read'
|
19
|
-
require 'actor/messaging/read/assertions'
|
20
19
|
require 'actor/messaging/read/dependency'
|
21
20
|
require 'actor/messaging/read/substitute'
|
22
21
|
|
@@ -25,24 +24,20 @@ require 'actor/messaging/send/dependency'
|
|
25
24
|
require 'actor/messaging/send/substitute'
|
26
25
|
|
27
26
|
require 'actor/messaging/publish'
|
28
|
-
require 'actor/messaging/publish/assertions'
|
29
27
|
require 'actor/messaging/publish/dependency'
|
30
28
|
require 'actor/messaging/publish/substitute'
|
31
29
|
|
32
30
|
require 'actor/messages'
|
33
31
|
|
34
32
|
require 'actor/module/dependencies'
|
35
|
-
require 'actor/module/dependencies/assertions'
|
36
33
|
require 'actor/module/digest'
|
37
34
|
require 'actor/module/handler'
|
38
35
|
require 'actor/module/handler/method_name'
|
39
36
|
require 'actor/module/handler/macro'
|
40
37
|
require 'actor/module/handler/send_next_message'
|
41
|
-
require 'actor/module/include_assertions'
|
42
38
|
require 'actor/module/run_loop'
|
43
39
|
require 'actor/module/start'
|
44
40
|
require 'actor/module/suspend_resume'
|
45
|
-
require 'actor/module/suspend_resume/assertions'
|
46
41
|
require 'actor/module/suspend_resume/configure'
|
47
42
|
require 'actor/module/suspend_resume/controls'
|
48
43
|
require 'actor/module/suspend_resume/handle'
|
@@ -56,7 +51,6 @@ require 'actor/supervisor'
|
|
56
51
|
require 'actor/supervisor/address/get'
|
57
52
|
require 'actor/supervisor/address/put'
|
58
53
|
require 'actor/supervisor/address/registry'
|
59
|
-
require 'actor/supervisor/assertions'
|
60
54
|
require 'actor/supervisor/observer'
|
61
55
|
|
62
56
|
require 'actor/actor'
|
@@ -28,37 +28,35 @@ module Actor
|
|
28
28
|
records << record
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
registered_addresses.any?
|
37
|
-
else
|
38
|
-
registered_addresses.include? address
|
39
|
-
end
|
31
|
+
def registered? address=nil
|
32
|
+
if address.nil?
|
33
|
+
registered_addresses.any?
|
34
|
+
else
|
35
|
+
registered_addresses.include? address
|
40
36
|
end
|
37
|
+
end
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
39
|
+
def unregistered? address=nil
|
40
|
+
if address.nil?
|
41
|
+
unregistered_addresses.any?
|
42
|
+
else
|
43
|
+
unregistered_addresses.include? address
|
48
44
|
end
|
45
|
+
end
|
49
46
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
return true
|
56
|
-
end
|
47
|
+
def published? message=nil, wait: nil
|
48
|
+
records.each do |record|
|
49
|
+
next unless message.nil? or record.message == message
|
50
|
+
next unless wait.nil? or record.wait == wait
|
57
51
|
|
58
|
-
|
52
|
+
return true
|
59
53
|
end
|
54
|
+
|
55
|
+
false
|
60
56
|
end
|
61
57
|
|
58
|
+
Record = Struct.new :message, :wait
|
59
|
+
|
62
60
|
singleton_class.send :alias_method, :build, :new # subst-attr compat
|
63
61
|
end
|
64
62
|
end
|
@@ -31,6 +31,15 @@ module Actor
|
|
31
31
|
record
|
32
32
|
end
|
33
33
|
|
34
|
+
def enqueued? message=nil, wait: nil
|
35
|
+
@enqueued_records.any? do |record|
|
36
|
+
next unless message.nil? or record.message == message
|
37
|
+
next unless wait.nil? or record.non_block == !wait
|
38
|
+
|
39
|
+
true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
34
43
|
def max
|
35
44
|
Float::INFINITY
|
36
45
|
end
|
@@ -42,18 +51,6 @@ module Actor
|
|
42
51
|
WouldBlockError = Class.new StandardError
|
43
52
|
|
44
53
|
Record = Struct.new :message, :non_block
|
45
|
-
|
46
|
-
module Assertions
|
47
|
-
def enqueued? message=nil, wait: nil
|
48
|
-
@enqueued_records.any? do |record|
|
49
|
-
next unless message.nil? or record.message == message
|
50
|
-
next unless wait.nil? or record.non_block == !wait
|
51
|
-
|
52
|
-
true
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
54
|
singleton_class.send :alias_method, :build, :new # subst-attr compat
|
58
55
|
end
|
59
56
|
end
|
data/lib/actor/messaging/read.rb
CHANGED
@@ -27,6 +27,24 @@ module Actor
|
|
27
27
|
rescue ThreadError
|
28
28
|
return nil
|
29
29
|
end
|
30
|
+
|
31
|
+
def address? address
|
32
|
+
queue? address.queue
|
33
|
+
end
|
34
|
+
|
35
|
+
def next_message? message
|
36
|
+
begin
|
37
|
+
next_message = @queue.deq true
|
38
|
+
rescue ThreadError
|
39
|
+
return false
|
40
|
+
end
|
41
|
+
|
42
|
+
next_message == message
|
43
|
+
end
|
44
|
+
|
45
|
+
def queue? queue
|
46
|
+
self.queue == queue
|
47
|
+
end
|
30
48
|
end
|
31
49
|
end
|
32
50
|
end
|
@@ -16,6 +16,18 @@ module Actor
|
|
16
16
|
records << record
|
17
17
|
end
|
18
18
|
|
19
|
+
def sent? message=nil, address: nil, wait: nil
|
20
|
+
records.each do |record|
|
21
|
+
next unless message.nil? or record.message? message
|
22
|
+
next unless address.nil? or record.address == address
|
23
|
+
next unless wait.nil? or record.wait == wait
|
24
|
+
|
25
|
+
return true
|
26
|
+
end
|
27
|
+
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
19
31
|
Record = Struct.new :message, :address, :wait do
|
20
32
|
def message? pattern
|
21
33
|
return true if message == pattern
|
@@ -26,20 +38,6 @@ module Actor
|
|
26
38
|
end
|
27
39
|
end
|
28
40
|
|
29
|
-
module Assertions
|
30
|
-
def sent? message=nil, address: nil, wait: nil
|
31
|
-
records.each do |record|
|
32
|
-
next unless message.nil? or record.message? message
|
33
|
-
next unless address.nil? or record.address == address
|
34
|
-
next unless wait.nil? or record.wait == wait
|
35
|
-
|
36
|
-
return true
|
37
|
-
end
|
38
|
-
|
39
|
-
false
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
41
|
singleton_class.send :alias_method, :build, :new # subst-attr compat
|
44
42
|
end
|
45
43
|
end
|
@@ -8,14 +8,28 @@ module Actor
|
|
8
8
|
include Messaging::Send::Dependency
|
9
9
|
|
10
10
|
prepend Configure
|
11
|
-
|
12
|
-
IncludeAssertions.(Assertions, self)
|
13
11
|
end
|
14
12
|
end
|
15
13
|
|
16
14
|
def configure
|
17
15
|
end
|
18
16
|
|
17
|
+
def dependencies_configured?
|
18
|
+
address_configured? and reader_configured? and send_configured?
|
19
|
+
end
|
20
|
+
|
21
|
+
def address_configured?
|
22
|
+
address.instance_of? Messaging::Address
|
23
|
+
end
|
24
|
+
|
25
|
+
def reader_configured?
|
26
|
+
read.instance_of? Messaging::Read
|
27
|
+
end
|
28
|
+
|
29
|
+
def send_configured?
|
30
|
+
send.instance_of? Messaging::Send
|
31
|
+
end
|
32
|
+
|
19
33
|
module Configure
|
20
34
|
def configure
|
21
35
|
self.address = Messaging::Address.build
|
@@ -6,8 +6,6 @@ module Actor
|
|
6
6
|
prepend Configure
|
7
7
|
prepend Handle
|
8
8
|
prepend Initialize
|
9
|
-
|
10
|
-
IncludeAssertions.(Assertions, self)
|
11
9
|
end
|
12
10
|
end
|
13
11
|
|
@@ -28,6 +26,25 @@ module Actor
|
|
28
26
|
end
|
29
27
|
end
|
30
28
|
|
29
|
+
def message_deferred? message=nil, wait: nil
|
30
|
+
non_block = wait == false
|
31
|
+
|
32
|
+
begin
|
33
|
+
msg = suspend_queue.deq true
|
34
|
+
rescue ThreadError
|
35
|
+
end
|
36
|
+
|
37
|
+
if message.nil?
|
38
|
+
msg ? true : false
|
39
|
+
else
|
40
|
+
msg == message
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def suspended?
|
45
|
+
@suspended == true
|
46
|
+
end
|
47
|
+
|
31
48
|
def suspend_queue
|
32
49
|
@suspend_queue ||= Messaging::Queue::Substitute.build
|
33
50
|
end
|
data/lib/actor/supervisor.rb
CHANGED
@@ -24,9 +24,7 @@ module Actor
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.start &assembly_block
|
27
|
-
|
28
|
-
Thread.report_on_exception = false
|
29
|
-
end
|
27
|
+
Thread.report_on_exception = false
|
30
28
|
|
31
29
|
thread = Thread.new do
|
32
30
|
instance = Build.(self, &assembly_block)
|
@@ -107,6 +105,14 @@ module Actor
|
|
107
105
|
super stop
|
108
106
|
end
|
109
107
|
|
108
|
+
def registered_actor? actor
|
109
|
+
publish.registered? actor.address
|
110
|
+
end
|
111
|
+
|
112
|
+
def unregistered_actor? actor
|
113
|
+
publish.unregistered? actor.address
|
114
|
+
end
|
115
|
+
|
110
116
|
def assembly_block
|
111
117
|
@assembly_block ||= proc { }
|
112
118
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ntl-actor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.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:
|
12
|
-
dependencies:
|
11
|
+
date: 2019-10-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: test_bench
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: Implementation of actor pattern for Ruby
|
14
28
|
email: nathanladd+github@gmail.com
|
15
29
|
executables: []
|
@@ -29,30 +43,25 @@ files:
|
|
29
43
|
- lib/actor/messaging/message.rb
|
30
44
|
- lib/actor/messaging/message/name.rb
|
31
45
|
- lib/actor/messaging/publish.rb
|
32
|
-
- lib/actor/messaging/publish/assertions.rb
|
33
46
|
- lib/actor/messaging/publish/dependency.rb
|
34
47
|
- lib/actor/messaging/publish/substitute.rb
|
35
48
|
- lib/actor/messaging/queue.rb
|
36
49
|
- lib/actor/messaging/queue/substitute.rb
|
37
50
|
- lib/actor/messaging/read.rb
|
38
|
-
- lib/actor/messaging/read/assertions.rb
|
39
51
|
- lib/actor/messaging/read/dependency.rb
|
40
52
|
- lib/actor/messaging/read/substitute.rb
|
41
53
|
- lib/actor/messaging/send.rb
|
42
54
|
- lib/actor/messaging/send/dependency.rb
|
43
55
|
- lib/actor/messaging/send/substitute.rb
|
44
56
|
- lib/actor/module/dependencies.rb
|
45
|
-
- lib/actor/module/dependencies/assertions.rb
|
46
57
|
- lib/actor/module/digest.rb
|
47
58
|
- lib/actor/module/handler.rb
|
48
59
|
- lib/actor/module/handler/macro.rb
|
49
60
|
- lib/actor/module/handler/method_name.rb
|
50
61
|
- lib/actor/module/handler/send_next_message.rb
|
51
|
-
- lib/actor/module/include_assertions.rb
|
52
62
|
- lib/actor/module/run_loop.rb
|
53
63
|
- lib/actor/module/start.rb
|
54
64
|
- lib/actor/module/suspend_resume.rb
|
55
|
-
- lib/actor/module/suspend_resume/assertions.rb
|
56
65
|
- lib/actor/module/suspend_resume/configure.rb
|
57
66
|
- lib/actor/module/suspend_resume/controls.rb
|
58
67
|
- lib/actor/module/suspend_resume/handle.rb
|
@@ -62,7 +71,6 @@ files:
|
|
62
71
|
- lib/actor/supervisor/address/get.rb
|
63
72
|
- lib/actor/supervisor/address/put.rb
|
64
73
|
- lib/actor/supervisor/address/registry.rb
|
65
|
-
- lib/actor/supervisor/assertions.rb
|
66
74
|
- lib/actor/supervisor/observer.rb
|
67
75
|
homepage: https://github.com/ntl/actor
|
68
76
|
licenses:
|
@@ -84,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
92
|
- !ruby/object:Gem::Version
|
85
93
|
version: '0'
|
86
94
|
requirements: []
|
87
|
-
|
88
|
-
rubygems_version: 2.7.6
|
95
|
+
rubygems_version: 3.0.1
|
89
96
|
signing_key:
|
90
97
|
specification_version: 4
|
91
98
|
summary: Implementation of actor pattern for Ruby
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Actor
|
2
|
-
module Messaging
|
3
|
-
class Read
|
4
|
-
module Assertions
|
5
|
-
def address? address
|
6
|
-
queue? address.queue
|
7
|
-
end
|
8
|
-
|
9
|
-
def next_message? message
|
10
|
-
begin
|
11
|
-
next_message = @queue.deq true
|
12
|
-
rescue ThreadError
|
13
|
-
return false
|
14
|
-
end
|
15
|
-
|
16
|
-
next_message == message
|
17
|
-
end
|
18
|
-
|
19
|
-
def queue? queue
|
20
|
-
self.queue == queue
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Actor
|
2
|
-
module Module
|
3
|
-
module Dependencies
|
4
|
-
module Assertions
|
5
|
-
def dependencies_configured?
|
6
|
-
address_configured? and reader_configured? and send_configured?
|
7
|
-
end
|
8
|
-
|
9
|
-
def address_configured?
|
10
|
-
address.instance_of? Messaging::Address
|
11
|
-
end
|
12
|
-
|
13
|
-
def reader_configured?
|
14
|
-
read.instance_of? Messaging::Read
|
15
|
-
end
|
16
|
-
|
17
|
-
def send_configured?
|
18
|
-
send.instance_of? Messaging::Send
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Actor
|
2
|
-
module Module
|
3
|
-
module IncludeAssertions
|
4
|
-
def self.call assertions_module, receiver
|
5
|
-
receiver.module_exec do
|
6
|
-
unless const_defined? :Assertions, false
|
7
|
-
receiver_assertions_module = ::Module.new
|
8
|
-
const_set :Assertions, receiver_assertions_module
|
9
|
-
end
|
10
|
-
|
11
|
-
receiver_assertions_module ||= const_get :Assertions
|
12
|
-
|
13
|
-
receiver_assertions_module.include assertions_module
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Actor
|
2
|
-
module Module
|
3
|
-
module SuspendResume
|
4
|
-
module Assertions
|
5
|
-
def message_deferred? message=nil, wait: nil
|
6
|
-
non_block = wait == false
|
7
|
-
|
8
|
-
begin
|
9
|
-
msg = suspend_queue.deq true
|
10
|
-
rescue ThreadError
|
11
|
-
end
|
12
|
-
|
13
|
-
if message.nil?
|
14
|
-
msg ? true : false
|
15
|
-
else
|
16
|
-
msg == message
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def suspended?
|
21
|
-
@suspended == true
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Actor
|
2
|
-
class Supervisor
|
3
|
-
module Assertions
|
4
|
-
def self.extended supervisor
|
5
|
-
supervisor.instance_exec do
|
6
|
-
assertions_module = publish.class::Assertions
|
7
|
-
publish.extend assertions_module
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def registered_actor? actor
|
12
|
-
publish.registered? actor.address
|
13
|
-
end
|
14
|
-
|
15
|
-
def unregistered_actor? actor
|
16
|
-
publish.unregistered? actor.address
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|