Kouhei Sutou
null+****@clear*****
Tue May 21 18:59:26 JST 2013
Kouhei Sutou 2013-05-21 18:59:26 +0900 (Tue, 21 May 2013) New Revision: 67bd7e4d52e4551a343b86824d99f2df802fc774 https://github.com/groonga/groonga-query-log/commit/67bd7e4d52e4551a343b86824d99f2df802fc774 Message: Add a script that replyas queries in query log It is just work for now. We need more work. For example: * Support XML output * Support concurrent requests * Support server address customize * ... Added files: lib/groonga/query-log/replayer.rb Copied files: bin/groonga-query-log-replay (from lib/groonga/query-log.rb) Modified files: lib/groonga/query-log.rb Copied: bin/groonga-query-log-replay (+6 -5) 78% Mode: 100644 -> 100755 =================================================================== --- lib/groonga/query-log.rb 2013-05-21 17:06:57 +0900 (a731150) +++ bin/groonga-query-log-replay 2013-05-21 18:59:26 +0900 (24d57c8) @@ -1,6 +1,7 @@ +#!/usr/bin/env ruby # -*- coding: utf-8 -*- # -# Copyright (C) 2012 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2013 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -16,7 +17,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "groonga/query-log/version" -require "groonga/query-log/analyzer" -require "groonga/query-log/extractor" -require "groonga/query-log/parser" +require "groonga/query-log" + +replayer = Groonga::QueryLog::Replayer.new +replayer.replay(ARGF) Modified: lib/groonga/query-log.rb (+1 -0) =================================================================== --- lib/groonga/query-log.rb 2013-05-21 17:06:57 +0900 (a731150) +++ lib/groonga/query-log.rb 2013-05-21 18:59:26 +0900 (3524c0a) @@ -20,3 +20,4 @@ require "groonga/query-log/version" require "groonga/query-log/analyzer" require "groonga/query-log/extractor" require "groonga/query-log/parser" +require "groonga/query-log/replayer" Added: lib/groonga/query-log/replayer.rb (+57 -0) 100644 =================================================================== --- /dev/null +++ lib/groonga/query-log/replayer.rb 2013-05-21 18:59:26 +0900 (4bac3b1) @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 Kouhei Sutou <kou �� clear-code.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "groonga/client" + +require "groonga/query-log/parser" + +module Groonga + module QueryLog + class Replayer + attr_accessor :host + attr_accessor :port + attr_accessor :protocol + def initialize + @host = "127.0.0.1" + @port = 10041 + @protocol = :gqtp + end + + def replay(input) + create_client do |client| + parser = Parser.new + parser.parse(input) do |statistic| + replay_command(client, statistic.command) + end + end + end + + private + def create_client(&block) + Groonga::Client.open(:host => @host, + :port => @port, + :protocol => @protocol, + &block) + end + + def replay_command(client, command) + p client.execute(command) + end + end + end +end -------------- next part -------------- HTML����������������������������... Télécharger