Coder Social home page Coder Social logo

excernan_avro's Introduction

excernan_avro

Build Status

An Elixir client for Cernan's Avro source.

Usage

The following example assumes you have an instance of Cernan's Avro source accepting connections on localhost:2002.

schema = ExCernan.Avro.Schema.record(
  "User",
  [ExCernan.Avro.Schema.field("name", :string),
   ExCernan.Avro.Schema.field("favorite_number", :int),
   ExCernan.Avro.Schema.field("favorite_color", :string)],
 [{:namespace, "example.avro"}])

user1 = [{"name", "Foo Bar"}, {"favorite_number", 10}, {"favorite_color", "maroon"}]
user2 = [{"name", "Alice Bob"}, {"favorite_number", 32}, {"favorite_color", "greenish-gold"}]
users = [user1, user2]

# Sync publish users.
# Blocks until Cernan acknowledges the publication.
ExCernan.Avro.publish("example.avro.User", schema, users)

# Async publish users.
ExCernan.Avro.publish("example.avro.User", schema, users, %{:sync => false})

# Async publish users and sequence the publication by the term "fizzbuzz".
# Note - shard_by values must be hashable by phash2.
ExCernan.Avro.publish("example.avro.User", schema, users, %{:sync => false, :shard_by => "fizzbuzz"})

Available Publication Options

As illustrated above, users can control various aspects of how their Avro payloads are published by providing an optional map() to publish.

The following is a full listing of the options currently available by default:

Option Type Spec Description Default
sync boolean() Publish the given data synchronously? true
shard_by undefined or term() Value used to determine which shard / bucket the resulting Avro is published to. Random (undefined)

Configuring Pools

ExCernan.Avro makes use of cerlnan_avro to publish data.

See Configuring Pools for details on pool configuration.

excernan_avro's People

Contributors

pulltab avatar

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.