Class: Gearman::Worker::Ability

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

Overview

Ability

Description

Information about an ability that we possess.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block, timeout = nil) ⇒ Ability

Create a new ability.

Parameters:

  • block

    code to run

  • timeout (defaults to: nil)

    server gives up on us after this many seconds



43
44
45
46
# File 'lib/gearman/worker.rb', line 43

def initialize(block, timeout=nil)
  @block = block
  @timeout = timeout
end

Instance Attribute Details

#timeoutObject (readonly)

Returns the value of attribute timeout.



47
48
49
# File 'lib/gearman/worker.rb', line 47

def timeout
  @timeout
end

Instance Method Details

#run(data, job) ⇒ Object

Run the block of code.

Parameters:

  • data

    data passed to us by a client

  • job

    interface to report job information to the server



54
55
56
# File 'lib/gearman/worker.rb', line 54

def run(data, job)
  @block.call(data, job)
end