Class: Fluent::GcloudPubSubInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_gcloud_pubsub.rb

Defined Under Namespace

Classes: FailedParseError, RPCServlet

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



105
106
107
108
109
110
111
112
113
# File 'lib/fluent/plugin/in_gcloud_pubsub.rb', line 105

def configure(conf)
  super
  @rpc_srv = nil
  @rpc_thread = nil
  @stop_pull = false

  @parser = Plugin.new_parser(@format)
  @parser.configure(conf)
end

#desc(description) ⇒ Object



15
16
# File 'lib/fluent/plugin/in_gcloud_pubsub.rb', line 15

def desc(description)
end

#shutdown ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/fluent/plugin/in_gcloud_pubsub.rb', line 130

def shutdown
  super
  if @rpc_srv
    @rpc_srv.shutdown
    @rpc_srv = nil
  end
  if @rpc_thread
    @rpc_thread.join
    @rpc_thread = nil
  end
  @stop_subscribing = true
  @subscribe_threads.each(&:join)
end

#start ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/fluent/plugin/in_gcloud_pubsub.rb', line 115

def start
  super
  start_rpc if @enable_rpc

  @subscriber = Fluent::GcloudPubSub::Subscriber.new @project, @key, @topic, @subscription
  log.debug "connected subscription:#{@subscription} in project #{@project}"

  @emit_guard = Mutex.new
  @stop_subscribing = false
  @subscribe_threads = []
  @pull_threads.times do
    @subscribe_threads.push Thread.new(&method(:subscribe))
  end
end

#start_pull ⇒ Object



149
150
151
152
# File 'lib/fluent/plugin/in_gcloud_pubsub.rb', line 149

def start_pull
  @stop_pull = false
  log.info "start pull from subscription:#{@subscription}"
end

#stop_pull ⇒ Object



144
145
146
147
# File 'lib/fluent/plugin/in_gcloud_pubsub.rb', line 144

def stop_pull
  @stop_pull = true
  log.info "stop pull from subscription:#{@subscription}"
end