Giter VIP home page Giter VIP logo

kfk-avro-bridge's Introduction

Clojure Avro Brigde for using with Kafka and Schema Registry

CircleCI

This library is designed specifically for converting Clojure data structures to Avro-compatible Java classes (not Avro binary format!) back and forth in order to be able to use Schema Registry's serializers with Kafka and Clojure.

Note, that this library is not an Avro-wrapper for Clojure: for this purpose you might want to use damballa/abracad or asmyczek/simple-avro

Installation

Add this to your favorite build file (project.clj or build.boot)

[io.thdr/kfk.avro-bridge "0.1.0-SNAPSHOT"]

Usage

Notes:

  • All keys in Clojure maps are keywordized and kebab-cased.
  • Enums are keywordized and kebab-cased
  • When converting to Java objects, all keys and enums are snake_cased.

Example:

(ns test-avro
  (:require [thdr.kfk.avro-bridge.core :as avro]
            [cheshire.core :as json]))

(def schema (json/generate-string {:type "record",
                                   :name "user",
								   :fields [{:name "id" :type "int"}
                                             :name "full_name" :type "string"]}))

(def obj (avro/->java (parse-schema schema) 
                      {:id 1 :full-name "John Doe"})) 
;; => <GenericRecord ...>, which can be passed to KafkaAvroSerializer, for example
  
(avro/->clj obj) 
;; => {:id 1 :full-name "John Doe"}

Contributing

Feel free to open an issue or PR

License

Copyright © 2016 Theodore Konukhov [email protected]

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

kfk-avro-bridge's People

Contributors

kfyodor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

akvo

kfk-avro-bridge's Issues

Make a release

Would you be so kind of creating a non-snapshot version of the library?

Thanks a lot,

Dan

enum symbols not getting kebab cased

Repo:

  1. Create an Avro schema of an enum type that has values with underscores in them.
  2. Deserialize payload for the schema and pass the resulting GenericRecord to ->clj for conversion.

Result:
Underscores are not converted to dashes.

Expected:
The comments in the ->clj function imply that enum symbols would be converted to kebab case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.