Class: Fluent::GcloudPubSub::Subscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/gcloud_pubsub/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(project, key, topic, subscription) ⇒ Subscriber

Returns a new instance of Subscriber.



25
26
27
28
29
30
# File 'lib/fluent/plugin/gcloud_pubsub/client.rb', line 25

def initialize(project, key, topic, subscription)
  pubsub = (Google::Cloud.new project, key).pubsub
  topic = pubsub.topic topic
  @client = topic.subscription subscription
  raise Fluent::GcloudPubSub::Error.new "subscription:#{subscription} does not exist." if @client.nil?
end

Instance Method Details

#acknowledge(messages) ⇒ Object



36
37
38
# File 'lib/fluent/plugin/gcloud_pubsub/client.rb', line 36

def acknowledge(messages)
  @client.acknowledge messages
end

#pull(immediate, max) ⇒ Object



32
33
34
# File 'lib/fluent/plugin/gcloud_pubsub/client.rb', line 32

def pull(immediate, max)
  @client.pull immediate: immediate, max: max
end