avro_turf 0.7.0 → 0.7.1
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/README.md +29 -0
- data/avro_turf.gemspec +1 -1
- data/lib/avro_turf/cached_schema_registry.rb +1 -1
- data/lib/avro_turf/schema_registry.rb +10 -0
- data/lib/avro_turf/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4973e043a05b5317719217586f8cee3b9f913d1a
|
4
|
+
data.tar.gz: fb36f804b15c0bed61161d7b73242b7cb0a4cd83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 234fa5e60fa5d41ead791b6f48c0db08b2ae02a53848b0fbd31dcf13ee07610800c8407a760e86b9329da3f0b0a2d96ea6c44768f7db9438e18aebe72a3f7ab6
|
7
|
+
data.tar.gz: deaa4c2afa94cabe4d50070d17c3cd455623461d1fb91397e2ed0a2ff473df9892e409836efe7e4bc13d55658de6b340955c1342a8251bee1a52aef2b8d875cb
|
data/README.md
CHANGED
@@ -121,6 +121,35 @@ data = avro.encode({ "title" => "hello, world" }, schema_name: "greeting")
|
|
121
121
|
avro.decode(data) #=> { "title" => "hello, world" }
|
122
122
|
```
|
123
123
|
|
124
|
+
In addition to encoding and decoding data, you can check whether a schema is compatible
|
125
|
+
with a subject in the registry using the [Compatibility API](http://docs.confluent.io/2.0.0/schema-registry/docs/api.html#compatibility)
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
require 'avro_turf/messaging'
|
129
|
+
|
130
|
+
schema = <<-JSON
|
131
|
+
{
|
132
|
+
"name": "person",
|
133
|
+
"type": "record",
|
134
|
+
"fields": [
|
135
|
+
{
|
136
|
+
"name": "full_name",
|
137
|
+
"type": "string"
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"name": "address",
|
141
|
+
"type": "address"
|
142
|
+
}
|
143
|
+
]
|
144
|
+
}
|
145
|
+
JSON
|
146
|
+
|
147
|
+
avro = AvroTurf::Messaging.new(registry_url: "http://my-registry:8081/")
|
148
|
+
|
149
|
+
# Returns true if the schema is compatible, false otherwise.
|
150
|
+
avro.compatible?("person", schema)
|
151
|
+
```
|
152
|
+
|
124
153
|
### Testing Support
|
125
154
|
|
126
155
|
AvroTurf includes a `FakeSchemaRegistryServer` that can be used in tests. The
|
data/avro_turf.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
20
|
spec.add_dependency "avro", ">= 1.7.7", "< 1.9"
|
21
|
-
spec.add_dependency "excon", "~> 0.45
|
21
|
+
spec.add_dependency "excon", "~> 0.45"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.7"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -10,7 +10,7 @@ class AvroTurf::CachedSchemaRegistry
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# Delegate the following methods to the upstream
|
13
|
-
%i(subjects subject_versions subject_version check).each do |name|
|
13
|
+
%i(subjects subject_versions subject_version check compatible?).each do |name|
|
14
14
|
define_method(name) do |*args|
|
15
15
|
instance_variable_get(:@upstream).send(name, *args)
|
16
16
|
end
|
@@ -51,6 +51,16 @@ class AvroTurf::SchemaRegistry
|
|
51
51
|
data unless data.has_key?("error_code")
|
52
52
|
end
|
53
53
|
|
54
|
+
# Check if a schema is compatible with the stored version.
|
55
|
+
# Returns true if compatible, false otherwise
|
56
|
+
# http://docs.confluent.io/2.0.0/schema-registry/docs/api.html#compatibility
|
57
|
+
def compatible?(subject, schema, version = 'latest')
|
58
|
+
data = post("/compatibility/subjects/#{subject}/versions/#{version}",
|
59
|
+
expects: [200, 404],
|
60
|
+
body: { schema: schema.to_s }.to_json)
|
61
|
+
data.fetch('is_compatible', false) unless data.has_key?('error_code')
|
62
|
+
end
|
63
|
+
|
54
64
|
private
|
55
65
|
|
56
66
|
def get(path, **options)
|
data/lib/avro_turf/version.rb
CHANGED
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.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Schierbeck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.45
|
39
|
+
version: '0.45'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.45
|
46
|
+
version: '0.45'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|