async-container-supervisor 0.2.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a0bc9194df4540151c6eefcb4cee4c7e3409ef0987cd9c531854735e55aa8a4
4
- data.tar.gz: 71250f5046b37fb5be64e2230f6f17a4a17ed73a427e695e1e16838240c776d1
3
+ metadata.gz: bd9f2199288f8fec5b35a5e03b198dbb7cd6b24d2b8fd3d88e3aac544010e67c
4
+ data.tar.gz: ac3ea3b40125f70b84913050f539b17459ed7479266ba9f6a93896ec16602d88
5
5
  SHA512:
6
- metadata.gz: 5e6f93605da53a940279f004d9132fc30c5de7c2517806f34c9fd3a4d4ffde964414a317d99f7828d72f4100891e807a8eef49f9c8bc45b76e2d130c8d820e67
7
- data.tar.gz: 7886788dd3cc56ac89f37e68657136ccf6ac608c0f74d48c6da73166c618a41d4608c650a9190c153b53f061803a3f81cd185c76ec10ff979cfebb89b03974ee
6
+ metadata.gz: 351d36fac69f88fd879e10d48c18af0f2d5b34e4646e8cffda29a431944a1f0cae9e95ab8963238bc4831516edf831cdafaf8a28cb288ac5d730a1664dfb9793
7
+ data.tar.gz: 26256ef607c7f227122a60d15477250f2a42f11bc6c9d76ad75d17aa8496a201ada0085f505d28b8ac8e25d7a4f9a0e96a2f4ea96226b6538f37a8f81907ef0f
checksums.yaml.gz.sig CHANGED
Binary file
@@ -58,7 +58,7 @@ module Async
58
58
  Console.error(self, "Connection failed:", exception: error)
59
59
  sleep(rand)
60
60
  ensure
61
- connection.close
61
+ connection&.close
62
62
  end
63
63
  end
64
64
  end
@@ -93,12 +93,34 @@ module Async
93
93
  call = self.new(connection, id, message)
94
94
 
95
95
  connection.calls[id] = call
96
- connection.write(id: id, **message)
97
-
98
- if block_given?
99
- call.each(&block)
100
- else
101
- return call.pop
96
+ begin
97
+ connection.write(id: id, **message)
98
+
99
+ if block_given?
100
+ call.each(&block)
101
+ else
102
+ intermediate = nil
103
+
104
+ while response = call.pop
105
+ if response.delete(:finished)
106
+ if intermediate
107
+ if response.any?
108
+ intermediate << response
109
+ end
110
+
111
+ return intermediate
112
+ else
113
+ return response
114
+ end
115
+ else
116
+ # Buffer intermediate responses:
117
+ intermediate ||= []
118
+ intermediate << response
119
+ end
120
+ end
121
+ end
122
+ ensure
123
+ connection.calls.delete(id)
102
124
  end
103
125
  end
104
126
  end
@@ -156,7 +178,7 @@ module Async
156
178
 
157
179
  def run(target)
158
180
  self.each do |message|
159
- if id = message[:id]
181
+ if id = message.delete(:id)
160
182
  if call = @calls[id]
161
183
  # Response to a call:
162
184
  call.push(**message)
@@ -5,6 +5,8 @@
5
5
 
6
6
  require "async/service/environment"
7
7
 
8
+ require_relative "service"
9
+
8
10
  module Async
9
11
  module Container
10
12
  module Supervisor
@@ -43,9 +43,7 @@ module Async
43
43
  end
44
44
 
45
45
  def status(call)
46
- @processes.each do
47
- call.push(memory_monitor: @cluster)
48
- end
46
+ call.push(memory_monitor: @cluster)
49
47
  end
50
48
 
51
49
  def run
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
6
+ require "async/service/environment"
7
+
8
+ module Async
9
+ module Container
10
+ module Supervisor
11
+ module Supervised
12
+ # The IPC path to use for communication with the supervisor.
13
+ # @returns [String]
14
+ def supervisor_ipc_path
15
+ ::File.expand_path("supervisor.ipc", root)
16
+ end
17
+
18
+ # The endpoint the supervisor will bind to.
19
+ # @returns [::IO::Endpoint::Generic]
20
+ def supervisor_endpoint
21
+ ::IO::Endpoint.unix(supervisor_ipc_path)
22
+ end
23
+
24
+ def make_supervised_worker(instance)
25
+ Worker.new(instance, endpoint: supervisor_endpoint)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -6,7 +6,7 @@
6
6
  module Async
7
7
  module Container
8
8
  module Supervisor
9
- VERSION = "0.2.0"
9
+ VERSION = "0.4.0"
10
10
  end
11
11
  end
12
12
  end
@@ -12,4 +12,4 @@ require_relative "supervisor/client"
12
12
  require_relative "supervisor/memory_monitor"
13
13
 
14
14
  require_relative "supervisor/environment"
15
- require_relative "supervisor/service"
15
+ require_relative "supervisor/supervised"
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-container-supervisor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -107,6 +107,7 @@ files:
107
107
  - lib/async/container/supervisor/memory_monitor.rb
108
108
  - lib/async/container/supervisor/server.rb
109
109
  - lib/async/container/supervisor/service.rb
110
+ - lib/async/container/supervisor/supervised.rb
110
111
  - lib/async/container/supervisor/version.rb
111
112
  - lib/async/container/supervisor/worker.rb
112
113
  - license.md
metadata.gz.sig CHANGED
Binary file