avro_turf 0.8.1 → 0.11.0
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/.circleci/config.yml +36 -0
- data/.github/workflows/ruby.yml +20 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile +0 -3
- data/README.md +20 -0
- data/avro_turf.gemspec +6 -5
- data/lib/avro_turf.rb +10 -1
- data/lib/avro_turf/cached_confluent_schema_registry.rb +18 -6
- data/lib/avro_turf/confluent_schema_registry.rb +23 -4
- data/lib/avro_turf/disk_cache.rb +83 -0
- data/lib/avro_turf/in_memory_cache.rb +38 -0
- data/lib/avro_turf/messaging.rb +109 -16
- data/lib/avro_turf/schema_store.rb +35 -20
- data/lib/avro_turf/test/fake_confluent_schema_registry_server.rb +15 -3
- data/lib/avro_turf/version.rb +1 -1
- data/spec/cached_confluent_schema_registry_spec.rb +24 -2
- data/spec/confluent_schema_registry_spec.rb +13 -1
- data/spec/disk_cached_confluent_schema_registry_spec.rb +159 -0
- data/spec/messaging_spec.rb +205 -17
- data/spec/schema_store_spec.rb +36 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/confluent_schema_registry_context.rb +8 -5
- data/spec/test/fake_confluent_schema_registry_server_spec.rb +40 -0
- metadata +34 -13
- data/circle.yml +0 -4
data/spec/schema_store_spec.rb
CHANGED
@@ -197,6 +197,42 @@ describe AvroTurf::SchemaStore do
|
|
197
197
|
schema = store.find("person")
|
198
198
|
expect(schema.fullname).to eq "person"
|
199
199
|
end
|
200
|
+
|
201
|
+
it "is thread safe" do
|
202
|
+
define_schema "address.avsc", <<-AVSC
|
203
|
+
{
|
204
|
+
"type": "record",
|
205
|
+
"name": "address",
|
206
|
+
"fields": []
|
207
|
+
}
|
208
|
+
AVSC
|
209
|
+
|
210
|
+
# Set a Thread breakpoint right in the core place of race condition
|
211
|
+
expect(Avro::Name)
|
212
|
+
.to receive(:add_name)
|
213
|
+
.and_wrap_original { |m, *args|
|
214
|
+
Thread.stop
|
215
|
+
m.call(*args)
|
216
|
+
}
|
217
|
+
|
218
|
+
# Run two concurring threads which both will trigger the same schema loading
|
219
|
+
threads = 2.times.map { Thread.new { store.find("address") } }
|
220
|
+
# Wait for the moment when both threads will reach the breakpoint
|
221
|
+
sleep 0.001 until threads.all?(&:stop?)
|
222
|
+
|
223
|
+
expect {
|
224
|
+
# Resume the threads evaluation, one after one
|
225
|
+
threads.each do |thread|
|
226
|
+
next unless thread.status == 'sleep'
|
227
|
+
|
228
|
+
thread.run
|
229
|
+
sleep 0.001 until thread.stop?
|
230
|
+
end
|
231
|
+
|
232
|
+
# Ensure that threads are finished
|
233
|
+
threads.each(&:join)
|
234
|
+
}.to_not raise_error
|
235
|
+
end
|
200
236
|
end
|
201
237
|
|
202
238
|
describe "#load_schemas!" do
|
data/spec/spec_helper.rb
CHANGED
@@ -12,6 +12,14 @@ module Helpers
|
|
12
12
|
f.write(content)
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
def store_cache(path, hash)
|
17
|
+
File.write(File.join("spec/cache", path), JSON.generate(hash))
|
18
|
+
end
|
19
|
+
|
20
|
+
def load_cache(path)
|
21
|
+
JSON.parse(File.read(File.join("spec/cache", path)))
|
22
|
+
end
|
15
23
|
end
|
16
24
|
|
17
25
|
RSpec.configure do |config|
|
@@ -88,16 +88,18 @@ shared_examples_for "a confluent schema registry client" do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
describe "#subject_version" do
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
91
|
+
let!(:schema_id1) do
|
92
|
+
registry.register(subject_name, { type: :record, name: "r0", fields: [] }.to_json)
|
93
|
+
end
|
94
|
+
let!(:schema_id2) do
|
95
|
+
registry.register(subject_name, { type: :record, name: "r1", fields: [] }.to_json)
|
96
96
|
end
|
97
|
+
|
97
98
|
let(:expected) do
|
98
99
|
{
|
99
100
|
name: subject_name,
|
100
101
|
version: 1,
|
102
|
+
id: schema_id1,
|
101
103
|
schema: { type: :record, name: "r0", fields: [] }.to_json
|
102
104
|
}.to_json
|
103
105
|
end
|
@@ -112,6 +114,7 @@ shared_examples_for "a confluent schema registry client" do
|
|
112
114
|
{
|
113
115
|
name: subject_name,
|
114
116
|
version: 2,
|
117
|
+
id: schema_id2,
|
115
118
|
schema: { type: :record, name: "r1", fields: [] }.to_json
|
116
119
|
}.to_json
|
117
120
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rack/test'
|
2
|
+
require 'avro_turf/test/fake_confluent_schema_registry_server'
|
3
|
+
|
4
|
+
describe FakeConfluentSchemaRegistryServer do
|
5
|
+
include Rack::Test::Methods
|
6
|
+
|
7
|
+
def app; described_class; end
|
8
|
+
|
9
|
+
let(:schema) do
|
10
|
+
{
|
11
|
+
type: "record",
|
12
|
+
name: "person",
|
13
|
+
fields: [
|
14
|
+
{ name: "name", type: "string" }
|
15
|
+
]
|
16
|
+
}.to_json
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'POST /subjects/:subject/versions' do
|
20
|
+
it 'returns the same schema ID when invoked with same schema and same subject' do
|
21
|
+
post '/subjects/person/versions', { schema: schema }.to_json, 'CONTENT_TYPE' => 'application/vnd.schemaregistry+json'
|
22
|
+
|
23
|
+
expected_id = JSON.parse(last_response.body).fetch('id')
|
24
|
+
|
25
|
+
post '/subjects/person/versions', { schema: schema }.to_json, 'CONTENT_TYPE' => 'application/vnd.schemaregistry+json'
|
26
|
+
|
27
|
+
expect(JSON.parse(last_response.body).fetch('id')).to eq expected_id
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns a different schema ID when invoked with same schema and different subject' do
|
31
|
+
post '/subjects/person/versions', { schema: schema }.to_json, 'CONTENT_TYPE' => 'application/vnd.schemaregistry+json'
|
32
|
+
|
33
|
+
original_id = JSON.parse(last_response.body).fetch('id')
|
34
|
+
|
35
|
+
post '/subjects/happy-person/versions', { schema: schema }.to_json, 'CONTENT_TYPE' => 'application/vnd.schemaregistry+json'
|
36
|
+
|
37
|
+
expect(JSON.parse(last_response.body).fetch('id')).not_to eq original_id
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avro_turf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Schierbeck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 1.7.7
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '1.
|
22
|
+
version: '1.10'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 1.7.7
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '1.
|
32
|
+
version: '1.10'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: excon
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,56 +50,56 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '2.0'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '2.0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rake
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
67
|
+
version: '13.0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '13.0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: rspec
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 3.2
|
81
|
+
version: '3.2'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: 3.2
|
88
|
+
version: '3.2'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: fakefs
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: 0.
|
95
|
+
version: 0.20.0
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 0.
|
102
|
+
version: 0.20.0
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: webmock
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,6 +142,20 @@ dependencies:
|
|
142
142
|
- - ">="
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '0'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: rack-test
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
145
159
|
description:
|
146
160
|
email:
|
147
161
|
- dasch@zendesk.com
|
@@ -149,6 +163,8 @@ executables: []
|
|
149
163
|
extensions: []
|
150
164
|
extra_rdoc_files: []
|
151
165
|
files:
|
166
|
+
- ".circleci/config.yml"
|
167
|
+
- ".github/workflows/ruby.yml"
|
152
168
|
- ".gitignore"
|
153
169
|
- ".rspec"
|
154
170
|
- CHANGELOG.md
|
@@ -157,7 +173,6 @@ files:
|
|
157
173
|
- README.md
|
158
174
|
- Rakefile
|
159
175
|
- avro_turf.gemspec
|
160
|
-
- circle.yml
|
161
176
|
- lib/avro_turf.rb
|
162
177
|
- lib/avro_turf/cached_confluent_schema_registry.rb
|
163
178
|
- lib/avro_turf/cached_schema_registry.rb
|
@@ -173,6 +188,8 @@ files:
|
|
173
188
|
- lib/avro_turf/core_ext/symbol.rb
|
174
189
|
- lib/avro_turf/core_ext/time.rb
|
175
190
|
- lib/avro_turf/core_ext/true_class.rb
|
191
|
+
- lib/avro_turf/disk_cache.rb
|
192
|
+
- lib/avro_turf/in_memory_cache.rb
|
176
193
|
- lib/avro_turf/messaging.rb
|
177
194
|
- lib/avro_turf/mutable_schema_store.rb
|
178
195
|
- lib/avro_turf/schema_registry.rb
|
@@ -198,11 +215,13 @@ files:
|
|
198
215
|
- spec/core_ext/symbol_spec.rb
|
199
216
|
- spec/core_ext/time_spec.rb
|
200
217
|
- spec/core_ext/true_class_spec.rb
|
218
|
+
- spec/disk_cached_confluent_schema_registry_spec.rb
|
201
219
|
- spec/messaging_spec.rb
|
202
220
|
- spec/schema_store_spec.rb
|
203
221
|
- spec/schema_to_avro_patch_spec.rb
|
204
222
|
- spec/spec_helper.rb
|
205
223
|
- spec/support/confluent_schema_registry_context.rb
|
224
|
+
- spec/test/fake_confluent_schema_registry_server_spec.rb
|
206
225
|
homepage: https://github.com/dasch/avro_turf
|
207
226
|
licenses:
|
208
227
|
- MIT
|
@@ -250,8 +269,10 @@ test_files:
|
|
250
269
|
- spec/core_ext/symbol_spec.rb
|
251
270
|
- spec/core_ext/time_spec.rb
|
252
271
|
- spec/core_ext/true_class_spec.rb
|
272
|
+
- spec/disk_cached_confluent_schema_registry_spec.rb
|
253
273
|
- spec/messaging_spec.rb
|
254
274
|
- spec/schema_store_spec.rb
|
255
275
|
- spec/schema_to_avro_patch_spec.rb
|
256
276
|
- spec/spec_helper.rb
|
257
277
|
- spec/support/confluent_schema_registry_context.rb
|
278
|
+
- spec/test/fake_confluent_schema_registry_server_spec.rb
|
data/circle.yml
DELETED