Class: Hatchet::Features::Workers

Inherits:
Object
  • Object
show all
Defined in:
lib/hatchet/features/workers.rb

Overview

Workers client for managing workers programmatically within Hatchet

This class provides a high-level interface for retrieving, listing, and updating workers in the Hatchet system.

Examples:

Getting a worker

worker = workers_client.get("worker-id")

Listing all workers

workers = workers_client.list

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(rest_client, config) ⇒ void

Initializes a new Workers client instance

Parameters:

  • rest_client (Object)

    The configured REST client for API communication

  • config (Hatchet::Config)

    The Hatchet configuration containing tenant_id and other settings

Since:

  • 0.1.0



24
25
26
27
28
# File 'lib/hatchet/features/workers.rb', line 24

def initialize(rest_client, config)
  @rest_client = rest_client
  @config = config
  @worker_api = HatchetSdkRest::WorkerApi.new(rest_client)
end

Instance Method Details

#get(worker_id) ⇒ Object

Get a worker by its ID

Examples:

worker = workers_client.get("worker-123")

Parameters:

  • worker_id (String)

    The ID of the worker to retrieve

Returns:

  • (Object)

    The worker details

Raises:

Since:

  • 0.1.0



37
38
39
# File 'lib/hatchet/features/workers.rb', line 37

def get(worker_id)
  @worker_api.worker_get(worker_id)
end

#listObject

List all workers in the tenant

Examples:

workers = workers_client.list

Returns:

  • (Object)

    A list of workers

Raises:

Since:

  • 0.1.0



47
48
49
# File 'lib/hatchet/features/workers.rb', line 47

def list
  @worker_api.worker_list(@config.tenant_id)
end

#update(worker_id, opts) ⇒ Object

Update a worker by its ID

Examples:

updated = workers_client.update("worker-123", { is_paused: true })

Parameters:

  • worker_id (String)

    The ID of the worker to update

  • opts (Hash)

    The update options

Returns:

  • (Object)

    The updated worker

Raises:

Since:

  • 0.1.0



59
60
61
62
# File 'lib/hatchet/features/workers.rb', line 59

def update(worker_id, opts)
  update_request = HatchetSdkRest::UpdateWorkerRequest.new(opts)
  @worker_api.worker_update(worker_id, update_request)
end