avromatic 0.14.0.rc1 → 0.14.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/Appraisals +7 -7
- data/README.md +11 -2
- data/gemfiles/avro_salsify_fork.gemfile +3 -3
- data/gemfiles/rails4_1.gemfile +2 -2
- data/gemfiles/rails4_2.gemfile +2 -2
- data/lib/avromatic/io/datum_reader.rb +6 -4
- data/lib/avromatic/messaging.rb +2 -2
- data/lib/avromatic/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: 81c34321b541cd5f890615b13b5d61b59b27a8a5
|
4
|
+
data.tar.gz: 0bb1ccc7add9573f0dd92433fcf64badc9eb1f28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99f92368cee3ad3dd2bf300929e691239bbb8b923530ac8ee883b7732dcf0078b96be4ded276744e17409b705f4b452d9d0e1effad1b19104a41f8360145278b
|
7
|
+
data.tar.gz: 99d8b4e28ed8e8a8aa5af87ad0ca60487f2d3437047b2e3133909ff72e24cc536719dce9f258451e37a53d359f8c55c3a6cd2ed99d3c892fcebbe780ceca45c1
|
data/Appraisals
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
appraise 'rails4_1' do
|
2
2
|
gem 'avro', '1.8.1'
|
3
|
-
gem 'activesupport', '~> 4.1.
|
4
|
-
gem 'activemodel', '~> 4.1.
|
3
|
+
gem 'activesupport', '~> 4.1.16'
|
4
|
+
gem 'activemodel', '~> 4.1.16'
|
5
5
|
end
|
6
6
|
|
7
7
|
appraise 'rails4_2' do
|
8
8
|
gem 'avro', '1.8.1'
|
9
|
-
gem 'activesupport', '~> 4.2.
|
10
|
-
gem 'activemodel', '~> 4.2.
|
9
|
+
gem 'activesupport', '~> 4.2.7.1'
|
10
|
+
gem 'activemodel', '~> 4.2.7.1'
|
11
11
|
end
|
12
12
|
|
13
13
|
appraise 'avro-salsify-fork' do
|
14
|
-
gem 'avro-salsify-fork', '1.9.0.
|
15
|
-
gem 'activesupport', '~> 4.2.
|
16
|
-
gem 'activemodel', '~> 4.2.
|
14
|
+
gem 'avro-salsify-fork', '1.9.0.3', require: 'avro'
|
15
|
+
gem 'activesupport', '~> 4.2.7.1'
|
16
|
+
gem 'activemodel', '~> 4.2.7.1'
|
17
17
|
end
|
data/README.md
CHANGED
@@ -59,8 +59,8 @@ and the [Messaging API](#messaging-api).
|
|
59
59
|
* **registry_url**: URL for the schema registry. Either `schema_registry` or
|
60
60
|
`registry_url` must be configured.
|
61
61
|
* **messaging**: An `AvroTurf::Messaging` object to be shared by all generated models.
|
62
|
-
The `build_messaging!` method may be used to create a `Messaging`
|
63
|
-
on the other configuration values.
|
62
|
+
The `build_messaging!` method may be used to create a `Avromatic::Messaging`
|
63
|
+
instance based on the other configuration values.
|
64
64
|
* **logger**: The logger to use for the schema registry client.
|
65
65
|
* [Custom Types](#custom-types)
|
66
66
|
|
@@ -74,6 +74,15 @@ Avromatic.configure do |config|
|
|
74
74
|
end
|
75
75
|
```
|
76
76
|
|
77
|
+
#### Decoding
|
78
|
+
|
79
|
+
* **use_custom_datum_reader**: `Avromatic` includes a modified subclass of
|
80
|
+
`Avro::IO::DatumReader`. This subclass returns additional information about
|
81
|
+
the index of union members when decoding Avro messages. This information is
|
82
|
+
used to optimize model creation when decoding. By default this information
|
83
|
+
is included in the hash returned by the `DatumReader` but can be omitted by
|
84
|
+
setting this option to `false`.
|
85
|
+
|
77
86
|
### Models
|
78
87
|
|
79
88
|
Models are defined based on an Avro schema for a record.
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "avro-salsify-fork", "1.9.0.
|
6
|
-
gem "activesupport", "~> 4.2.
|
7
|
-
gem "activemodel", "~> 4.2.
|
5
|
+
gem "avro-salsify-fork", "1.9.0.3", :require => "avro"
|
6
|
+
gem "activesupport", "~> 4.2.7.1"
|
7
|
+
gem "activemodel", "~> 4.2.7.1"
|
8
8
|
|
9
9
|
gemspec :path => "../"
|
data/gemfiles/rails4_1.gemfile
CHANGED
data/gemfiles/rails4_2.gemfile
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
module Avromatic
|
3
3
|
module IO
|
4
4
|
# Subclass DatumReader to include additional information about the union
|
5
|
-
# index used.
|
5
|
+
# member index used. The code modified below is based on salsify/avro,
|
6
|
+
# branch 'salsify-master' with the tag 'v1.9.0.3'
|
6
7
|
class DatumReader < Avro::IO::DatumReader
|
7
8
|
|
8
9
|
UNION_MEMBER_INDEX = '__avromatic_member_index'.freeze
|
@@ -25,8 +26,7 @@ module Avromatic
|
|
25
26
|
raise SchemaMatchException.new(writers_schema, readers_schema)
|
26
27
|
end
|
27
28
|
|
28
|
-
# function dispatch for reading data based on type of writer's
|
29
|
-
# schema
|
29
|
+
# function dispatch for reading data based on type of writer's schema
|
30
30
|
datum = case writers_schema.type_sym
|
31
31
|
when :null; decoder.read_null
|
32
32
|
when :boolean; decoder.read_boolean
|
@@ -46,6 +46,8 @@ module Avromatic
|
|
46
46
|
raise AvroError.new("Cannot read unknown schema type: #{writers_schema.type}")
|
47
47
|
end
|
48
48
|
|
49
|
+
# Allow this code to be used with an official Avro release or the
|
50
|
+
# avro-salsify-fork that includes logical_type support.
|
49
51
|
if readers_schema.respond_to?(:logical_type)
|
50
52
|
readers_schema.type_adapter.decode(datum)
|
51
53
|
else
|
@@ -53,7 +55,7 @@ module Avromatic
|
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
|
-
# Override to specify initial record that may contain union index
|
58
|
+
# Override to specify an initial record that may contain union index
|
57
59
|
def read_record(writers_schema, readers_schema, decoder, initial_record = {})
|
58
60
|
readers_fields_hash = readers_schema.fields_hash
|
59
61
|
read_record = Avromatic.use_custom_datum_reader ? initial_record : {}
|
data/lib/avromatic/messaging.rb
CHANGED
@@ -2,7 +2,7 @@ require 'avro_turf/messaging'
|
|
2
2
|
require 'avromatic/io/datum_reader'
|
3
3
|
|
4
4
|
module Avromatic
|
5
|
-
# Subclass AvroTurf::Messaging to use a custom DatumReader
|
5
|
+
# Subclass AvroTurf::Messaging to use a custom DatumReader for decode.
|
6
6
|
class Messaging < AvroTurf::Messaging
|
7
7
|
def decode(data, schema_name: nil, namespace: @namespace)
|
8
8
|
readers_schema = schema_name && @schema_store.find(schema_name, namespace)
|
@@ -24,7 +24,7 @@ module Avromatic
|
|
24
24
|
@schemas_by_id[schema_id] = Avro::Schema.parse(schema_json)
|
25
25
|
end
|
26
26
|
|
27
|
-
# The following line
|
27
|
+
# The following line differs from the parent class to use a custom DatumReader
|
28
28
|
reader = Avromatic::IO::DatumReader.new(writers_schema, readers_schema)
|
29
29
|
reader.read(decoder)
|
30
30
|
end
|
data/lib/avromatic/version.rb
CHANGED
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.14.0
|
4
|
+
version: 0.14.0
|
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-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro
|
@@ -289,9 +289,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
289
289
|
version: '0'
|
290
290
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
291
291
|
requirements:
|
292
|
-
- - "
|
292
|
+
- - ">="
|
293
293
|
- !ruby/object:Gem::Version
|
294
|
-
version:
|
294
|
+
version: '0'
|
295
295
|
requirements: []
|
296
296
|
rubyforge_project:
|
297
297
|
rubygems_version: 2.6.8
|