avro_turf 1.20.1 → 1.20.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/avro_turf.gemspec +0 -1
- data/lib/avro_turf/confluent_schema_registry.rb +9 -1
- data/lib/avro_turf/version.rb +1 -1
- data/spec/confluent_schema_registry_socket_reset_spec.rb +76 -0
- metadata +3 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 470551a79cda6c0bd70278cc897ce49865da245cf23343e470cfe678d9be8337
|
|
4
|
+
data.tar.gz: 8cad926076373c9e4dca011cea71bd5db2765eaacca3e9ca041e8ecb676aefed
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ba8a93fb62a571993c31ea9b6bd5ca7113f0b090b3d846e0b350bad8ad0068af4801d0e090af1454f2d83cae6d06f2fe5c487f58e76451204f6cbbb5ecfd24f
|
|
7
|
+
data.tar.gz: 750fde4b42c44ee5d68e43d72ce4f33e28565993ead7982fa3d720c480e8b47e0bd55f0fd4bdbe326a26c43e60643f5d63815b2ab8b0949db99ce93325a90d29
|
data/CHANGELOG.md
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## v1.20.2
|
|
6
|
+
|
|
7
|
+
- Fix stale reads from `AvroTurf::ConfluentSchemaRegistry` after `Exceptions`
|
|
6
8
|
|
|
7
9
|
## v1.20.1
|
|
8
10
|
|
|
9
11
|
- Remove `sinatra` as a development dependency (#237)
|
|
12
|
+
- Memoize parsed schemas to improve encoding performance when using `AvroTurf::Messaging` (#206)
|
|
10
13
|
|
|
11
14
|
## v1.20.0
|
|
12
15
|
|
data/avro_turf.gemspec
CHANGED
|
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.add_dependency "avro", ">= 1.11.3", "< 1.13"
|
|
23
23
|
spec.add_dependency "excon", ">= 0.104", "< 2"
|
|
24
24
|
|
|
25
|
-
spec.add_development_dependency "bundler", "~> 2.0"
|
|
26
25
|
spec.add_development_dependency "rake", "~> 13.0"
|
|
27
26
|
spec.add_development_dependency "rspec", "~> 3.2"
|
|
28
27
|
spec.add_development_dependency "fakefs", "~> 3"
|
|
@@ -163,7 +163,15 @@ class AvroTurf::ConfluentSchemaRegistry
|
|
|
163
163
|
def request(path, **options)
|
|
164
164
|
options = {expects: 200}.merge!(options)
|
|
165
165
|
path = File.join(@path_prefix, path) unless @path_prefix.nil?
|
|
166
|
-
response =
|
|
166
|
+
response = begin
|
|
167
|
+
@connection.request(path: path, **options)
|
|
168
|
+
rescue Exception # rubocop:disable Lint/RescueException
|
|
169
|
+
# Excon only resets the connection for StandardError, so an exception
|
|
170
|
+
# outside that hierarchy (e.g. Rack::Timeout::RequestTimeoutException)
|
|
171
|
+
# leaves the socket cached with unread bytes still on it.
|
|
172
|
+
@connection.reset
|
|
173
|
+
raise
|
|
174
|
+
end
|
|
167
175
|
JSON.parse(response.body)
|
|
168
176
|
end
|
|
169
177
|
end
|
data/lib/avro_turf/version.rb
CHANGED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "avro_turf/confluent_schema_registry"
|
|
4
|
+
|
|
5
|
+
describe AvroTurf::ConfluentSchemaRegistry, "socket reset on interrupt" do
|
|
6
|
+
let(:registry) { described_class.new("http://127.0.0.1:#{port}", logger: logger) }
|
|
7
|
+
let(:server) { TCPServer.new("127.0.0.1", 0) }
|
|
8
|
+
let(:port) { server.addr[1] }
|
|
9
|
+
let(:logger) { Logger.new(StringIO.new) }
|
|
10
|
+
|
|
11
|
+
let(:timeout_exception) { Class.new(Exception) } # rubocop:disable Lint/InheritException
|
|
12
|
+
|
|
13
|
+
# These specs need an actual socket to the local test server
|
|
14
|
+
around do |example|
|
|
15
|
+
FakeFS.deactivate!
|
|
16
|
+
WebMock.allow_net_connect! if defined?(WebMock)
|
|
17
|
+
|
|
18
|
+
example.call
|
|
19
|
+
ensure
|
|
20
|
+
WebMock.disable_net_connect! if defined?(WebMock)
|
|
21
|
+
FakeFS.activate!
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
before do
|
|
25
|
+
@server_thread = Thread.new do
|
|
26
|
+
loop do
|
|
27
|
+
socket = server.accept
|
|
28
|
+
|
|
29
|
+
Thread.new(socket) do |connection|
|
|
30
|
+
request_line = connection.gets
|
|
31
|
+
path = request_line.split[1]
|
|
32
|
+
|
|
33
|
+
schema = {type: "string", path: path}.to_json
|
|
34
|
+
body = {schema: schema}.to_json
|
|
35
|
+
|
|
36
|
+
connection.write(
|
|
37
|
+
"HTTP/1.1 200 OK\r\n" \
|
|
38
|
+
"Content-Type: application/json\r\n" \
|
|
39
|
+
"Content-Length: #{body.bytesize}\r\n\r\n" \
|
|
40
|
+
"#{body}"
|
|
41
|
+
)
|
|
42
|
+
connection.flush
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
timeout = true
|
|
48
|
+
this = self
|
|
49
|
+
Excon::Socket.class_eval do
|
|
50
|
+
alias_method :__unstubbed_readline, :readline
|
|
51
|
+
define_method(:readline) do |*args|
|
|
52
|
+
if timeout
|
|
53
|
+
timeout = false
|
|
54
|
+
raise this.timeout_exception, "request timeout"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
__unstubbed_readline(*args)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
after do
|
|
63
|
+
Excon::Socket.class_eval do
|
|
64
|
+
alias_method :readline, :__unstubbed_readline
|
|
65
|
+
remove_method :__unstubbed_readline
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
@server_thread&.kill
|
|
69
|
+
server.close unless server.closed?
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "does not hand the next request the abandoned response" do
|
|
73
|
+
expect { registry.fetch("1") }.to raise_error(timeout_exception)
|
|
74
|
+
expect(registry.fetch("2")).to include("/schemas/ids/2")
|
|
75
|
+
end
|
|
76
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: avro_turf
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.20.
|
|
4
|
+
version: 1.20.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Schierbeck
|
|
@@ -49,20 +49,6 @@ dependencies:
|
|
|
49
49
|
- - "<"
|
|
50
50
|
- !ruby/object:Gem::Version
|
|
51
51
|
version: '2'
|
|
52
|
-
- !ruby/object:Gem::Dependency
|
|
53
|
-
name: bundler
|
|
54
|
-
requirement: !ruby/object:Gem::Requirement
|
|
55
|
-
requirements:
|
|
56
|
-
- - "~>"
|
|
57
|
-
- !ruby/object:Gem::Version
|
|
58
|
-
version: '2.0'
|
|
59
|
-
type: :development
|
|
60
|
-
prerelease: false
|
|
61
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
62
|
-
requirements:
|
|
63
|
-
- - "~>"
|
|
64
|
-
- !ruby/object:Gem::Version
|
|
65
|
-
version: '2.0'
|
|
66
52
|
- !ruby/object:Gem::Dependency
|
|
67
53
|
name: rake
|
|
68
54
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -211,6 +197,7 @@ files:
|
|
|
211
197
|
- perf/person.avsc
|
|
212
198
|
- spec/avro_turf_spec.rb
|
|
213
199
|
- spec/cached_confluent_schema_registry_spec.rb
|
|
200
|
+
- spec/confluent_schema_registry_socket_reset_spec.rb
|
|
214
201
|
- spec/confluent_schema_registry_spec.rb
|
|
215
202
|
- spec/core_ext/date_spec.rb
|
|
216
203
|
- spec/core_ext/enumerable_spec.rb
|
|
@@ -261,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
261
248
|
- !ruby/object:Gem::Version
|
|
262
249
|
version: '0'
|
|
263
250
|
requirements: []
|
|
264
|
-
rubygems_version:
|
|
251
|
+
rubygems_version: 4.0.20
|
|
265
252
|
specification_version: 4
|
|
266
253
|
summary: A library that makes it easier to use the Avro serialization format from
|
|
267
254
|
Ruby
|