async-container 0.21.0 → 0.23.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: 6dd27e02912c5f1258419c9821da1bd97d58f4fd68b4a58512b3ebd5291c5b6b
4
- data.tar.gz: 36fc9d2d0ce94a0e2591beac3384d2fba288094a93c1ada7a9000841c1e78a59
3
+ metadata.gz: 83778c10be3ccd8ed8b61d607d5e742f2b727f01a2ee16149cf298a70585a083
4
+ data.tar.gz: 14eb47ac328d93b39517b74210f6a4d26b22afa13aefa42df105e2d9e55d16b1
5
5
  SHA512:
6
- metadata.gz: 162f3604bbaa973b486fc271ccf61106008a5d2259f114134535188349267ee3dfb81cbe857ce7edc49dd2037b5d1f5581dd531955ddbfba264a113638e300cd
7
- data.tar.gz: b1ba5f8e3b96976a97b6f81e20a62efbcbde89e4e2f0be43c754954a44924e2553c447cf275121ce74894d0044e7677a144c7f43df5f77d7a55b263f6442eb96
6
+ metadata.gz: fc053221b626ecfbec43f512442547d151737dc8894efb15a4ab53e9f651d5597162206dd1260c43a6d5a0599d39edb2bd37cb21ab0a3c415ee44b9f42b68117
7
+ data.tar.gz: 36ae31abb21e0ee9bc7db47fc881de4ba2ddd3b0aa13b8878ae639cf96e8c56b0bfb561cb34074ee2d10b65e8bcdb5bd4e678d48a7bf1d9527774a525d43eb98
checksums.yaml.gz.sig CHANGED
Binary file
@@ -41,12 +41,24 @@ module Async
41
41
  @name = nil
42
42
  end
43
43
 
44
+ def as_json(...)
45
+ {
46
+ process_id: ::Process.pid,
47
+ name: @name,
48
+ }
49
+ end
50
+
51
+ def to_json(...)
52
+ as_json.to_json(...)
53
+ end
54
+
44
55
  # Set the process title to the specified value.
45
56
  # @parameter value [String] The name of the process.
46
57
  def name= value
47
- if @name = value
48
- ::Process.setproctitle(@name)
49
- end
58
+ @name = value
59
+
60
+ # This sets the process title to an empty string if the name is nil:
61
+ ::Process.setproctitle(@name.to_s)
50
62
  end
51
63
 
52
64
  # The name of the process.
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2024, by Samuel Williams.
5
+
6
+ require_relative "client"
7
+ require "socket"
8
+
9
+ module Async
10
+ module Container
11
+ module Notify
12
+ class Log < Client
13
+ # The name of the environment variable which contains the path to the notification socket.
14
+ NOTIFY_LOG = "NOTIFY_LOG"
15
+
16
+ # Open a notification client attached to the current {NOTIFY_LOG} if possible.
17
+ def self.open!(environment = ENV)
18
+ if path = environment.delete(NOTIFY_LOG)
19
+ self.new(path)
20
+ end
21
+ end
22
+
23
+ # Initialize the notification client.
24
+ # @parameter path [String] The path to the UNIX socket used for sending messages to the process manager.
25
+ def initialize(path)
26
+ @path = path
27
+ end
28
+
29
+ # @attribute [String] The path to the UNIX socket used for sending messages to the controller.
30
+ attr :path
31
+
32
+ # Send the given message.
33
+ # @parameter message [Hash]
34
+ def send(**message)
35
+ data = JSON.dump(message)
36
+
37
+ File.open(@path, "a") do |file|
38
+ file.puts(data)
39
+ end
40
+ end
41
+
42
+ # Send the specified error.
43
+ # `sd_notify` requires an `errno` key, which defaults to `-1` to indicate a generic error.
44
+ def error!(text, **message)
45
+ message[:errno] ||= -1
46
+
47
+ super
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -5,6 +5,7 @@
5
5
  # Copyright, 2020, by Olle Jonsson.
6
6
 
7
7
  require "tmpdir"
8
+ require "socket"
8
9
  require "securerandom"
9
10
 
10
11
  module Async
@@ -6,6 +6,7 @@
6
6
  require_relative "notify/pipe"
7
7
  require_relative "notify/socket"
8
8
  require_relative "notify/console"
9
+ require_relative "notify/log"
9
10
 
10
11
  module Async
11
12
  module Container
@@ -18,6 +19,7 @@ module Async
18
19
  @client ||= (
19
20
  Pipe.open! ||
20
21
  Socket.open! ||
22
+ Log.open! ||
21
23
  Console.open!
22
24
  )
23
25
  end
@@ -53,12 +53,23 @@ module Async
53
53
  end
54
54
 
55
55
  def initialize(io)
56
- @name = nil
57
56
  @thread = ::Thread.current
58
57
 
59
58
  super
60
59
  end
61
60
 
61
+ def as_json(...)
62
+ {
63
+ process_id: ::Process.pid,
64
+ thread_id: @thread.object_id,
65
+ name: @thread.name,
66
+ }
67
+ end
68
+
69
+ def to_json(...)
70
+ as_json.to_json(...)
71
+ end
72
+
62
73
  # Set the name of the thread.
63
74
  # @parameter value [String] The name to set.
64
75
  def name= value
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Container
8
- VERSION = "0.21.0"
8
+ VERSION = "0.23.0"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-container
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -40,7 +40,7 @@ cert_chain:
40
40
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
41
41
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
42
42
  -----END CERTIFICATE-----
43
- date: 2025-02-20 00:00:00.000000000 Z
43
+ date: 2025-02-27 00:00:00.000000000 Z
44
44
  dependencies:
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: async
@@ -73,6 +73,7 @@ files:
73
73
  - lib/async/container/notify.rb
74
74
  - lib/async/container/notify/client.rb
75
75
  - lib/async/container/notify/console.rb
76
+ - lib/async/container/notify/log.rb
76
77
  - lib/async/container/notify/pipe.rb
77
78
  - lib/async/container/notify/server.rb
78
79
  - lib/async/container/notify/socket.rb
metadata.gz.sig CHANGED
Binary file