class Fluent::GcloudPubSubOutput
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_gcloud_pubsub.rb, line 28 def configure(conf) super raise Fluent::ConfigError, "'topic' must be specified." unless @topic end
format(tag, time, record)
click to toggle source
# File lib/fluent/plugin/out_gcloud_pubsub.rb, line 41 def format(tag, time, record) [tag, time, record].to_msgpack end
start()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_gcloud_pubsub.rb, line 34 def start super pubsub = (Gcloud.new @project, @key).pubsub @client = pubsub.topic @topic, autocreate: @autocreate_topic end
write(chunk)
click to toggle source
# File lib/fluent/plugin/out_gcloud_pubsub.rb, line 45 def write(chunk) messages = [] chunk.msgpack_each do |tag, time, record| messages << record.to_json end if messages.length > 0 @client.publish do |batch| messages.each do |m| batch.publish m end end end rescue => e log.error "unexpected error", :error=>$!.to_s log.error_backtrace raise e end