droonga-client 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ffd6d3d2d200ed371e9796d222810204d63fe573
4
+ data.tar.gz: dd0ccbf7334fc5f1d17f609c038441cad708fcee
5
+ SHA512:
6
+ metadata.gz: e08a13f2c2bad4374bec11b277d88b595f3384ee271a8506fa248d29ab493ecbb60e2435c6889a1f5327b30c169ec805816a3f14622129aee2bed75c9c229a07
7
+ data.tar.gz: de0d11dd6ac42a60dde0821cdc706a2d63b99d5396c60849c077d5ec99b31e3976372fb2abfb3c628610522973e1612e31bdbaaf8b89fcf6f3f08bf580d8c8e1
data/bin/droonga-request CHANGED
@@ -23,7 +23,7 @@ require "droonga/client"
23
23
 
24
24
  options = {
25
25
  :host => "localhost",
26
- :port => 24224,
26
+ :port => 10031,
27
27
  :tag => "droonga",
28
28
  :protocol => :droonga,
29
29
  :timeout => 1,
@@ -35,6 +35,7 @@ options = {
35
35
  }
36
36
 
37
37
  parser = OptionParser.new
38
+ parser.version = Droonga::Client::VERSION
38
39
  parser.banner += " REQUEST_JSON_FILE"
39
40
  parser.separator("")
40
41
  parser.separator("Connect:")
data/bin/droonga-send CHANGED
@@ -27,7 +27,7 @@ options.report_request = false
27
27
  options.report_throughput = false
28
28
 
29
29
  servers = []
30
- default_server = "droonga:localhost:24224/droonga"
30
+ default_server = "droonga:localhost:10031/droonga"
31
31
  messages_per_second = Droonga::Client::RateLimiter::NO_LIMIT
32
32
 
33
33
  def parse_server(server)
@@ -73,6 +73,7 @@ class ThroughputReporter
73
73
  end
74
74
 
75
75
  parser = OptionParser.new
76
+ parser.version = Droonga::Client::VERSION
76
77
  parser.banner += " REQUEST_JSON_FILE1 REQUEST_JSON_FILE2 ..."
77
78
  parser.separator("")
78
79
  parser.separator("Connection:")
data/doc/text/news.md CHANGED
@@ -1,8 +1,13 @@
1
1
  # News
2
2
 
3
- ## 0.1.6: 2014-04-29 (planned)
3
+ ## 0.1.7: 2014-05-29
4
4
 
5
- * Supports droonga's protocol.
5
+ * Updated the default port number, same to `droonga-engine`'s one.
6
+
7
+ ## 0.1.6: 2014-04-29
8
+
9
+ * Supports Droonga's protocol.
10
+ * Used "Cool.io" backend for Droonga protocol.
6
11
 
7
12
  ## 0.1.5: 2014-03-29
8
13
 
@@ -47,14 +47,46 @@ module Droonga
47
47
  end
48
48
 
49
49
  class Sender < ::Coolio::TCPSocket
50
- def initialize(socket)
51
- super(socket)
50
+ def initialize(*args)
51
+ super
52
+ @connected = false
53
+ @failed_to_connect = false
54
+ @buffer = []
52
55
  end
53
56
 
54
- def send(tag, data)
57
+ def close
58
+ return if @failed_to_connect
59
+ super
60
+ end
61
+
62
+ def send(tag, data, &on_error)
63
+ if @failed_to_connect
64
+ on_error.call(data)
65
+ end
55
66
  fluent_message = [tag, Time.now.to_i, data]
56
67
  packed_fluent_message = MessagePackPacker.pack(fluent_message)
57
- write(packed_fluent_message)
68
+ if @connected
69
+ write(packed_fluent_message)
70
+ else
71
+ @buffer << [packed_fluent_message, on_error]
72
+ end
73
+ end
74
+
75
+ def on_connect
76
+ @connected = true
77
+ @buffer.each do |packed_message,|
78
+ write(packed_message)
79
+ end
80
+ @buffer.clear
81
+ end
82
+
83
+ def on_connect_failed
84
+ @failed_to_connect = true
85
+ @buffer.each do |packed_message, on_error|
86
+ _, _, message = MessagePack.unpack(packed_message)
87
+ on_error.call(message)
88
+ end
89
+ @buffer.clear
58
90
  end
59
91
  end
60
92
 
@@ -70,10 +102,10 @@ module Droonga
70
102
 
71
103
  def close
72
104
  super
73
- @engines.each do |engine|
105
+ engines = @engines.dup
106
+ engines.each do |engine|
74
107
  engine.close
75
108
  end
76
- @engines.clear
77
109
  end
78
110
 
79
111
  def host
@@ -154,7 +186,9 @@ module Droonga
154
186
  id = message["id"] || generate_id
155
187
  message = message.merge("id" => id,
156
188
  "replyTo" => @receiver.droonga_name)
157
- send(message, options)
189
+ send(message, options) do |error|
190
+ yield(error)
191
+ end
158
192
 
159
193
  sync = block.nil?
160
194
  if sync
@@ -179,8 +213,11 @@ module Droonga
179
213
  def subscribe(message, options={}, &block)
180
214
  id = message["id"] || generate_id
181
215
  message = message.merge("id" => id,
216
+ "replyTo" => @receiver.droonga_name,
182
217
  "from" => @receiver.droonga_name)
183
- send(message, options)
218
+ send(message, options) do |error|
219
+ yield(error)
220
+ end
184
221
 
185
222
  request = InfiniteRequest.new(@loop)
186
223
  sync = block.nil?
@@ -213,7 +250,13 @@ module Droonga
213
250
  date = message["date"] || Time.now
214
251
  message = message.merge("id" => id, "date" => date)
215
252
  end
216
- @sender.send("#{@tag}.message", message)
253
+ @sender.send("#{@tag}.message", message) do
254
+ host = @sender.peeraddr[3]
255
+ port = @sender.peeraddr[1]
256
+ detail = message
257
+ error = ConnectionError.new(host, port, detail)
258
+ yield(error)
259
+ end
217
260
  end
218
261
 
219
262
  def close
@@ -72,8 +72,10 @@ module Droonga
72
72
 
73
73
  def subscribe(message, options={}, &block)
74
74
  receiver = create_receiver
75
+ receive_end_point = "#{receiver.host}:#{receiver.port}/droonga"
75
76
  message = message.dup
76
- message["from"] = "#{receiver.host}:#{receiver.port}/droonga"
77
+ message["replyTo"] = receive_end_point
78
+ message["from"] = receive_end_point
77
79
  send(message, options)
78
80
 
79
81
  receive_options = {
@@ -33,6 +33,18 @@ module Droonga
33
33
  super("Unknown #{@protocol} backend: <#{backend}>: #{detail}")
34
34
  end
35
35
  end
36
+
37
+ class ConnectionError < Error
38
+ attr_reader :host
39
+ attr_reader :port
40
+ attr_reader :detail
41
+ def initialize(host, port, detail)
42
+ @host = host
43
+ @port = port
44
+ @detail = detail
45
+ super("Failed to connect: <#{@host}:#{@port}>: #{@detail}")
46
+ end
47
+ end
36
48
  end
37
49
  end
38
50
  end
@@ -17,6 +17,6 @@
17
17
 
18
18
  module Droonga
19
19
  class Client
20
- VERSION = "0.1.6"
20
+ VERSION = "0.1.7"
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,104 +1,127 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: droonga-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
5
- prerelease:
4
+ version: 0.1.7
6
5
  platform: ruby
7
6
  authors:
8
7
  - Droonga Project
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-04-28 00:00:00.000000000 Z
11
+ date: 2014-05-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: msgpack
16
- requirement: &76464960 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *76464960
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: fluent-logger
27
- requirement: &76464730 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - '>='
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *76464730
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: rack
38
- requirement: &76464520 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ! '>='
45
+ - - '>='
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0'
44
48
  type: :runtime
45
49
  prerelease: false
46
- version_requirements: *76464520
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: yajl-ruby
49
- requirement: &76464310 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
- - - ! '>='
59
+ - - '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  type: :runtime
56
63
  prerelease: false
57
- version_requirements: *76464310
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: droonga-message-pack-packer
60
- requirement: &76464100 !ruby/object:Gem::Requirement
61
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
62
72
  requirements:
63
- - - ! '>='
73
+ - - '>='
64
74
  - !ruby/object:Gem::Version
65
75
  version: '0'
66
76
  type: :runtime
67
77
  prerelease: false
68
- version_requirements: *76464100
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
- requirement: &76463850 !ruby/object:Gem::Requirement
72
- none: false
85
+ requirement: !ruby/object:Gem::Requirement
73
86
  requirements:
74
87
  - - ~>
75
88
  - !ruby/object:Gem::Version
76
89
  version: '1.3'
77
90
  type: :development
78
91
  prerelease: false
79
- version_requirements: *76463850
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '1.3'
80
97
  - !ruby/object:Gem::Dependency
81
98
  name: rake
82
- requirement: &76463640 !ruby/object:Gem::Requirement
83
- none: false
99
+ requirement: !ruby/object:Gem::Requirement
84
100
  requirements:
85
- - - ! '>='
101
+ - - '>='
86
102
  - !ruby/object:Gem::Version
87
103
  version: '0'
88
104
  type: :development
89
105
  prerelease: false
90
- version_requirements: *76463640
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
91
111
  - !ruby/object:Gem::Dependency
92
112
  name: packnga
93
- requirement: &76463410 !ruby/object:Gem::Requirement
94
- none: false
113
+ requirement: !ruby/object:Gem::Requirement
95
114
  requirements:
96
- - - ! '>='
115
+ - - '>='
97
116
  - !ruby/object:Gem::Version
98
117
  version: '0'
99
118
  type: :development
100
119
  prerelease: false
101
- version_requirements: *76463410
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
102
125
  description: Droonga client for Ruby
103
126
  email:
104
127
  - droonga@groonga.org
@@ -131,27 +154,26 @@ files:
131
154
  homepage: https://github.com/droonga/droonga-client-ruby
132
155
  licenses:
133
156
  - LGPL-2.1
157
+ metadata: {}
134
158
  post_install_message:
135
159
  rdoc_options: []
136
160
  require_paths:
137
161
  - lib
138
162
  required_ruby_version: !ruby/object:Gem::Requirement
139
- none: false
140
163
  requirements:
141
- - - ! '>='
164
+ - - '>='
142
165
  - !ruby/object:Gem::Version
143
166
  version: 1.9.3
144
167
  required_rubygems_version: !ruby/object:Gem::Requirement
145
- none: false
146
168
  requirements:
147
- - - ! '>='
169
+ - - '>='
148
170
  - !ruby/object:Gem::Version
149
171
  version: '0'
150
172
  requirements: []
151
173
  rubyforge_project:
152
- rubygems_version: 1.8.11
174
+ rubygems_version: 2.0.14
153
175
  signing_key:
154
- specification_version: 3
176
+ specification_version: 4
155
177
  summary: Droonga client for Ruby
156
178
  test_files: []
157
179
  has_rdoc: