gqtp 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -1
- data/doc/text/news.md +14 -8
- data/lib/gqtp/client.rb +24 -4
- data/lib/gqtp/version.rb +1 -1
- data/test/test-client.rb +39 -7
- metadata +16 -16
data/Gemfile
CHANGED
data/doc/text/news.md
CHANGED
@@ -1,32 +1,38 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 1.0.5: 2013-09-18
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* Supported async close.
|
8
|
+
|
3
9
|
## 1.0.4: 2013-07-08
|
4
10
|
|
5
11
|
### Fixes
|
6
12
|
|
7
|
-
* Fixed missing synchronization bug
|
8
|
-
* Suppressed warnings
|
13
|
+
* Fixed missing synchronization bug
|
14
|
+
* Suppressed warnings
|
9
15
|
|
10
16
|
## 1.0.3: 2013-01-07
|
11
17
|
|
12
18
|
### Fixes
|
13
19
|
|
14
|
-
* Fixed the bug anyone can't see README document in rubydoc.info.
|
15
|
-
|
20
|
+
* Fixed the bug anyone can't see README document in rubydoc.info.
|
21
|
+
README URL: http://rubydoc.info/gems/gqtp/
|
16
22
|
|
17
23
|
## 1.0.2: 2012-12-29
|
18
24
|
|
19
25
|
### Fixes
|
20
26
|
|
21
|
-
* Added missing file for documentaion.
|
27
|
+
* Added missing file for documentaion.
|
22
28
|
|
23
29
|
## 1.0.1: 2012-12-29
|
24
30
|
|
25
31
|
### Improvements
|
26
32
|
|
27
|
-
* [client] Sent
|
28
|
-
|
29
|
-
|
33
|
+
* [client] Sent
|
34
|
+
[quit command](http://groonga.org/docs/reference/commands/quit.html)
|
35
|
+
on close.
|
30
36
|
|
31
37
|
## 1.0.0: 2012-11-29
|
32
38
|
|
data/lib/gqtp/client.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
3
|
+
# Copyright (C) 2012-2013 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -69,18 +69,38 @@ module GQTP
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
# Closes the opened connection. You can't send a new request after
|
73
|
+
# this method is called.
|
74
|
+
#
|
75
|
+
# @overload close
|
76
|
+
# Closes synchronously.
|
77
|
+
#
|
78
|
+
# @return [true]
|
79
|
+
#
|
80
|
+
# @overload close {}
|
81
|
+
# Closes asynchronously.
|
82
|
+
#
|
83
|
+
# @yield [] Calls the block when the opened connection is closed.
|
84
|
+
# @return [#wait] The request object. If you want to wait until
|
85
|
+
# the request is processed. You can send #wait message to the
|
86
|
+
# request.
|
72
87
|
def close
|
73
88
|
sync = !block_given?
|
74
|
-
|
89
|
+
sequential_request = SequentialRequest.new
|
75
90
|
quit_request = send("quit", :header => header_for_close) do
|
76
91
|
ack_request = send("ACK", :header => header_for_close) do
|
77
92
|
@connection.close
|
78
93
|
yield if block_given?
|
79
94
|
end
|
95
|
+
sequential_request << ack_request
|
80
96
|
end
|
97
|
+
sequential_request << quit_request
|
98
|
+
|
81
99
|
if sync
|
82
|
-
|
83
|
-
|
100
|
+
sequential_request.wait
|
101
|
+
true
|
102
|
+
else
|
103
|
+
sequential_request
|
84
104
|
end
|
85
105
|
end
|
86
106
|
|
data/lib/gqtp/version.rb
CHANGED
data/test/test-client.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
3
|
+
# Copyright (C) 2012-2013 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -32,13 +32,8 @@ class ClientTest < Test::Unit::TestCase
|
|
32
32
|
client = @server.accept
|
33
33
|
@server.close
|
34
34
|
|
35
|
-
|
36
|
-
@request_body = client.read(header.size)
|
35
|
+
process_client(client)
|
37
36
|
|
38
|
-
response_header = GQTP::Header.new
|
39
|
-
response_header.size = @response_body.bytesize
|
40
|
-
client.write(response_header.pack)
|
41
|
-
client.write(@response_body)
|
42
37
|
client.close
|
43
38
|
end
|
44
39
|
end
|
@@ -65,4 +60,41 @@ class ClientTest < Test::Unit::TestCase
|
|
65
60
|
end
|
66
61
|
request.wait
|
67
62
|
end
|
63
|
+
|
64
|
+
private
|
65
|
+
def process_client(client)
|
66
|
+
header = GQTP::Header.parse(client.read(GQTP::Header.size))
|
67
|
+
@request_body = client.read(header.size)
|
68
|
+
|
69
|
+
response_header = GQTP::Header.new
|
70
|
+
response_header.size = @response_body.bytesize
|
71
|
+
client.write(response_header.pack)
|
72
|
+
client.write(@response_body)
|
73
|
+
end
|
74
|
+
|
75
|
+
class CloseTest < self
|
76
|
+
def test_sync
|
77
|
+
@response_body = "[]"
|
78
|
+
client = GQTP::Client.new(:address => @address, :port => @port)
|
79
|
+
assert_true(client.close)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_async
|
83
|
+
@response_body = "[]"
|
84
|
+
client = GQTP::Client.new(:address => @address, :port => @port)
|
85
|
+
closed = false
|
86
|
+
close_request = client.close do
|
87
|
+
closed = true
|
88
|
+
end
|
89
|
+
assert_false(closed)
|
90
|
+
close_request.wait
|
91
|
+
assert_true(closed)
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
def process_client(client)
|
96
|
+
super(client)
|
97
|
+
super(client)
|
98
|
+
end
|
99
|
+
end
|
68
100
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gqtp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -126,25 +126,25 @@ files:
|
|
126
126
|
- Gemfile
|
127
127
|
- gqtp.gemspec
|
128
128
|
- .yardopts
|
129
|
-
- lib/gqtp.rb
|
130
|
-
- lib/gqtp/version.rb
|
131
|
-
- lib/gqtp/connection/synchronous.rb
|
132
|
-
- lib/gqtp/connection/coolio.rb
|
133
|
-
- lib/gqtp/connection/thread.rb
|
129
|
+
- lib/gqtp/parser.rb
|
134
130
|
- lib/gqtp/header.rb
|
135
131
|
- lib/gqtp/error.rb
|
132
|
+
- lib/gqtp/version.rb
|
133
|
+
- lib/gqtp/proxy.rb
|
136
134
|
- lib/gqtp/sequential-request.rb
|
137
|
-
- lib/gqtp/parser.rb
|
138
135
|
- lib/gqtp/server.rb
|
139
|
-
- lib/gqtp/
|
136
|
+
- lib/gqtp/connection/coolio.rb
|
137
|
+
- lib/gqtp/connection/thread.rb
|
138
|
+
- lib/gqtp/connection/synchronous.rb
|
140
139
|
- lib/gqtp/client.rb
|
141
|
-
-
|
140
|
+
- lib/gqtp.rb
|
142
141
|
- doc/text/news.md
|
143
|
-
-
|
144
|
-
- test/test-parser.rb
|
145
|
-
- test/test-proxy.rb
|
142
|
+
- doc/text/lgpl-2.1.txt
|
146
143
|
- test/run-test.rb
|
147
144
|
- test/test-client.rb
|
145
|
+
- test/test-parser.rb
|
146
|
+
- test/test-proxy.rb
|
147
|
+
- test/test-header.rb
|
148
148
|
- bin/gqtp-proxy
|
149
149
|
homepage: https://github.com/ranguba/gqtp
|
150
150
|
licenses:
|
@@ -173,9 +173,9 @@ specification_version: 3
|
|
173
173
|
summary: Gqtp gem is a [GQTP (Groonga Query Transfer Protocol)](http://groonga.org/docs/spec/gqtp.html)
|
174
174
|
Ruby implementation.
|
175
175
|
test_files:
|
176
|
-
- test/test-header.rb
|
177
|
-
- test/test-parser.rb
|
178
|
-
- test/test-proxy.rb
|
179
176
|
- test/run-test.rb
|
180
177
|
- test/test-client.rb
|
178
|
+
- test/test-parser.rb
|
179
|
+
- test/test-proxy.rb
|
180
|
+
- test/test-header.rb
|
181
181
|
has_rdoc:
|