Sha256: 1e2f0f7cd57bb13c4a2f2b4601fdcb07a5fe771f95ffbf20060177bb29e06184

Contents?: true

Size: 891 Bytes

Versions: 2

Compression:

Stored size: 891 Bytes

Contents

module Gearman
  # = Job
  #
  # == Description
  # Interface to allow a worker to report information to a job server.
  class Job
    ##
    # Create a new Job.
    #
    # @param sock    Socket connected to job server
    # @param handle  job server-supplied job handle
    def initialize(client, handle)
      @client = client
      @handle = handle
    end
    ##
    # Report our status to the job server.
    def report_status(numerator, denominator)
      @client.send :work_status, "#{@handle}\0#{numerator}\0#{denominator}"
      self
    end

    ##
    # Send data before job completes
    def send_partial(data)
      @client.send :work_data, "#{@handle}\0#{data}"
      self
    end
    alias :send_data :send_partial

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

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
evented-gearman-ruby-1.0.0 lib/gearman/job.rb
gearman-ruby-2.0.0 lib/gearman/job.rb