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.



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

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

Instance Method Details

#acknowledge(messages) ⇒ Object



41
42
43
# File 'lib/fluent/plugin/gcloud_pubsub/client.rb', line 41

def acknowledge(messages)
  @client.acknowledge messages
end

#pull(immediate, max) ⇒ Object



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

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