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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74d1c4048d40164e89c4edcd2b3bd91516b0bf82d6f8d0b0d68c25b70c21927e
4
- data.tar.gz: 290d49a38bd95423c93f0c5df749ada24245731369c9233d11f3de619f5099d6
3
+ metadata.gz: 6f4a74cb28195b08e8c1105b16b40a4d79189c4e8a5396a1f2df3deba71ed9d4
4
+ data.tar.gz: 4d01dc2e96f809e5ed338f875f87e90468721b190bb79856aa854830a4b413bf
5
5
  SHA512:
6
- metadata.gz: 253d562cff1325f5218f89b6d800d6e656eeb3c8c5067a38581271720161c55a181c2fbba3e2ff815219805438af9dea258e59e6b00f12ba8485db172d4abab3
7
- data.tar.gz: defe6add59ce6268f5d16f3ccc7f20da40c7436f686dfafd5d66cc2f4ed8aedc1a591e2eb1da69cdcfbaf4693fe19d0ba46e8a5d1e297170fbed8a1fec5d717a
6
+ metadata.gz: 12e0c3edbef1d6ce684ea79bb80ac0379f5962626d07cc574906df58bd2158225c4732982850c6adefd0dbb4cd7347eff58f7f3422537bb96da57ac5f62ec5bd
7
+ data.tar.gz: cd3eddebabc474a530dfca7427bda4dffbbf377a09bf8b891d6c8ef51c2fc2aa033c625254ea88854d0b3b8e83207e59097276ccf06840c461c23fd872929995
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ GemHadar do
20
20
  readme 'README.md'
21
21
  licenses << 'GPL-2.0'
22
22
 
23
- dependency 'unix_socks', '~> 0.2'
23
+ dependency 'unix_socks', '~> 0.3'
24
24
  dependency 'tins', '~> 1.51'
25
25
  dependency 'term-ansicolor', '~> 1.11'
26
26
  dependency 'pstree', '~> 0.3'
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.start
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/
@@ -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
@@ -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
  #
@@ -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 = UnixSocks::Server.new(socket_name: 'probe.sock', runtime_dir: Dir.pwd)
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 = UnixSocks::Server.new(socket_name: 'probe.sock', runtime_dir: Dir.pwd)
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.server_socket_path}.", type: :info
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.server_socket_path}.", type: :info
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
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  # Utils version
3
- VERSION = '0.80.0'
3
+ VERSION = '0.81.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/utils.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: utils 0.80.0 ruby lib
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.80.0".freeze
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, ["~> 2.10".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.2".freeze])
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.80.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: '2.10'
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: '2.10'
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.2'
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.2'
53
+ version: '0.3'
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: tins
56
56
  requirement: !ruby/object:Gem::Requirement