Class: Fluent::GcloudPubSubOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::GcloudPubSubOutput
- Defined in:
- lib/fluent/plugin/out_gcloud_pubsub.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Instance Method Details
#configure(conf) ⇒ Object
25 26 27 28 29 |
# File 'lib/fluent/plugin/out_gcloud_pubsub.rb', line 25 def configure(conf) super @formatter = Plugin.new_formatter(@format) @formatter.configure(conf) end |
#format(tag, time, record) ⇒ Object
37 38 39 |
# File 'lib/fluent/plugin/out_gcloud_pubsub.rb', line 37 def format(tag, time, record) [tag, time, record].to_msgpack end |
#start ⇒ Object
31 32 33 34 35 |
# File 'lib/fluent/plugin/out_gcloud_pubsub.rb', line 31 def start super @publisher = Fluent::GcloudPubSub::Publisher.new @project, @key, @topic, @autocreate_topic log.debug "connected topic:#{@topic} in project #{@project}" end |
#write(chunk) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fluent/plugin/out_gcloud_pubsub.rb', line 41 def write(chunk) = [] size = 0 chunk.msgpack_each do |tag, time, record| msg = @formatter.format(tag, time, record) if .length + 1 > || size + msg.bytesize > @max_total_size publish = [] size = 0 end << msg size += msg.bytesize end if .length > 0 publish end rescue => e log.error "unexpected error", :error=>$!.to_s log.error_backtrace raise e end |