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 66 def initialize(server, plugin) super @plugin = plugin end
Public Instance Methods
do_GET(req, res)
click to toggle source
rubocop:disable Naming/MethodName
# File lib/fluent/plugin/in_gcloud_pubsub.rb, line 72 def do_GET(req, res) begin code, header, body = process(req, res) rescue StandardError code, header, body = render_json(500, { "ok" => false, "message" => "Internal Server Error", "error" => $ERROR_INFO.to_s, "backtrace" => $ERROR_INFO.backtrace, }) end res.status = code header.each_pair do |k, v| res[k] = v end res.body = body end
process(req, _res)
click to toggle source
# File lib/fluent/plugin/in_gcloud_pubsub.rb, line 96 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, "Invalid path_info: #{req.path_info}" end render_json(200, ret) end
render_json(code, obj)
click to toggle source
rubocop:enable Naming/MethodName
# File lib/fluent/plugin/in_gcloud_pubsub.rb, line 92 def render_json(code, obj) [code, { "Content-Type" => "application/json" }, obj.to_json] end