Giter Club home page Giter Club logo

confluent_schema's Introduction

ConfluentSchema elixir workflow

Provides cache and validation for confluent schemas that are pulled from a registry.

It mixes

To provide fast validation for schemas registered remotely on a registry server, for example confluent.cloud.

Installation

def deps do
  [
    {:confluent_schema, "~> 0.1.2"}
  ]
end

Usage

On application.ex:

  def start(_type, _args) do
    opts = [
      period: :timer.seconds(10),
      debug: true,
      base_url: "https://foobar.region.aws.confluent.cloud",
      username: "key",
      password: "api secret",
    ]

    children = [
      {ConfluentSchema, opts}
    ]

    supervisor_opts = [strategy: :one_for_one, name: MyApp.Supervisor]
    Supervisor.start_link(children, supervisor_opts)
  end

Then you can use confluent schema registry to validate payloads for a subject:

payload = %{foo: "bar"}
ConfluentSchema.validate(payload, "my-subject")

Check out ConfluentSchema.child_spec/1 for documentation about all options.

Test

On test or dev environment, it is common to not have internet access. In this case, we want to load the schemas from local files.

To achieve this, put a subject_name.json file inside priv/confluent_schema/, or run the mix confluent_schema.download mix task defined in Mix.Tasks.ConfluentSchema.Download:

$ mix confluent_schema.download \
  --app-name my_app \
  --username API_KEY \
  --password API_SECRET \
  --base-url https://foobar.region.aws.confluent.cloud 

And configure your application like this:

  # application.ex

  children = [
    {ConfluentSchema, Application.fetch_env!(:my_app, :confluent_schema)}
  ]

  # config.exs
  config :my_app, :confluent_schema, local: true, app_name: :my_app

Now, when ConfluentSchema starts, it will load the schemas from your app's priv/confluent_schema/ directory.

confluent_schema's People

Contributors

alexandremcosta avatar

Watchers

Jerry Luk avatar  avatar  avatar Doga Tuncay avatar Deric Walintukan avatar Kostas Georgiou avatar

confluent_schema's Issues

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.