Skip to content

Elixir library to cache and validate confluent schemas from a registry

License

Notifications You must be signed in to change notification settings

alexandremcosta/confluent_schema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConfluentSchema

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.0"}
  ]
end

Usage

On application.ex:

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

    children = [{ConfluentSchema.Server, confluent_schema_opts}]

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

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

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

Use the period option to customize the interval to refresh schemas on the cache. It is 5 minutes by default. Use the debug option to log errors in case schemas aren't correctly fetched from the registry.

About

Elixir library to cache and validate confluent schemas from a registry

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages