utils 0.84.0 → 0.85.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 +4 -4
- data/bin/probe +15 -9
- data/lib/utils/config_file.rb +8 -14
- data/lib/utils/probe/probe_client.rb +11 -8
- data/lib/utils/probe/probe_server.rb +2 -2
- data/lib/utils/probe/server_handling.rb +10 -15
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3fd913953f77f177caac61d9a98e615eaba79f5aad327b892a8728d510443b3f
|
|
4
|
+
data.tar.gz: d8f2937862ac26cffa7a4d3244155354b33e587d0fc6cecacedbf6539845bbf4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cc3e00dd0c01f36a2835f74c490f2b35cb8d64b7d4197d49d7c3ae09e247ea3d6067483d34facbdc40c19018516e7a368ddfeb4a38e26efc6d8cf460a8785e4a
|
|
7
|
+
data.tar.gz: 566f70210d3ff85d8798cc2876371e49c86d2ec959fa11f76a6ecc6e546819953878fcabc53e210de8c1b024dab9d61863f86f5c415fcb02551fe0f79420b8de
|
data/bin/probe
CHANGED
|
@@ -33,6 +33,7 @@ def usage
|
|
|
33
33
|
|
|
34
34
|
-n TESTNAME run the test TESTNAME in file FILENAME
|
|
35
35
|
-t FRAMEWORK use test framework FRAMEWORK (rspec, test-unit or cucumber)
|
|
36
|
+
-s SERVER_URL tcp/unix URL to connect to
|
|
36
37
|
-c start probe as a client
|
|
37
38
|
-C FOO[=BAR] set/get env variable on probe server
|
|
38
39
|
-l start probe as a server
|
|
@@ -72,6 +73,17 @@ def find_cmd(*cmds, on_fail: -> *cmds { fail "no #{cmds * '|'} command found" })
|
|
|
72
73
|
cmds.map { |c| `which #{c}`.full?(:chomp) }.compact.first or on_fail.(*cmds)
|
|
73
74
|
end
|
|
74
75
|
|
|
76
|
+
# The server_url method retrieves the configured server URL for probe operations.
|
|
77
|
+
#
|
|
78
|
+
# This method checks if a server URL has been specified via command-line
|
|
79
|
+
# options and returns it if available. Otherwise, it falls back to the server
|
|
80
|
+
# URL configured in the probe settings.
|
|
81
|
+
#
|
|
82
|
+
# @return [ String ] the server URL for probe operations
|
|
83
|
+
def server_url
|
|
84
|
+
$opts[?s] || $config.probe.server_url
|
|
85
|
+
end
|
|
86
|
+
|
|
75
87
|
# The start_server method initializes and begins operation of a probe server.
|
|
76
88
|
#
|
|
77
89
|
# This method configures the environment for server operation by setting the
|
|
@@ -79,10 +91,7 @@ end
|
|
|
79
91
|
# probe server instance to handle incoming requests and process jobs.
|
|
80
92
|
def start_server
|
|
81
93
|
Thread.abort_on_exception = $DEBUG
|
|
82
|
-
ProbeServer.new(
|
|
83
|
-
server_type: $config.probe.server_type,
|
|
84
|
-
port: $config.probe.tcp_server_port
|
|
85
|
-
).start
|
|
94
|
+
ProbeServer.new(server_url:).start
|
|
86
95
|
end
|
|
87
96
|
|
|
88
97
|
# The connect_server method establishes a connection to a probe server and
|
|
@@ -93,10 +102,7 @@ end
|
|
|
93
102
|
# It also enqueues jobs for execution on the probe server when specified.
|
|
94
103
|
#
|
|
95
104
|
def connect_server
|
|
96
|
-
probe_client = ProbeClient.new(
|
|
97
|
-
server_type: $config.probe.server_type,
|
|
98
|
-
port: $config.probe.tcp_server_port
|
|
99
|
-
)
|
|
105
|
+
probe_client = ProbeClient.new(server_url:)
|
|
100
106
|
if setting = $opts[?C]
|
|
101
107
|
case setting
|
|
102
108
|
when /\A([^=]+)=([^=]+)\z/
|
|
@@ -125,7 +131,7 @@ if i = ARGV.index('--')
|
|
|
125
131
|
else
|
|
126
132
|
$args = ARGV.dup
|
|
127
133
|
end
|
|
128
|
-
$opts = go 'lct:n:C:h', $args
|
|
134
|
+
$opts = go 'lct:n:C:s:h', $args
|
|
129
135
|
$opts[?h] and usage
|
|
130
136
|
|
|
131
137
|
case
|
data/lib/utils/config_file.rb
CHANGED
|
@@ -224,22 +224,16 @@ class Utils::ConfigFile
|
|
|
224
224
|
# @param dirs [ Array<String> ] the array of directory names to include
|
|
225
225
|
config :include_dirs, %w[lib test tests ext spec]
|
|
226
226
|
|
|
227
|
-
# The
|
|
227
|
+
# The server_url method configures the URL for the probe server
|
|
228
|
+
# communication.
|
|
228
229
|
#
|
|
229
|
-
# This method sets up the server
|
|
230
|
-
#
|
|
231
|
-
#
|
|
230
|
+
# This method sets up a DSL accessor for the probe server URL, providing a
|
|
231
|
+
# default value that uses a Unix domain socket located in the current
|
|
232
|
+
# working directory.
|
|
232
233
|
#
|
|
233
|
-
# @return [
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
# The tcp_server_port method configures the TCP server port setting.
|
|
237
|
-
#
|
|
238
|
-
# This method sets up a configuration option that specifies the port number
|
|
239
|
-
# to be used for TCP server operations.
|
|
240
|
-
#
|
|
241
|
-
# @param value [ Integer ] the TCP server port number to use
|
|
242
|
-
config :tcp_server_port, 59999
|
|
234
|
+
# @return [ String ] the configured probe server URL including the default
|
|
235
|
+
# socket path
|
|
236
|
+
dsl_accessor :server_url, "unix://#{Pathname.pwd + 'probe.socket'}"
|
|
243
237
|
|
|
244
238
|
# The include_dirs_argument method constructs a colon-separated string from
|
|
245
239
|
# include directories.
|
|
@@ -57,15 +57,18 @@ module Utils::Probe
|
|
|
57
57
|
|
|
58
58
|
# The initialize method sets up a new probe server instance.
|
|
59
59
|
#
|
|
60
|
-
# This method creates and configures
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
#
|
|
60
|
+
# This method creates and configures the core components of the probe
|
|
61
|
+
# server, including initializing the Unix domain socket server for
|
|
62
|
+
# communication, setting up the job queue for processing tasks, and
|
|
63
|
+
# preparing the history tracking for completed jobs.
|
|
64
64
|
#
|
|
65
|
-
# @
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
# @param server_url [ String ] the URL to be used for the probe server
|
|
66
|
+
# communication
|
|
67
|
+
#
|
|
68
|
+
# @return [ Utils::ProbeServer ] a new probe server instance configured
|
|
69
|
+
# with the specified socket name and runtime directory
|
|
70
|
+
def initialize(server_url:)
|
|
71
|
+
@server = create_server(server_url)
|
|
69
72
|
end
|
|
70
73
|
|
|
71
74
|
# The env method provides access to environment variable management through
|
|
@@ -19,8 +19,8 @@ module Utils::Probe
|
|
|
19
19
|
#
|
|
20
20
|
# @return [ Utils::ProbeServer ] a new probe server instance configured
|
|
21
21
|
# with the specified socket name and runtime directory
|
|
22
|
-
def initialize(
|
|
23
|
-
@server = create_server(
|
|
22
|
+
def initialize(server_url:)
|
|
23
|
+
@server = create_server(server_url)
|
|
24
24
|
@history = [].freeze
|
|
25
25
|
@jobs_queue = Queue.new
|
|
26
26
|
@current_job_id = 0
|
|
@@ -8,25 +8,20 @@ module Utils::Probe
|
|
|
8
8
|
# creation and management within the Utils library.
|
|
9
9
|
module ServerHandling
|
|
10
10
|
# The create_server method initializes and returns a socket server instance
|
|
11
|
-
# based on the specified server
|
|
11
|
+
# based on the specified server URL configuration
|
|
12
12
|
#
|
|
13
|
-
# This method
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
13
|
+
# This method acts as a factory for creating socket server objects,
|
|
14
|
+
# delegating to the UnixSocks.from_url method to construct either a TCP
|
|
15
|
+
# socket server or a domain socket server depending on the URL scheme
|
|
16
|
+
# provided
|
|
17
17
|
#
|
|
18
|
-
# @param
|
|
19
|
-
#
|
|
18
|
+
# @param server_url [ String ] the URL specifying the socket server
|
|
19
|
+
# configuration
|
|
20
20
|
#
|
|
21
21
|
# @return [ UnixSocks::TCPSocketServer, UnixSocks::DomainSocketServer ] a
|
|
22
|
-
# new socket server instance
|
|
23
|
-
def create_server(
|
|
24
|
-
|
|
25
|
-
when :tcp
|
|
26
|
-
UnixSocks::TCPSocketServer.new(port:)
|
|
27
|
-
else
|
|
28
|
-
UnixSocks::DomainSocketServer.new(socket_name: 'probe.sock', runtime_dir: Dir.pwd)
|
|
29
|
-
end
|
|
22
|
+
# new socket server instance configured according to the URL specification
|
|
23
|
+
def create_server(server_url)
|
|
24
|
+
UnixSocks.from_url(server_url)
|
|
30
25
|
end
|
|
31
26
|
end
|
|
32
27
|
end
|
data/lib/utils/version.rb
CHANGED
data/utils.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: utils 0.
|
|
2
|
+
# stub: utils 0.85.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "utils".freeze
|
|
6
|
-
s.version = "0.
|
|
6
|
+
s.version = "0.85.0".freeze
|
|
7
7
|
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
9
9
|
s.require_paths = ["lib".freeze]
|