avromatic 0.15.0 → 0.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6f0ed00b507561bee5c905af3ad8d32e752cbaf
4
- data.tar.gz: 6aad47be2668c65a14f23b66da204c88a720b9e9
3
+ metadata.gz: 46512fd49a1b53c39202a90d03214b23303a7775
4
+ data.tar.gz: e63c9f9f1dd812b6627f3e06c93283d3ce095ad4
5
5
  SHA512:
6
- metadata.gz: e7f64c1ed68803b496ff6b923b6dda7ce9f89306f8a590ec1dbe7676e344e2fc7353d6a98c627c4929ce38d19e6f73900033273951a19dc24611d38026ef3df3
7
- data.tar.gz: c6dd1ae8d6dde959cc6da12f280453126917a4f43120f6d7f812f0dde845ab516a0f26253acd5b483d0cba4c48575a3ff0a3e3e44fd1c65fc083dacb208bd2fc
6
+ metadata.gz: 6619307c3c04ad60f7072f1ab019ee20ae718464cfac13f74be82d3556bfe51a9ef6c4fa9ca9eb566535e7c24d74577e4e67a50deab2505e362285e9d3e1e713
7
+ data.tar.gz: ef6be3d67985f24e3b1f7ff3836a28945e769f4b8878ba9973ba0a9ecf4919c1f4788f7f1587af8847d31ea7a1f3a0e1166bac4d1e361e823fd274104ed11921
data/.travis.yml CHANGED
@@ -1,7 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.4
4
- - 2.3.1
3
+ - 2.4.0
4
+ - 2.3.3
5
+ - 2.2.6
6
+ before_install:
7
+ # Workaround for https://github.com/sickill/rainbow/issues/48
8
+ - gem update --system
5
9
  before_script:
6
10
  - bundle exec appraisal install --jobs=3
7
11
  script:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # avromatic changelog
2
2
 
3
+ ## v0.15.1
4
+ - Add `Avromatic.use_cacheable_schema_registration` option to control the lookup
5
+ of existing schema ids by fingerprint.
6
+
3
7
  ## v0.15.0
4
8
  - Add patch to `AvroTurf::SchemaRegistry` to lookup existing schema ids using
5
9
  `GET /subjects/:subject/fingerprints/:fingerprint` from `#register`.
data/README.md CHANGED
@@ -58,6 +58,13 @@ and the [Messaging API](#messaging-api).
58
58
  `registry_url` must be configured.
59
59
  * **registry_url**: URL for the schema registry. Either `schema_registry` or
60
60
  `registry_url` must be configured.
61
+ * **use_cacheable_schema_registration**: Avromatic supports a Schema Registry
62
+ [extension](https://github.com/salsify/avro-schema-registry#extensions) that
63
+ provides an endpoint to lookup existing schema ids by fingerprint.
64
+ A successful response from this GET request can be cached indefinitely.
65
+ The use of this additional endpoint can be disabled by setting this option to
66
+ `false` and this is recommended if using a Schema Registry that does not support
67
+ the endpoint.
61
68
  * **messaging**: An `AvroTurf::Messaging` object to be shared by all generated models.
62
69
  The `build_messaging!` method may be used to create a `Avromatic::Messaging`
63
70
  instance based on the other configuration values.
@@ -1,27 +1,33 @@
1
1
  require 'avro_turf'
2
2
  require 'avro_turf/schema_registry'
3
3
 
4
- AvroTurf::SchemaRegistry.class_eval do
5
- # Override register to first check if a schema is registered by fingerprint
6
- def register(subject, schema)
7
- schema_object = if schema.is_a?(String)
8
- Avro::Schema.parse(schema)
9
- else
10
- schema
11
- end
4
+ module Avromatic
5
+ module CacheableSchemaRegistration
6
+ # Override register to first check if a schema is registered by fingerprint
7
+ def register(subject, schema)
8
+ return super unless Avromatic.use_cacheable_schema_registration
12
9
 
13
- registered = false
14
- data = begin
15
- get("/subjects/#{subject}/fingerprints/#{schema_object.sha256_fingerprint.to_s(16)}")
16
- rescue
17
- registered = true
18
- post("/subjects/#{subject}/versions", body: { schema: schema.to_s }.to_json)
19
- end
10
+ schema_object = if schema.is_a?(String)
11
+ Avro::Schema.parse(schema)
12
+ else
13
+ schema
14
+ end
20
15
 
21
- id = data.fetch('id')
16
+ registered = false
17
+ data = begin
18
+ get("/subjects/#{subject}/fingerprints/#{schema_object.sha256_fingerprint.to_s(16)}")
19
+ rescue
20
+ registered = true
21
+ post("/subjects/#{subject}/versions", body: { schema: schema.to_s }.to_json)
22
+ end
22
23
 
23
- @logger.info("#{registered ? 'Registered' : 'Found'} schema for subject `#{subject}`; id = #{id}")
24
+ id = data.fetch('id')
24
25
 
25
- id
26
+ @logger.info("#{registered ? 'Registered' : 'Found'} schema for subject `#{subject}`; id = #{id}")
27
+
28
+ id
29
+ end
26
30
  end
27
31
  end
32
+
33
+ AvroTurf::SchemaRegistry.prepend(Avromatic::CacheableSchemaRegistration)
@@ -1,3 +1,3 @@
1
1
  module Avromatic
2
- VERSION = '0.15.0'.freeze
2
+ VERSION = '0.15.1'.freeze
3
3
  end
data/lib/avromatic.rb CHANGED
@@ -9,7 +9,7 @@ module Avromatic
9
9
  class << self
10
10
  attr_accessor :schema_registry, :registry_url, :schema_store, :logger,
11
11
  :messaging, :type_registry, :nested_models,
12
- :use_custom_datum_reader
12
+ :use_custom_datum_reader, :use_cacheable_schema_registration
13
13
 
14
14
  delegate :register_type, to: :type_registry
15
15
  end
@@ -18,6 +18,7 @@ module Avromatic
18
18
  self.logger = Logger.new($stdout)
19
19
  self.type_registry = Avromatic::Model::TypeRegistry.new
20
20
  self.use_custom_datum_reader = true
21
+ self.use_cacheable_schema_registration = true
21
22
 
22
23
  def self.configure
23
24
  yield self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avromatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salsify Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-20 00:00:00.000000000 Z
11
+ date: 2017-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro
@@ -296,7 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
296
296
  version: '0'
297
297
  requirements: []
298
298
  rubyforge_project:
299
- rubygems_version: 2.6.8
299
+ rubygems_version: 2.6.10
300
300
  signing_key:
301
301
  specification_version: 4
302
302
  summary: Generate Ruby models from Avro schemas