droonga-client 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f75dd4c556d84c4e966646bc997a2572a4ca1fd
4
- data.tar.gz: 3b34c387045228fde45119808abc0044baeb8599
3
+ metadata.gz: b93424bbf1204f04881870bed8343e65072ee30f
4
+ data.tar.gz: 264ed3acb88d12ae24c6828f31c1f056bca0b1cf
5
5
  SHA512:
6
- metadata.gz: fb76c805ec407b17f4d6d920c6dc7c59858cb41c038d41a5d48609d90d895c854380856fa0ac2918a967749fa0b4bf676bf1d35fedc6f52b6e693602939adcdb
7
- data.tar.gz: 267a919cb82b3e9a3ae5b948dd700137556dc3f13d5158d5307ca167c4805638795219760f34b066993a9a14d2d39149df39b35597f6cb6cd27c23424bc81260
6
+ metadata.gz: 9b7558962c63b1faa32cc1717abd224cfe8d4fdfa41723c5186914cf70421ee6ebd66df4b12a94cbaf43cb4cc837eb4124f5294d7810032a3efcb2636c516782
7
+ data.tar.gz: 1308a45eaeb3a71d269d45a1c17aa0bf3629fffc83c3f10f112d7bbbd4d69e65e1ecd90b9d881845011d13ed70b7bb185af4c43432f40d0a7e048898e8e60bc1
data/bin/droonga-send CHANGED
@@ -25,14 +25,33 @@ require "droonga/client"
25
25
  options = OpenStruct.new
26
26
  options.report_request = false
27
27
  options.report_throughput = false
28
+ options.default_protocol = "droonga"
29
+ options.default_port = 10031
30
+ options.default_tag = "droonga"
28
31
 
29
32
  servers = []
30
33
  default_server = "droonga:localhost:10031/droonga"
31
34
  messages_per_second = Droonga::Client::RateLimiter::NO_LIMIT
32
35
 
