jackdaw

https://github.com/FundingCircle/jackdaw
2021-03-10T18:58:56.007200Z

Does jackdaw have support for json-schema serdes or could anyone point me to any examples of how to build a json-schema serdes for jackdaw?

2021-03-10T20:27:53.008900Z

What would you want it to do? Simply validate messages against some schema or are you thinking about something which keeps track of versions and checks compatibility like the confluent schema registry?

2021-03-10T20:35:28.011100Z

Mainly the former. My issue is that I’ve got a topic with plain old json messages that I want to write to an aws lambda connector that requires json-schema formatted messages (or avro). If you pass in plain json it munges the data so I need some sort of schema solution.

2021-03-10T20:36:22.012200Z

Today I learned that json and json schema aren’t binary compatible. I guess my other solution would be to do avro or protobuf.

2021-03-10T20:36:55.013Z

https://json-schema.org/ is this what you mean by json-schema?

2021-03-10T20:38:01.014300Z

Not json schema as in “a json schema” but there is an actual format for the data that isn’t just json strings.

2021-03-10T20:40:49.015900Z

Or, do you have a simple example of using avro in clojure? I may just do that if it’s pretty straighforward.

2021-03-10T20:41:59.017200Z

Is it as simple as registering a serdes using https://cljdoc.org/d/fundingcircle/jackdaw/0.7.6/api/jackdaw.serdes.avro.confluent? That seems way to easy.

2021-03-10T20:42:50.017900Z

Yeah that's pretty much it. But you need to have a schema-registry to make that work

2021-03-10T20:43:10.018500Z

I am using the confluent registry.

2021-03-10T20:43:26.019Z

Does it handle everything over the wire?

2021-03-10T20:43:32.019200Z

Seems magic.

2021-03-10T20:44:22.020Z

It does handle the wire format.

2021-03-10T20:47:10.021200Z

An alternative option for avro is https://github.com/cddr/edn-avro. In the README I tried to explain the rationale for the different approach.

2021-03-10T20:49:55.021500Z

cool

2021-03-10T20:50:07.021800Z

I’ll check it out. Thanks!

2021-03-10T21:03:45.023Z

What is the correct way to invoke this:

(def serde-resolver
  (partial
    resolver/serde-resolver
    :schema-registry-url
    "<https://schemaregistry.aws.confluent.cloud>"))
Something like: (serde-resolver {:serde-keyword ...}) ?

2021-03-10T21:06:25.024Z

Actually, I think jackdaw.serdes.avro.confluent is more what I want. Is the schema param the actual schema itself or the name of the schema in the registry?

2021-03-10T21:07:29.024600Z

(avro-confluent/serde
  "<https://schemaregistry.aws.confluent.cloud>"
  "orders-value"
  false)
Seems to want a map or something.

2021-03-10T21:17:11.025200Z

I guess it’s the raw string for the schema. Shouldn’t it look that up from the registry?

2021-03-10T21:28:22.026500Z

It needs the schema only for the producer side. It's a bit of a wart that the interface makes you specify for both

2021-03-10T21:31:13.029700Z

Your producer should probably have access to the schema either via JSON stored as a resource, or via the class generated by the avro compiler

2021-03-10T21:37:12.030200Z

With edn-avro do you not specify a serdes or do you use it as a serdes?

2021-03-10T21:39:27.031600Z

So just:

;This
{:topic-name         "my-topic-name"
 :partition-count    1
 :replication-factor 3}

;vs something like this
{:topic-name         "my-topic-name"
 :partition-count    1
 :replication-factor 3
 :key-serde   (avro-serdes/serde)
 :value-serde (avro-serdes/serde)}