lib/poseidon/consumer_group.rb
# Checks out a single partition consumer. Round-robins between claimed partitions.
#
# @yield [consumer] The processing block
# @yieldparam [Consumer] consumer The consumer instance
# @yieldreturn [Boolean] return false to stop auto-commit
#
# @param [Hash] opts
# @option opts [Boolean] :commit Automatically commit consumer offset (default: true)
# @return [Boolean] true if a consumer was checked out, false if none could be claimed
#
# @example
#
#   ok = group.checkout do |consumer|
#     puts "Checked out consumer for partition #{consumer.partition}"
#   end
#   ok # => true if the block was run, false otherwise
#
# @api public
Checks out a single partition consumer. Round-robins between claimed partitions.
Checks out a single partition consumer . Round - robins between claimed partitions .
def checkout(opts = {})
    consumer = nil
    commit   = @mutex.synchronize do
      consumer = @consumers.shift
      return false unless consumer
      @consumers.push consumer
      yield consumer
    end
    unless opts[:commit] == false || commit == false
      commit consumer.partition, consumer.offset
    end
    true
  end
def checkout ( opts = { } ) consumer = nil commit = @mutex . synchronize do consumer = @consumers . shift return false unless consumer @consumers . push consumer yield consumer end unless opts [ :commit ] == false || commit == false commit consumer . partition , consumer . offset end true end
Checks out a single partition consumer.
Checks out a single partition consumer .
return false to stop auto-commit
return false to stop auto - commit
Boolean
true if a consumer was checked out, false if none could be claimed
true if a consumer was checked out false if none could be claimed
Boolean
opts
:commit Automatically commit consumer offset (default: true)
: commit Automatically commit consumer offset ( default : true )
]
<not_specific>
The processing block
The processing block
<not_specific>
None
example
ok = group.checkout do |consumer| puts "Checked out consumer for partition #{consumer.partition}" end ok # => true if the block was run, false otherwise
ok = group . checkout do |consumer| puts " Checked out consumer for partition # { consumer . partition } " end ok # = > true if the block was run false otherwise
api
None