class Fluent::Plugin::GcloudPubSubInput::RPCServlet
Public Class Methods
new(server, plugin)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_gcloud_pubsub.rb, line 64 def initialize(server, plugin) super @plugin = plugin end
Public Instance Methods
do_GET(req, res)
click to toggle source
# File lib/fluent/plugin/in_gcloud_pubsub.rb, line 69 def do_GET(req, res) begin code, header, body = process(req, res) rescue code, header, body = render_json(500, { 'ok' => false, 'message' => 'Internal Server Error', 'error' => "#{$!}", 'backtrace'=> $!.backtrace }) end res.status = code header.each_pair {|k,v| res[k] = v } res.body = body end
process(req, res)
click to toggle source
# File lib/fluent/plugin/in_gcloud_pubsub.rb, line 92 def process(req, res) ret = {'ok' => true} case req.path_info when '/stop' @plugin.stop_pull when '/start' @plugin.start_pull when '/status' ret['status'] = @plugin.status_of_pull else raise Error.new "Invalid path_info: #{req.path_info}" end render_json(200, ret) end
render_json(code, obj)
click to toggle source
# File lib/fluent/plugin/in_gcloud_pubsub.rb, line 88 def render_json(code, obj) [code, {'Content-Type' => 'application/json'}, obj.to_json] end