Class: Utils::Probe::ProbeClient

Inherits:
Object
  • Object
show all
Includes:
ServerHandling
Defined in:
lib/utils/probe/probe_client.rb

Overview

A client for interacting with the probe server through Unix domain sockets.

This class provides an interface for enqueueing process jobs and managing environment variables on a remote probe server. It uses Unix domain sockets to communicate with the server, enabling distributed task execution and configuration management.

Defined Under Namespace

Classes: EnvProxy

Instance Method Summary collapse

Methods included from ServerHandling

#create_server

Constructor Details

#initialize(server_type: :unix, port: 6666) ⇒ Utils::ProbeServer

The initialize method sets up a new probe server instance.

This method creates and configures a Unix domain socket server for handling probe jobs and communication. It initializes the server with a specific socket name and runtime directory, preparing it to listen for incoming connections and process jobs.



67
68
69
# File 'lib/utils/probe/probe_client.rb', line 67

def initialize(server_type: :unix, port: 6666)
  @server = create_server(server_type, port)
end

Instance Method Details

#enqueue(args) ⇒ Object

The enqueue method submits a new process job to the probe server for execution.

This method transmits a process job request to the underlying Unix domain socket server, which then adds the job to the processing queue. The job includes the specified command arguments that will be executed by the probe server.

job

Parameters:

  • args (Array)

    the command arguments to be executed by the process



94
95
96
# File 'lib/utils/probe/probe_client.rb', line 94

def enqueue(args)
  @server.transmit({ type: 'process_job', args: })
end

#envUtils::ProbeServer::EnvProxy

The env method provides access to environment variable management through a proxy object.

This method returns an EnvProxy instance that allows for setting and retrieving environment variables via the probe server communication channel.

variable operations

Returns:

  • (Utils::ProbeServer::EnvProxy)

    a proxy object for environment



80
81
82
# File 'lib/utils/probe/probe_client.rb', line 80

def env
  EnvProxy.new(@server)
end