Class: RedisClient::Cluster::ConcurrentWorker::Group::Task

Inherits:
Struct
  • Object
show all
Defined in:
lib/redis_client/cluster/concurrent_worker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsObject

Returns the value of attribute args

Returns:

  • (Object)

    the current value of args



13
14
15
# File 'lib/redis_client/cluster/concurrent_worker.rb', line 13

def args
  @args
end

#blockObject

Returns the value of attribute block

Returns:

  • (Object)

    the current value of block



13
14
15
# File 'lib/redis_client/cluster/concurrent_worker.rb', line 13

def block
  @block
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



13
14
15
# File 'lib/redis_client/cluster/concurrent_worker.rb', line 13

def id
  @id
end

#kwargsObject

Returns the value of attribute kwargs

Returns:

  • (Object)

    the current value of kwargs



13
14
15
# File 'lib/redis_client/cluster/concurrent_worker.rb', line 13

def kwargs
  @kwargs
end

#queueObject

Returns the value of attribute queue

Returns:

  • (Object)

    the current value of queue



13
14
15
# File 'lib/redis_client/cluster/concurrent_worker.rb', line 13

def queue
  @queue
end

#resultObject

Returns the value of attribute result

Returns:

  • (Object)

    the current value of result



13
14
15
# File 'lib/redis_client/cluster/concurrent_worker.rb', line 13

def result
  @result
end

Instance Method Details

#doneObject



26
27
28
29
30
# File 'lib/redis_client/cluster/concurrent_worker.rb', line 26

def done
  queue&.push(self)
rescue ClosedQueueError
  # something was wrong
end

#execObject



18
19
20
21
22
23
24
# File 'lib/redis_client/cluster/concurrent_worker.rb', line 18

def exec
  self[:result] = block&.call(*args, **kwargs)
rescue StandardError => e
  self[:result] = e
ensure
  done
end