utils 0.80.0 → 0.81.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/Rakefile +1 -1
- data/bin/probe +8 -2
- data/lib/utils/config_dir.rb +0 -14
- data/lib/utils/config_file.rb +17 -0
- data/lib/utils/probe_server.rb +40 -6
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +4 -4
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6f4a74cb28195b08e8c1105b16b40a4d79189c4e8a5396a1f2df3deba71ed9d4
|
|
4
|
+
data.tar.gz: 4d01dc2e96f809e5ed338f875f87e90468721b190bb79856aa854830a4b413bf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 12e0c3edbef1d6ce684ea79bb80ac0379f5962626d07cc574906df58bd2158225c4732982850c6adefd0dbb4cd7347eff58f7f3422537bb96da57ac5f62ec5bd
|
|
7
|
+
data.tar.gz: cd3eddebabc474a530dfca7427bda4dffbbf377a09bf8b891d6c8ef51c2fc2aa033c625254ea88854d0b3b8e83207e59097276ccf06840c461c23fd872929995
|
data/Rakefile
CHANGED
data/bin/probe
CHANGED
|
@@ -78,7 +78,10 @@ end
|
|
|
78
78
|
# probe server instance to handle incoming requests and process jobs.
|
|
79
79
|
def start_server
|
|
80
80
|
Thread.abort_on_exception = $DEBUG
|
|
81
|
-
Utils::ProbeServer.new
|
|
81
|
+
Utils::ProbeServer.new(
|
|
82
|
+
server_type: $config.probe.server_type,
|
|
83
|
+
port: $config.probe.tcp_server_port
|
|
84
|
+
).start
|
|
82
85
|
end
|
|
83
86
|
|
|
84
87
|
# The connect_server method establishes a connection to a probe server and
|
|
@@ -89,7 +92,10 @@ end
|
|
|
89
92
|
# It also enqueues jobs for execution on the probe server when specified.
|
|
90
93
|
#
|
|
91
94
|
def connect_server
|
|
92
|
-
probe_client = ProbeClient.new
|
|
95
|
+
probe_client = Utils::ProbeClient.new(
|
|
96
|
+
server_type: $config.probe.server_type,
|
|
97
|
+
port: $config.probe.tcp_server_port
|
|
98
|
+
)
|
|
93
99
|
if setting = $opts[?C]
|
|
94
100
|
case setting
|
|
95
101
|
when /\A([^=]+)=([^=]+)\z/
|
data/lib/utils/config_dir.rb
CHANGED
|
@@ -31,20 +31,6 @@ module Utils
|
|
|
31
31
|
@directory_path = derive_directory_path(name, root_path)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
# Memoizes the foobar method's return value and returns the result of the computation.
|
|
35
|
-
# Initializes a new ConfigDir instance with the specified name and optional
|
|
36
|
-
# root path or environment variable.
|
|
37
|
-
#
|
|
38
|
-
# @param name [ String ] the name of the directory to be used
|
|
39
|
-
# @param root_path [ String, nil ] the root path to use; if nil, the
|
|
40
|
-
# default root path is used
|
|
41
|
-
# @param env_var [ String, nil ] the name of the environment variable to
|
|
42
|
-
# check for the root path
|
|
43
|
-
def initialize(name, root_path: nil, env_var: nil)
|
|
44
|
-
root_path ||= env_var_path(env_var)
|
|
45
|
-
@directory_path = derive_directory_path(name, root_path)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
34
|
# Returns the string representation of the configuration directory path.
|
|
49
35
|
#
|
|
50
36
|
# @return [ String ] the path of the configuration directory as a string
|
data/lib/utils/config_file.rb
CHANGED
|
@@ -224,6 +224,23 @@ 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 server_type method configures the type of server to be used.
|
|
228
|
+
#
|
|
229
|
+
# This method sets up the server type configuration option, which
|
|
230
|
+
# determines the underlying server implementation to be utilized, this is
|
|
231
|
+
# either :unix for UNIX domain sockets or :tcp for TCP Sockets.
|
|
232
|
+
#
|
|
233
|
+
# @return [ Symbol ] returns the server type configured
|
|
234
|
+
config :server_type, :unix
|
|
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
|
|
243
|
+
|
|
227
244
|
# The include_dirs_argument method constructs a colon-separated string from
|
|
228
245
|
# include directories.
|
|
229
246
|
#
|
data/lib/utils/probe_server.rb
CHANGED
|
@@ -2,6 +2,37 @@ require 'unix_socks'
|
|
|
2
2
|
require 'term/ansicolor'
|
|
3
3
|
|
|
4
4
|
module Utils
|
|
5
|
+
# A module that provides server handling functionality for creating and
|
|
6
|
+
# managing socket servers.
|
|
7
|
+
#
|
|
8
|
+
# This module encapsulates the logic for initializing different types of
|
|
9
|
+
# socket servers based on the specified server type, supporting both TCP and
|
|
10
|
+
# domain socket configurations. It provides a centralized approach to server
|
|
11
|
+
# creation and management within the Utils library.
|
|
12
|
+
module ServerHandling
|
|
13
|
+
# The create_server method initializes and returns a socket server instance
|
|
14
|
+
# based on the specified server type.
|
|
15
|
+
#
|
|
16
|
+
# This method creates either a TCP socket server or a domain socket server
|
|
17
|
+
# depending on the server type parameter. It configures the server with the
|
|
18
|
+
# appropriate parameters including port number for TCP servers or socket
|
|
19
|
+
# name and runtime directory for domain sockets.
|
|
20
|
+
#
|
|
21
|
+
# @param server_type [ Symbol ] the type of socket server to create, either :tcp or another value for domain socket
|
|
22
|
+
# @param port [ Integer ] the port number to use for TCP socket server creation
|
|
23
|
+
#
|
|
24
|
+
# @return [ UnixSocks::TCPSocketServer, UnixSocks::DomainSocketServer ] a
|
|
25
|
+
# new socket server instance of the specified type
|
|
26
|
+
def create_server(server_type, port)
|
|
27
|
+
case server_type
|
|
28
|
+
when :tcp
|
|
29
|
+
UnixSocks::TCPSocketServer.new(port:)
|
|
30
|
+
else
|
|
31
|
+
UnixSocks::DomainSocketServer.new(socket_name: 'probe.sock', runtime_dir: Dir.pwd)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
5
36
|
# A process job representation for execution within the probe server system.
|
|
6
37
|
#
|
|
7
38
|
# This class encapsulates the information and behavior associated with a
|
|
@@ -138,6 +169,8 @@ module Utils
|
|
|
138
169
|
# to communicate with the server, enabling distributed task execution and
|
|
139
170
|
# configuration management.
|
|
140
171
|
class ProbeClient
|
|
172
|
+
include ServerHandling
|
|
173
|
+
|
|
141
174
|
# A proxy class for managing environment variables through a probe server communication channel.
|
|
142
175
|
#
|
|
143
176
|
# This class provides a wrapper around the ENV object that allows setting and retrieving
|
|
@@ -194,8 +227,8 @@ module Utils
|
|
|
194
227
|
#
|
|
195
228
|
# @return [ Utils::ProbeServer ] a new probe server instance configured with
|
|
196
229
|
# the specified socket name and runtime directory
|
|
197
|
-
def initialize
|
|
198
|
-
@server =
|
|
230
|
+
def initialize(server_type: :unix, port: 6666)
|
|
231
|
+
@server = create_server(server_type, port)
|
|
199
232
|
end
|
|
200
233
|
|
|
201
234
|
# The env method provides access to environment variable management through
|
|
@@ -234,6 +267,7 @@ module Utils
|
|
|
234
267
|
# maintains a queue of jobs, tracks their execution status, and provides an
|
|
235
268
|
# interactive interface for managing the server.
|
|
236
269
|
class ProbeServer
|
|
270
|
+
include ServerHandling
|
|
237
271
|
include Term::ANSIColor
|
|
238
272
|
|
|
239
273
|
# The initialize method sets up a new probe server instance.
|
|
@@ -245,8 +279,8 @@ module Utils
|
|
|
245
279
|
#
|
|
246
280
|
# @return [ Utils::ProbeServer ] a new probe server instance configured
|
|
247
281
|
# with the specified socket name and runtime directory
|
|
248
|
-
def initialize
|
|
249
|
-
@server =
|
|
282
|
+
def initialize(server_type: :unix, port: 6666)
|
|
283
|
+
@server = create_server(server_type, port)
|
|
250
284
|
@history = [].freeze
|
|
251
285
|
@jobs_queue = Queue.new
|
|
252
286
|
@current_job_id = 0
|
|
@@ -258,7 +292,7 @@ module Utils
|
|
|
258
292
|
# from the queue and entering a receive loop to handle incoming requests.
|
|
259
293
|
# It also manages interrupt signals to enter interactive mode when needed.
|
|
260
294
|
def start
|
|
261
|
-
output_message "Starting probe server listening to #{@server.
|
|
295
|
+
output_message "Starting probe server listening to #{@server.to_url}", type: :info
|
|
262
296
|
Thread.new do
|
|
263
297
|
loop do
|
|
264
298
|
job = @jobs_queue.pop
|
|
@@ -278,7 +312,7 @@ module Utils
|
|
|
278
312
|
$VERBOSE = old
|
|
279
313
|
end
|
|
280
314
|
@server.remove_socket_path
|
|
281
|
-
output_message "Quitting interactive mode, but still listening to #{@server.
|
|
315
|
+
output_message "Quitting interactive mode, but still listening to #{@server.to_url}", type: :info
|
|
282
316
|
retry
|
|
283
317
|
end
|
|
284
318
|
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.81.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.81.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]
|
|
@@ -23,9 +23,9 @@ Gem::Specification.new do |s|
|
|
|
23
23
|
|
|
24
24
|
s.specification_version = 4
|
|
25
25
|
|
|
26
|
-
s.add_development_dependency(%q<gem_hadar>.freeze, ["
|
|
26
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, [">= 2.16.2".freeze])
|
|
27
27
|
s.add_development_dependency(%q<test-unit>.freeze, [">= 0".freeze])
|
|
28
|
-
s.add_runtime_dependency(%q<unix_socks>.freeze, ["~> 0.
|
|
28
|
+
s.add_runtime_dependency(%q<unix_socks>.freeze, ["~> 0.3".freeze])
|
|
29
29
|
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.51".freeze])
|
|
30
30
|
s.add_runtime_dependency(%q<term-ansicolor>.freeze, ["~> 1.11".freeze])
|
|
31
31
|
s.add_runtime_dependency(%q<pstree>.freeze, ["~> 0.3".freeze])
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: utils
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.81.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -13,16 +13,16 @@ dependencies:
|
|
|
13
13
|
name: gem_hadar
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
|
-
- - "
|
|
16
|
+
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version:
|
|
18
|
+
version: 2.16.2
|
|
19
19
|
type: :development
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
|
-
- - "
|
|
23
|
+
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version:
|
|
25
|
+
version: 2.16.2
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: test-unit
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -43,14 +43,14 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '0.
|
|
46
|
+
version: '0.3'
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '0.
|
|
53
|
+
version: '0.3'
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: tins
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|