avro_turf 0.7.0 → 0.7.1

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: b494234a9f8fb90ae28c68c2536c4b4a53282879
4
- data.tar.gz: 1bf0027da6a5666c292613c501a3b5d1d95b0e93
3
+ metadata.gz: 4973e043a05b5317719217586f8cee3b9f913d1a
4
+ data.tar.gz: fb36f804b15c0bed61161d7b73242b7cb0a4cd83
5
5
  SHA512:
6
- metadata.gz: d2b4e531bda7323a871176fd1e75a85f8aac7285af95ed9ddb51fe274085724fae0af50bf3e098457142453a5c4ba4348904318213cbb425eb58cfbd42ebdb0a
7
- data.tar.gz: ca5046c5fa48b1ceb2d491ca20e4e5ff7367d931ef32634579954459be9a66d50ebad46ad7de756b96541c3c9b7ad745ac83d15f0947ace042fd06dec343b09a
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.4"
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)
@@ -1,3 +1,3 @@
1
1
  class AvroTurf
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  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.7.0
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-06-01 00:00:00.000000000 Z
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.4
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.4
46
+ version: '0.45'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement