lib/google_pubsub_enhancer.rb in google-pubsub-enhancer-0.1.4 vs lib/google_pubsub_enhancer.rb in google-pubsub-enhancer-0.1.5
- old
+ new
@@ -2,10 +2,11 @@
require 'middleware'
require 'google/cloud/pubsub'
class GooglePubsubEnhancer
+ require_relative 'google_pubsub_enhancer/constants'
require_relative 'google_pubsub_enhancer/middleware'
class << self
def name_by(type, name)
raise unless %w(topics subscriptions).include?(type)
@@ -31,10 +32,10 @@
end
private
def work(subscription, opts)
- while received_messages = subscription.pull
+ while received_messages = subscription.pull(:max => GooglePubsubEnhancer::Constants::MAX_PULL_SIZE)
break if opts[:shutdown].call || received_messages == nil
next if received_messages.empty?
@stack.call({received_messages: received_messages})
subscription.acknowledge(received_messages)
end