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 +4 -4
- data/.travis.yml +6 -2
- data/CHANGELOG.md +4 -0
- data/README.md +7 -0
- data/lib/avromatic/schema_registry_patch.rb +24 -18
- data/lib/avromatic/version.rb +1 -1
- data/lib/avromatic.rb +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46512fd49a1b53c39202a90d03214b23303a7775
|
4
|
+
data.tar.gz: e63c9f9f1dd812b6627f3e06c93283d3ce095ad4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6619307c3c04ad60f7072f1ab019ee20ae718464cfac13f74be82d3556bfe51a9ef6c4fa9ca9eb566535e7c24d74577e4e67a50deab2505e362285e9d3e1e713
|
7
|
+
data.tar.gz: ef6be3d67985f24e3b1f7ff3836a28945e769f4b8878ba9973ba0a9ecf4919c1f4788f7f1587af8847d31ea7a1f3a0e1166bac4d1e361e823fd274104ed11921
|
data/.travis.yml
CHANGED
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
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
|
-
|
24
|
+
id = data.fetch('id')
|
24
25
|
|
25
|
-
|
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)
|
data/lib/avromatic/version.rb
CHANGED
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.
|
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
|
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.
|
299
|
+
rubygems_version: 2.6.10
|
300
300
|
signing_key:
|
301
301
|
specification_version: 4
|
302
302
|
summary: Generate Ruby models from Avro schemas
|