33
- def parse_server(server)
34
- connect_info, tag = server.split(/\//, 2)
35
- protocol, host, port = connect_info.split(/:/, 3)
36
+ def parse_server(server, options)
37
+ server_matcher = /\A(?:(droonga|http):)?([^:]+)(?::([0-9]+))?(?:\/(.+))?\z/
38
+ server =~ server_matcher
39
+ protocol = $1
40
+ host = $2
41
+ port = $3
42
+ tag = $4
43
+
44
+ if protocol and host =~ /\A[0-9]+\z/ and port.nil?
45
+ # "host:port" case can be detected as "protocol:host" wrongly.
46
+ port = host
47
+ host = protocol
48
+ protocol = nil
49
+ end
50
+
51
+ protocol ||= options.default_protocol
52
+ port ||= options.default_port
53
+ tag ||= options.default_tag
54
+
36
55
  {
37
56
  :host => host,
38
57
  :port => Integer(port),
@@ -81,6 +100,8 @@ parser.on("--server=PROTOCOL:HOST:PORT/TAG",
81
100
  "Droonga server to be connected.",
82
101
  "Use multiple servers to use round-robin requests.",
83
102
  "Specify this option multiple times to use multiple servers.",
103
+ "Protocol, port, and tag can be provided via other options ",
104
+ "but host name must be specified.",
84
105
  "(#{default_server})") do |server|
85
106
  servers << server
86
107
  end
@@ -90,6 +111,21 @@ parser.on("--messages-per-second=N", Integer,
90
111
  "(#{messages_per_second})") do |n|
91
112
  messages_per_second = n
92
113
  end
114
+ parser.on("--default-protocol=PROTOCOL",
115
+ "Default protocol for servers.",
116
+ "(#{options.default_protocol})") do |protocol|
117
+ options.default_protocol = protocol
118
+ end
119
+ parser.on("--default-port=PORT", Integer,
120
+ "Default port for servers.",
121
+ "(#{options.default_port})") do |port|
122
+ options.default_port = port
123
+ end
124
+ parser.on("--default-tag=TAG",
125
+ "Default tag for servers.",
126
+ "(#{options.default_tag})") do |tag|
127
+ options.default_tag = tag
128
+ end
93
129
  parser.separator("")
94
130
  parser.separator("Report:")
95
131
  parser.on("--[no-]report-request",
@@ -106,7 +142,7 @@ request_json_files = parser.parse!(ARGV)
106
142
 
107
143
  servers << default_server if servers.empty?
108
144
  clients = servers.collect do |server|
109
- client_options = parse_server(server)
145
+ client_options = parse_server(server, options)
110
146
  client = Droonga::Client.new(client_options)
111
147
  Droonga::Client::RateLimiter.new(client, messages_per_second)
112
148
  end
data/doc/text/news.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # News
2
2
 
3
+ ## 0.1.9: 2014-07-29 (planned)
4
+
5
+ * droonga-send: Accept default protocol, port, and tag. Now you can omit them for the `--server` option.
6
+
3
7
  ## 0.1.8: 2014-07-14
4
8
 
5
9
  ### Fixes
@@ -64,14 +64,25 @@ module Droonga
64
64
  end
65
65
 
66
66
  def send(message, options={}, &block)
67
+ if message["id"].nil? or message["date"].nil?
68
+ id = message["id"] || generate_id
69
+ date = message["date"] || Time.now
70
+ message = message.merge("id" => id, "date" => date)
71
+ end
67
72
  @connection.send(message, options, &block)
68
73
  end
69
74
 
70
75
  def request(message, options={}, &block)
76
+ if message["id"].nil?
77
+ message = message.merge("id" => generate_id)
78
+ end
71
79
  @connection.request(message, options, &block)
72
80
  end
73
81
 
74
82
  def subscribe(message, options={}, &block)
83
+ if message["id"].nil?
84
+ message = message.merge("id" => generate_id)
85
+ end
75
86
  @connection.subscribe(message, options, &block)
76
87
  end
77
88
 
@@ -92,5 +103,9 @@ module Droonga
92
103
  Connection::DroongaProtocol.new(options)
93
104
  end
94
105
  end
106
+
107
+ def generate_id
108
+ Time.now.to_f.to_s
109
+ end
95
110
  end
96
111
  end
@@ -183,9 +183,7 @@ module Droonga
183
183
  end
184
184
 
185
185
  def request(message, options={}, &block)
186
- id = message["id"] || generate_id
187
- message = message.merge("id" => id,
188
- "replyTo" => @receiver.droonga_name)
186
+ message = message.merge("replyTo" => @receiver.droonga_name)
189
187
  send(message, options) do |error|
190
188
  yield(error)
191
189
  end
@@ -197,6 +195,7 @@ module Droonga
197
195
  response = _response
198
196
  end
199
197
  end
198
+ id = message["id"]
200
199
  @receiver.register(id) do |response|
201
200
  @receiver.unregister(id)
202
201
  block.call(response)
@@ -211,14 +210,13 @@ module Droonga
211
210
  end
212
211
 
213
212
  def subscribe(message, options={}, &block)
214
- id = message["id"] || generate_id
215
- message = message.merge("id" => id,
216
- "replyTo" => @receiver.droonga_name,
213
+ message = message.merge("replyTo" => @receiver.droonga_name,
217
214
  "from" => @receiver.droonga_name)
218
215
  send(message, options) do |error|
219
216
  yield(error)
220
217
  end
221
218
 
219
+ id = message["id"]
222
220
  request = InfiniteRequest.new(@loop)
223
221
  sync = block.nil?
224
222
  if sync
@@ -245,11 +243,6 @@ module Droonga
245
243
  end
246
244
 
247
245
  def send(message, options={}, &block)
248
- if message["id"].nil? or message["date"].nil?
249
- id = message["id"] || generate_id
250
- date = message["date"] || Time.now
251
- message = message.merge("id" => id, "date" => date)
252
- end
253
246
  @sender.send("#{@tag}.message", message) do
254
247
  host = @sender.peeraddr[3]
255
248
  port = @sender.peeraddr[1]
@@ -263,11 +256,6 @@ module Droonga
263
256
  @sender.close
264
257
  @receiver.close
265
258
  end
266
-
267
- private
268
- def generate_id
269
- Time.now.to_f.to_s
270
- end
271
259
  end
272
260
  end
273
261
  end
@@ -105,10 +105,6 @@ module Droonga
105
105
  end
106
106
 
107
107
  def send(message, options={}, &block)
108
- if message["id"].nil? or message["date"].nil?
109
- message = message.merge("id" => Time.now.to_f.to_s,
110
- "date" => Time.now)
111
- end
112
108
  @logger.post("message", message)
113
109
  end
114
110
 
@@ -151,7 +147,6 @@ module Droonga
151
147
  @client_handlers.each_key do |client|
152
148
  client.close
153
149
  end
154
- @read_ios.clear
155
150
  end
156
151
 
157
152
  def host
@@ -17,6 +17,6 @@
17
17
 
18
18
  module Droonga
19
19
  class Client
20
- VERSION = "0.1.8"
20
+ VERSION = "0.1.9"
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,125 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: droonga-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Droonga Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-14 00:00:00.000000000 Z
11
+ date: 2014-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fluent-logger
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rack
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: yajl-ruby
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: droonga-message-pack-packer
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.3'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.3'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: packnga
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  description: Droonga client for Ruby
@@ -131,8 +131,8 @@ executables:
131
131
  extensions: []
132
132
  extra_rdoc_files: []
133
133
  files:
134
- - ".gitignore"
135
- - ".yardopts"
134
+ - .gitignore
135
+ - .yardopts
136
136
  - Gemfile
137
137
  - LICENSE.txt
138
138
  - README.md
@@ -161,17 +161,17 @@ require_paths:
161
161
  - lib
162
162
  required_ruby_version: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ">="
164
+ - - '>='
165
165
  - !ruby/object:Gem::Version
166
166
  version: 1.9.3
167
167
  required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  requirements:
169
- - - ">="
169
+ - - '>='
170
170
  - !ruby/object:Gem::Version
171
171
  version: '0'
172
172
  requirements: []
173
173
  rubyforge_project:
174
- rubygems_version: 2.2.2
174
+ rubygems_version: 2.0.14
175
175
  signing_key:
176
176
  specification_version: 4
177
177
  summary: Droonga client for Ruby