Kouhei Sutou
null+****@clear*****
Mon Apr 24 17:44:25 JST 2017
Kouhei Sutou 2017-04-24 17:44:25 +0900 (Mon, 24 Apr 2017) New Revision: 8c4bb6b1721ffd011a5eb0c9b441ff15b0014671 https://github.com/groonga/fluent-plugin-groonga/commit/8c4bb6b1721ffd011a5eb0c9b441ff15b0014671 Message: Support multi workers Modified files: lib/fluent/plugin/in_groonga.rb lib/fluent/plugin/out_groonga.rb test/test_input.rb test/test_output.rb Modified: lib/fluent/plugin/in_groonga.rb (+5 -0) =================================================================== --- lib/fluent/plugin/in_groonga.rb 2017-04-24 17:06:20 +0900 (74ccdd8) +++ lib/fluent/plugin/in_groonga.rb 2017-04-24 17:44:25 +0900 (d595cc6) @@ -58,6 +58,7 @@ module Fluent server_create_connection(:groonga_input, port, :proto => :tcp, + :shared => system_config.workers > 1, :bind => bind) do |connection| handler = nil real_host =****@input*****_host @@ -89,6 +90,10 @@ module Fluent super end + def multi_workers_ready? + true + end + class Repeater < Coolio::TCPSocket def initialize(socket, handler) super(socket) Modified: lib/fluent/plugin/out_groonga.rb (+4 -0) =================================================================== --- lib/fluent/plugin/out_groonga.rb 2017-04-24 17:06:20 +0900 (3e0349b) +++ lib/fluent/plugin/out_groonga.rb 2017-04-24 17:44:25 +0900 (160bcf2) @@ -105,6 +105,10 @@ module Fluent @client.shutdown end + def multi_workers_ready? + true + end + def format(tag, time, record) [tag, time, record].to_msgpack end Modified: test/test_input.rb (+26 -17) =================================================================== --- test/test_input.rb 2017-04-24 17:06:20 +0900 (ed79018) +++ test/test_input.rb 2017-04-24 17:44:25 +0900 (744e10e) @@ -19,9 +19,9 @@ require "net/http" require "webrick/config" require "webrick/httpresponse" -require "fluent/plugin/in_groonga" +require "fluent/test/driver/input" -require "http_parser" +require "fluent/plugin/in_groonga" class GroongaInputTest < Test::Unit::TestCase setup :before => :append @@ -33,7 +33,7 @@ class GroongaInputTest < Test::Unit::TestCase private def create_driver - driver = Fluent::Test::InputTestDriver.new(Fluent::Plugin::GroongaInput) + driver = Fluent::Test::Driver::Input.new(Fluent::Plugin::GroongaInput) driver.configure(configuration) driver end @@ -100,16 +100,21 @@ EOC def test_target_command @real_response["Content-Type"] = "application/json" @real_response.body = JSON.generate([[0, 0.0, 0.0], true]) - @driver.expect_emit("groonga.command.table_create", - @now, - { - "name" => "Users", - "flags" => "TABLE_NO_KEY", - }) @driver.run do get("/d/table_create", "name" => "Users", "flags" => "TABLE_NO_KEY") assert_equal("200", @last_response.code) end + assert_equal([ + [ + "groonga.command.table_create", + @now, + { + "name" => "Users", + "flags" => "TABLE_NO_KEY", + }, + ] + ], + @driver.events) end def test_not_target_command @@ -117,7 +122,7 @@ EOC get("/d/status") assert_equal("200", @last_response.code) end - assert_empty(@driver.emits) + assert_empty(@driver.events) end def test_load @@ -129,17 +134,21 @@ EOC {"name": "Bob"} ] EOJ - @driver.expect_emit("groonga.command.load", - @now, - { - "table" => "Users", - "values" => json, - }) - @driver.run do post("/d/load", json, "table" => "Users") assert_equal("200", @last_response.code) end + assert_equal([ + [ + "groonga.command.load", + @now, + { + "table" => "Users", + "values" => json, + }, + ], + ], + @driver.events) end def test_not_command Modified: test/test_output.rb (+1 -2) =================================================================== --- test/test_output.rb 2017-04-24 17:06:20 +0900 (1221340) +++ test/test_output.rb 2017-04-24 17:44:25 +0900 (c6ec6fd) @@ -20,9 +20,8 @@ require "webrick/config" require "webrick/httpresponse" require "fluent/test/driver/output" -require "fluent/plugin/out_groonga" -require "http_parser" +require "fluent/plugin/out_groonga" class GroongaOutputTest < Test::Unit::TestCase setup :before => :append -------------- next part -------------- HTML����������������������������... Download