Class: Gearman::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/gearman/job.rb

Overview

Job

Description

Interface to allow a worker to report information to a job server.

Instance Method Summary collapse

Constructor Details

#initialize(client, handle) ⇒ Job

Create a new Job.

Parameters:

  • sock

    Socket connected to job server

  • handle

    job server-supplied job handle



12
13
14
15
# File 'lib/gearman/job.rb', line 12

def initialize(client, handle)
  @client = client
  @handle = handle
end

Instance Method Details

#report_status(numerator, denominator) ⇒ Object

Report our status to the job server.



18
19
20
21
# File 'lib/gearman/job.rb', line 18

def report_status(numerator, denominator)
  @client.send :work_status, "#{@handle}\0#{numerator}\0#{denominator}"
  self
end

#report_warning(warning) ⇒ Object

Send a warning explicitly



33
34
35
36
# File 'lib/gearman/job.rb', line 33

def report_warning(warning)
  @client.send :work_warning, "#{@handle}\0#{warning}"
  self
end

#send_partial(data) ⇒ Object Also known as: send_data

Send data before job completes



25
26
27
28
# File 'lib/gearman/job.rb', line 25

def send_partial(data)
  @client.send :work_data, "#{@handle}\0#{data}"
  self
end