async-container 0.27.5 → 0.27.7

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: b33373c25e8c39d091f9f9013eb12579d08f01c03ec14612767b607041d59688
4
- data.tar.gz: 2990fa6ab90beb2a67b9bf4ef47c8b8c58590426df73652642d771544c9d15dd
3
+ metadata.gz: 4e0f77eb0f6eb3e7e8f8971af4d653e5ff2c3243ecc12f8dd06b27ae27e09d45
4
+ data.tar.gz: 869aaa117d285f6f407b482b5fcd5b3bb19edcba215202d2faefe159195eed38
5
5
  SHA512:
6
- metadata.gz: 30a81d6c5eede1bf527b9f4493efcd41f2080db091eacb96cfa841cda6c044d52d45bb714dda55009c26bfc1834b18219ff1552116852dc0a7daa7c5a8d34d87
7
- data.tar.gz: be8f6b931ed89cbef3ae8cf04c73519b3184d47ead5a0d3cbe84fb8b99fb178eb031c482b25b2380936450ae97134b0e2c8362d10b6c293e979b8c356cf32b20
6
+ metadata.gz: f1eb59fda7b292a5ca70b15ea0b70af9d6f41551d9a4818f5820dbc9b078f3008d37f646e8cbcdc74428d3c359c9ec9e731b3b0b008a74922f379b700eda32e4
7
+ data.tar.gz: 301401ff8bcd736d2e41d1816110625ce038ff65b0a675d11e0ec900feb5550c73e6e754af9e5123dd12b692e4980deac1d197cbdad38e3a48213b38dd938171
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require "json"
7
7
 
@@ -10,8 +10,9 @@ module Async
10
10
  # Provides a basic multi-thread/multi-process uni-directional communication channel.
11
11
  class Channel
12
12
  # Initialize the channel using a pipe.
13
- def initialize
13
+ def initialize(timeout: 1.0)
14
14
  @in, @out = ::IO.pipe
15
+ @in.timeout = timeout
15
16
  end
16
17
 
17
18
  # The input end of the pipe.
@@ -43,12 +44,11 @@ module Async
43
44
  # @returns [Hash]
44
45
  def receive
45
46
  if data = @in.gets
46
- begin
47
- return JSON.parse(data, symbolize_names: true)
48
- rescue
49
- return {line: data}
50
- end
47
+ return JSON.parse(data, symbolize_names: true)
51
48
  end
49
+ rescue => error
50
+ Console.error(self, "Error during channel receive!", error)
51
+ return nil
52
52
  end
53
53
  end
54
54
  end
@@ -136,8 +136,8 @@ module Async
136
136
 
137
137
  # Initialize the process.
138
138
  # @parameter name [String] The name to use for the child process.
139
- def initialize(name: nil)
140
- super()
139
+ def initialize(name: nil, **options)
140
+ super(**options)
141
141
 
142
142
  @name = name
143
143
  @status = nil
@@ -2,6 +2,7 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2019-2025, by Samuel Williams.
5
+ # Copyright, 2025, by Marc-André Cournoyer.
5
6
 
6
7
  require "etc"
7
8
  require "async/clock"
@@ -179,12 +180,12 @@ module Async
179
180
 
180
181
  fiber do
181
182
  while @running
182
- Console.info(self, "Starting child...", child: {key: key, name: name, restart: restart, health_check_timeout: health_check_timeout}, statistics: @statistics)
183
+ Console.debug(self, "Starting child...", child: {key: key, name: name, restart: restart, health_check_timeout: health_check_timeout}, statistics: @statistics)
183
184
 
184
185
  child = self.start(name, &block)
185
186
  state = insert(key, child)
186
187
 
187
- Console.info(self, "Started child.", child: child, spawn: {key: key, restart: restart, health_check_timeout: health_check_timeout}, statistics: @statistics)
188
+ Console.debug(self, "Started child.", child: child, spawn: {key: key, restart: restart, health_check_timeout: health_check_timeout}, statistics: @statistics)
188
189
 
189
190
  # If a health check is specified, we will monitor the child process and terminate it if it does not update its state within the specified time.
190
191
  if health_check_timeout
@@ -212,7 +213,7 @@ module Async
212
213
  end
213
214
 
214
215
  if status&.success?
215
- Console.info(self, "Child exited successfully.", status: status, running: @running)
216
+ Console.debug(self, "Child exited successfully.", status: status, running: @running)
216
217
  else
217
218
  @statistics.failure!
218
219
  Console.error(self, "Child exited with error!", status: status, running: @running)
@@ -224,8 +225,6 @@ module Async
224
225
  break
225
226
  end
226
227
  end
227
- ensure
228
- Console.info(self, "Child process management loop exited.", running: @running)
229
228
  end.resume
230
229
 
231
230
  return true
@@ -63,9 +63,9 @@ module Async
63
63
  # Formats the message using JSON and sends it to the parent controller.
64
64
  # This is suitable for use with {Channel}.
65
65
  def send(**message)
66
- data = ::JSON.dump(message)
66
+ data = ::JSON.dump(message) << "\n"
67
67
 
68
- @io.puts(data)
68
+ @io.write(data)
69
69
  @io.flush
70
70
  end
71
71
 
@@ -124,8 +124,8 @@ module Async
124
124
  # Initialize the thread.
125
125
  #
126
126
  # @parameter name [String] The name to use for the child thread.
127
- def initialize(name: nil)
128
- super()
127
+ def initialize(name: nil, **options)
128
+ super(**options)
129
129
 
130
130
  @status = nil
131
131
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Container
8
- VERSION = "0.27.5"
8
+ VERSION = "0.27.7"
9
9
  end
10
10
  end
data/license.md CHANGED
@@ -5,6 +5,7 @@ Copyright, 2019, by Yuji Yaginuma.
5
5
  Copyright, 2020, by Olle Jonsson.
6
6
  Copyright, 2020, by Juan Antonio Martín Lucas.
7
7
  Copyright, 2022, by Anton Sozontov.
8
+ Copyright, 2025, by Marc-André Cournoyer.
8
9
 
9
10
  Permission is hereby granted, free of charge, to any person obtaining a copy
10
11
  of this software and associated documentation files (the "Software"), to deal
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-container
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.5
4
+ version: 0.27.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  - Olle Jonsson
9
9
  - Anton Sozontov
10
10
  - Juan Antonio Martín Lucas
11
+ - Marc-André Cournoyer
11
12
  - Yuji Yaginuma
12
13
  bindir: bin
13
14
  cert_chain:
metadata.gz.sig CHANGED
Binary file