Kouhei Sutou
null+****@clear*****
Mon Jan 20 10:56:53 JST 2014
Kouhei Sutou 2014-01-20 10:56:53 +0900 (Mon, 20 Jan 2014) New Revision: 5f16b46e885b70955e9afe45aa087368ee8409cc https://github.com/droonga/droonga-client-ruby/commit/5f16b46e885b70955e9afe45aa087368ee8409cc Message: http: assume that the published messages are JSONs Modified files: droonga-client.gemspec lib/droonga/client/connection/http.rb Modified: droonga-client.gemspec (+1 -0) =================================================================== --- droonga-client.gemspec 2014-01-20 10:28:09 +0900 (0658452) +++ droonga-client.gemspec 2014-01-20 10:56:53 +0900 (5487031) @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency "msgpack" spec.add_runtime_dependency "fluent-logger" spec.add_runtime_dependency "rack" + spec.add_runtime_dependency "yajl" spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "rake" Modified: lib/droonga/client/connection/http.rb (+7 -1) =================================================================== --- lib/droonga/client/connection/http.rb 2014-01-20 10:28:09 +0900 (c61f580) +++ lib/droonga/client/connection/http.rb 2014-01-20 10:56:53 +0900 (1eee188) @@ -18,6 +18,8 @@ require "thread" require "rack" +require "yajl" + module Droonga class Client module Connection @@ -96,8 +98,12 @@ module Droonga # @return [Request] The request object. def subscribe(message, options={}, &block) thread = Thread.new do + json_parser = Yajl::Parser.new + json_parser.on_parse_complete = block send(message, options.merge(:read_timeout => nil)) do |response| - response.read_body(&block) + response.read_body do |chunk| + json_parser << chunk + end end end Request.new(thread) -------------- next part -------------- HTML����������������������������...Descargar