[Groonga-commit] droonga/droonga-engine at d0f59ff [master] Add droonga-engine command

Back to archive index

YUKI Hiroshi yuki****@clear*****
Thu Apr 17 10:11:33 JST 2014


 >     It is not worked yet. Sorry.

It doesn't work yet.
でよいのではないかと思いました。


Kouhei Sutou wrote:
> Author
>     Kouhei Sutou <kou �� clear-code.com>
> Date
>     2014-04-16 19:21:53 +0900 (Wed, 16 Apr 2014)
> New Revision
>     d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632 <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632>
> Message
>
>     Add droonga-engine command
>
>     It is not worked yet. Sorry.
>
> Added files
>
>       * bin/droonga-engine <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#diff-0>
>       * lib/droonga/fluent_message_receiver.rb <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#diff-1>
>
>    Added: bin/droonga-engine (+61 -0) 100755
> ===================================================================
>
> ...  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0L-1>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> 	
>
> ...  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R0>
> 1  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R1>
> 2  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R2>
> 3  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R3>
> 4  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R4>
> 5  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R5>
> 6  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R6>
> 7  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R7>
> 8  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R8>
> 9  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R9>
> 10  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R10>
> 11  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R11>
> 12  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R12>
> 13  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R13>
> 14  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R14>
> 15  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R15>
> 16  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R16>
> 17  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R17>
> 18  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R18>
> 19  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R19>
> 20  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R20>
> 21  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R21>
> 22  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R22>
> 23  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R23>
> 24  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R24>
> 25  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R25>
> 26  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R26>
> 27  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R27>
> 28  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R28>
> 29  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R29>
> 30  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R30>
> 31  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R31>
> 32  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R32>
> 33  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R33>
> 34  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R34>
> 35  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R35>
> 36  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R36>
> 37  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R37>
> 38  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R38>
> 39  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R39>
> 40  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R40>
> 41  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R41>
> 42  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R42>
> 43  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R43>
> 44  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R44>
> 45  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R45>
> 46  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R46>
> 47  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R47>
> 48  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R48>
> 49  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R49>
> 50  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R50>
> 51  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R51>
> 52  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R52>
> 53  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R53>
> 54  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R54>
> 55  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R55>
> 56  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R56>
> 57  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R57>
> 58  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R58>
> 59  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R59>
> 60  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R60>
> 61  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L0R61>
>
> 	
>
> @@ -0,0 +1,61 @@
> +#!/usr/bin/env ruby
> +#
> +# Copyright (C) 2014 Droonga Project
> +#
> +# This library is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU Lesser General Public
> +# License version 2.1 as published by the Free Software Foundation.
> +#
> +# 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> +
> +require "droonga/engine"
> +require "droonga/event_loop"
> +require "droonga/fluent_message_receiver"
> +require "droonga/plugin_loader"
> +
> +Droonga::PluginLoader.load_all
> +
> +raw_loop = Coolio::Loop.default
> +loop = Droonga::EventLoop.new(raw_loop)
> +
> +engine = Droonga::Engine.new(:name => "droonga")
> +engine.start
> +
> +receiver = Droonga::FluentMessageReceiver.new(loop) do |tag, time, record|
> +  prefix, type, *arguments = tag.split(/\./)
> +  if type.nil? or type.empty? or type == "message"
> +    message = record
> +  else
> +    message = {
> +      "type" => type,
> +      "arguments" => arguments,
> +      "body" => record
> +    }
> +  end
> +  reply_to = message["replyTo"]
> +  if reply_to.is_a? String
> +    message["replyTo"] = {
> +      "type" => "#{message["type"]}.result",
> +      "to" => reply_to
> +    }
> +  end
> +  message
> +
> +  engine.process(message)
> +end
> +receiver.start
> +
> +begin
> +  raw_loop.run
> +rescue Interrupt
> +end
> +
> +receiver.shutdown
> +engine.shutdown
>
>    Added: lib/droonga/fluent_message_receiver.rb (+191 -0) 100644
> ===================================================================
>
> ...  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1L-1>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> 	
>
> ...  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R0>
> 1  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R1>
> 2  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R2>
> 3  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R3>
> 4  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R4>
> 5  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R5>
> 6  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R6>
> 7  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R7>
> 8  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R8>
> 9  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R9>
> 10  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R10>
> 11  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R11>
> 12  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R12>
> 13  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R13>
> 14  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R14>
> 15  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R15>
> 16  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R16>
> 17  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R17>
> 18  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R18>
> 19  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R19>
> 20  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R20>
> 21  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R21>
> 22  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R22>
> 23  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R23>
> 24  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R24>
> 25  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R25>
> 26  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R26>
> 27  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R27>
> 28  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R28>
> 29  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R29>
> 30  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R30>
> 31  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R31>
> 32  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R32>
> 33  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R33>
> 34  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R34>
> 35  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R35>
> 36  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R36>
> 37  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R37>
> 38  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R38>
> 39  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R39>
> 40  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R40>
> 41  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R41>
> 42  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R42>
> 43  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R43>
> 44  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R44>
> 45  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R45>
> 46  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R46>
> 47  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R47>
> 48  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R48>
> 49  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R49>
> 50  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R50>
> 51  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R51>
> 52  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R52>
> 53  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R53>
> 54  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R54>
> 55  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R55>
> 56  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R56>
> 57  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R57>
> 58  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R58>
> 59  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R59>
> 60  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R60>
> 61  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R61>
> 62  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R62>
> 63  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R63>
> 64  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R64>
> 65  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R65>
> 66  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R66>
> 67  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R67>
> 68  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R68>
> 69  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R69>
> 70  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R70>
> 71  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R71>
> 72  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R72>
> 73  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R73>
> 74  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R74>
> 75  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R75>
> 76  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R76>
> 77  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R77>
> 78  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R78>
> 79  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R79>
> 80  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R80>
> 81  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R81>
> 82  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R82>
> 83  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R83>
> 84  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R84>
> 85  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R85>
> 86  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R86>
> 87  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R87>
> 88  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R88>
> 89  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R89>
> 90  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R90>
> 91  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R91>
> 92  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R92>
> 93  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R93>
> 94  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R94>
> 95  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R95>
> 96  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R96>
> 97  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R97>
> 98  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R98>
> 99  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R99>
> 100  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R100>
> 101  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R101>
> 102  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R102>
> 103  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R103>
> 104  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R104>
> 105  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R105>
> 106  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R106>
> 107  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R107>
> 108  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R108>
> 109  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R109>
> 110  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R110>
> 111  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R111>
> 112  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R112>
> 113  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R113>
> 114  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R114>
> 115  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R115>
> 116  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R116>
> 117  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R117>
> 118  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R118>
> 119  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R119>
> 120  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R120>
> 121  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R121>
> 122  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R122>
> 123  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R123>
> 124  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R124>
> 125  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R125>
> 126  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R126>
> 127  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R127>
> 128  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R128>
> 129  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R129>
> 130  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R130>
> 131  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R131>
> 132  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R132>
> 133  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R133>
> 134  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R134>
> 135  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R135>
> 136  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R136>
> 137  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R137>
> 138  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R138>
> 139  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R139>
> 140  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R140>
> 141  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R141>
> 142  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R142>
> 143  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R143>
> 144  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R144>
> 145  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R145>
> 146  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R146>
> 147  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R147>
> 148  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R148>
> 149  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R149>
> 150  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R150>
> 151  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R151>
> 152  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R152>
> 153  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R153>
> 154  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R154>
> 155  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R155>
> 156  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R156>
> 157  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R157>
> 158  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R158>
> 159  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R159>
> 160  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R160>
> 161  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R161>
> 162  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R162>
> 163  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R163>
> 164  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R164>
> 165  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R165>
> 166  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R166>
> 167  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R167>
> 168  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R168>
> 169  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R169>
> 170  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R170>
> 171  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R171>
> 172  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R172>
> 173  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R173>
> 174  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R174>
> 175  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R175>
> 176  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R176>
> 177  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R177>
> 178  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R178>
> 179  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R179>
> 180  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R180>
> 181  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R181>
> 182  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R182>
> 183  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R183>
> 184  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R184>
> 185  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R185>
> 186  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R186>
> 187  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R187>
> 188  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R188>
> 189  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R189>
> 190  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R190>
> 191  <https://github.com/droonga/droonga-engine/commit/d0f59ff4b3cefad2f5d79ea8c495b1ede98ad632#L1R191>
>
> 	
>
> @@ -0,0 +1,191 @@
> +# Copyright (C) 2014 Droonga Project
> +#
> +# This library is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU Lesser General Public
> +# License version 2.1 as published by the Free Software Foundation.
> +#
> +# 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> +
> +require "socket"
> +require "ipaddr"
> +
> +require "msgpack"
> +
> +require "droonga/loggable"
> +require "droonga/event_loop"
> +
> +module Droonga
> +  class FluentMessageReceiver
> +    include Loggable
> +
> +    def initialize(loop, options={}, &on_message)
> +      @loop = loop
> +      @host = options[:host] || "0.0.0.0"
> +      @port = options[:port] || 24224
> +      @server = nil
> +      @clients = []
> +      @on_message = on_message
> +    end
> +
> +    def start
> +      logger.trace("start: start")
> +      start_heartbeat_receiver
> +      start_server
> +      logger.trace("start: done")
> +    end
> +
> +    def shutdown
> +      logger.trace("shutdown: start")
> +      shutdown_server
> +      shutdown_clients
> +      shutdown_heartbeat_receiver
> +      logger.trace("shutdown: done")
> +    end
> +
> +    private
> +    def start_heartbeat_receiver
> +      logger.trace("start_heartbeat_receiver: start")
> +      @heartbeat_receiver = HeartbeatReceiver.new(@loop, @host, @port)
> +      @heartbeat_receiver.start
> +      logger.trace("start_heartbeat_receiver: done")
> +    end
> +
> +    def shutdown_heartbeat_receiver
> +      logger.trace("shutdown_heartbeat_receiver: start")
> +      @heartbeat_receiver.shutdown
> +      logger.trace("shutdown_heartbeat_receiver: done")
> +    end
> +
> +    def start_server
> +      logger.trace("start_server: start")
> +
> +      @clients = []
> +      @server = Coolio::TCPServer.new(@host, @port) do |connection|
> +        client = Client.new(connection) do |tag, time, record|
> +          @on_message.call(tag, time, record)
> +        end
> +        @clients << client
> +      end
> +      @loop.attach(@server)
> +
> +      logger.trace("start_server: done")
> +    end
> +
> +    def shutdown_server
> +      @server.close
> +    end
> +
> +    def shutdown_clients
> +      @clients.each do |client|
> +        client.close
> +      end
> +    end
> +
> +    def log_tag
> +      "fluent-message-receiver"
> +    end
> +
> +    class HeartbeatReceiver
> +      def initialize(loop, host, port)
> +        @loop = loop
> +        @host = host
> +        @port = port
> +      end
> +
> +      def start
> +        @socket = UDPSocket.new(address_family)
> +        @socket.bind(@host, @port)
> +
> +        @watcher = Coolio::IOWatcher.new(@socket, "r")
> +        on_readable = lambda do
> +          receive_heartbeat
> +        end
> +        @watcher.on_readable do
> +          on_readable.call
> +        end
> +        @loop.attach(@watcher)
> +      end
> +
> +      def shutdown
> +        @watcher.detach
> +        @socket.close
> +      end
> +
> +      private
> +      def address_family
> +        ip_address = IPAddr.new(IPSocket.getaddress(@host))
> +        ip_address.family
> +      end
> +
> +      def receive_heartbeat
> +        address = nil
> +        begin
> +          _, address =****@socke*****(1024)
> +        rescue SystamCallError
> +          return
> +        end
> +
> +        host = address[3]
> +        port = address[1]
> +        send_back_heartbeat(host, port)
> +      end
> +
> +      def send_back_heartbeat(host, port)
> +        data = "\0"
> +        flags = 0
> +        begin
> +          @socket.send(data, flags, host, port)
> +        rescue SystemCallError
> +        end
> +      end
> +    end
> +
> +    class Client
> +      include Loggable
> +
> +      def initialize(io, &on_message)
> +        @io = io
> +        @on_message = on_message
> +        @unpacker = MessagePack::Unpacker.new
> +        on_read = lambda do |data|
> +          feed(data)
> +        end
> +        @io.on_read do |data|
> +          on_read.call(data)
> +        end
> +      end
> +
> +      private
> +      def feed(data)
> +        @unpacker.feed_each(data) do |object|
> +          tag = object[0]
> +          case object[1]
> +          when String # PackedForward message
> +            entries = MessagePack.unpack(object[1])
> +          when Array # Forward message
> +            entries = object[1]
> +          when Integer # Message message
> +            entries = [[object[1], object[2]]]
> +          else
> +            logger.error("unknown message", :message => object)
> +            next
> +          end
> +          entries.each do |time, record|
> +            @on_message.call(tag, time || Time.now.to_i, record)
> +          end
> +        end
> +      end
> +
> +      def log_tag
> +        "fluent-message-receiver::client"
> +      end
> +    end
> +  end
> +end
>
>
>
> _______________________________________________
> Groonga-commit mailing list
> Groonga-commit �� lists.sourceforge.jp
> http://lists.sourceforge.jp/mailman/listinfo/groonga-commit
>

-- 
結城 洋志 <YUKI Hiroshi>
E-mail: yuki �� clear-code.com

株式会社クリアコード
〒113-0033 東京都文京区本郷3-27-12
            本郷デントビル2階
TEL : 03-6231-7270
FAX : 03-6231-7271
WWW : http://www.clear-code.com/




More information about the Groonga-commit mailing list
Back to archive index