You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/async/container/forked.rb
+23-2
Original file line number
Diff line number
Diff line change
@@ -35,24 +35,34 @@ def self.for(process)
35
35
returninstance
36
36
end
37
37
38
+
# Initialize the child process instance.
39
+
#
40
+
# @parameter io [IO] The IO object to use for communication.
38
41
definitialize(io)
39
42
super
40
43
41
44
@name=nil
42
45
end
43
46
47
+
# Generate a hash representation of the process.
48
+
#
49
+
# @returns [Hash] The process as a hash, including `process_id` and `name`.
44
50
defas_json(...)
45
51
{
46
52
process_id: ::Process.pid,
47
53
name: @name,
48
54
}
49
55
end
50
56
57
+
# Generate a JSON representation of the process.
58
+
#
59
+
# @returns [String] The process as JSON.
51
60
defto_json(...)
52
61
as_json.to_json(...)
53
62
end
54
63
55
64
# Set the process title to the specified value.
65
+
#
56
66
# @parameter value [String] The name of the process.
57
67
defname=value
58
68
@name=value
@@ -61,14 +71,17 @@ def name= value
61
71
::Process.setproctitle(@name.to_s)
62
72
end
63
73
64
-
# The name of the process.
65
-
# @returns [String]
74
+
# @returns [String] The name of the process.
66
75
defname
67
76
@name
68
77
end
69
78
70
79
# Replace the current child process with a different one. Forwards arguments and options to {::Process.exec}.
71
80
# This method replaces the child process with the new executable, thus this method never returns.
81
+
#
82
+
# @parameter arguments [Array] The arguments to pass to the new process.
83
+
# @parameter ready [Boolean] If true, informs the parent process that the child is ready. Otherwise, the child process will need to use a notification protocol to inform the parent process that it is ready.
84
+
# @parameter options [Hash] Additional options to pass to {::Process.exec}.
Copy file name to clipboardExpand all lines: lib/async/container/keyed.rb
+9-6
Original file line number
Diff line number
Diff line change
@@ -8,22 +8,23 @@ module Container
8
8
# Tracks a key/value pair such that unmarked keys can be identified and cleaned up.
9
9
# This helps implement persistent processes that start up child processes per directory or configuration file. If those directories and/or configuration files are removed, the child process can then be cleaned up automatically, because those key/value pairs will not be marked when reloading the container.
10
10
classKeyed
11
+
# Initialize the keyed instance
12
+
#
13
+
# @parameter key [Object] The key.
14
+
# @parameter value [Object] The value.
11
15
definitialize(key,value)
12
16
@key=key
13
17
@value=value
14
18
@marked=true
15
19
end
16
20
17
-
# The key. Normally a symbol or a file-system path.
18
-
# @attribute [Object]
21
+
# @attribute [Object] The key value, normally a symbol or a file-system path.
19
22
attr:key
20
23
21
-
# The value. Normally a child instance of some sort.
22
-
# @attribute [Object]
24
+
# @attribute [Object] The value, normally a child instance.
23
25
attr:value
24
26
25
-
# Has the instance been marked?
26
-
# @returns [Boolean]
27
+
# @returns [Boolean] True if the instance has been marked, during reloading the container.
27
28
defmarked?
28
29
@marked
29
30
end
@@ -39,6 +40,8 @@ def clear!
39
40
end
40
41
41
42
# Stop the instance if it was not marked.
43
+
#
44
+
# @returns [Boolean] True if the instance was stopped.
Copy file name to clipboardExpand all lines: lib/async/container/notify/client.rb
+3
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,9 @@ module Async
7
7
moduleContainer
8
8
# Handles the details of several process readiness protocols.
9
9
moduleNotify
10
+
# Represents a client that can send messages to the parent controller in order to notify it of readiness, status changes, etc.
11
+
#
12
+
# A process readiness protocol (e.g. `sd_notify`) is a simple protocol for a child process to notify the parent process that it is ready (e.g. to accept connections, to process requests, etc). This can help dependency-based startup systems to start services in the correct order, and to handle failures gracefully.
10
13
classClient
11
14
# Notify the parent controller that the child has become ready, with a brief status message.
12
15
# @parameters message [Hash] Additional details to send with the message.
0 commit comments