avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1764) Allow YAML files as Map to be added in RecordSchema
Date Mon, 30 Nov 2015 22:18:10 GMT

    [ https://issues.apache.org/jira/browse/AVRO-1764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15032601#comment-15032601
] 

ASF GitHub Bot commented on AVRO-1764:
--------------------------------------

GitHub user fltiago opened a pull request:

    https://github.com/apache/avro/pull/61

    AVRO-1764: YAML loader to add metadata properties on RecordSchema

    Add to RecordSchema attribute metadata to load a Map from a YAML file.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/geteloquent/avro metadata-avro

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/avro/pull/61.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #61
    
----
commit 2dd91c2d47f8ad8dfd4560d82dbfbc9aa56ba0b6
Author: Tiago Lima <fltiago@gmail.com>
Date:   2015-11-30T22:12:06Z

    AVRO-1764: YAML loader to add metadata properties on RecordSchema
    
    Add to RecordSchema attribute metadata to load a Map from a YAML file.

----


> Allow YAML files as Map to be added in RecordSchema
> ---------------------------------------------------
>
>                 Key: AVRO-1764
>                 URL: https://issues.apache.org/jira/browse/AVRO-1764
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.9.0
>            Reporter: Tiago Lima
>
> I did this little improvement to allow me to add annotations to generated files. 
> So, if I want to add persistence's annotation to the generated files, I will have to
add some "javaAnnotations` in schema. This is a bad idea, because my client also will have
these annotations. Maybe I just have to create a *new layer* using the *Decorator Pattern*
to add those annotations, but I don't want this level of complexity in my application. I just
want that my Avro Objects have some custom annotations.
> Because of that, we should have the opportunity to add custom configuration to be accessed
via velocity template (record.vm). So, I added an attribute in RecordSchema (called metadata)
that read an YAML file, which has the same name of the Record, to be loaded as a Map. Now,
I just have to overwrite the record.vm from velocity to call metadata.
> {code:title=record.vm|borderStyle=solid}
> #set ($indexName = $schema.getMetadata().get('persistence').get('elasticsearch').get('indexName'))
> #set ($type = $schema.getMetadata().get('persistence').get('elasticsearch').get('type'))
> @Document(indexName = "$indexName", type = "$type")
> {code}
> This can also be used to add validations and any kind of behaviour to the Avro Object.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message