Fork me on GitHub
#jackdaw
<
2019-07-24
>
xi13:07:29

@cddr seems like I'm a bit confused about serdes. I checked src/jackdaw/specs.clj as you suggested and that says that :key-serde must be a map EG {:serde-keyword ...}. OTOH looking at examples/simple-ledger/src/simple_ledger.clj, topic-config defaults :key-serde to (jse/serde). The problem I'm trying to resolve is that although I've passed a (Serdes/serdeFrom (key-serializer) (key-deserializer))) as :key-serde, it seems to be falling back to the default key serializer. Any ideas please?

cddr13:07:32

Ah yeah. The serdes are definitely the most confusing part of this thing. The {:serde-keyword ...} syntax is to be used in conjunction with the resolver which will use the data to find a schema required for the serde to actually serialize a message. When the resolver runs, it assigns an actual Serde object to the :key-serde/:value-serde slots.

xi13:07:02

Is the resolver so you can set serdes from config files or something? I'm not using it so it should be OK to put real serdes into :key-serde/:value-serde and pass that topic map to EG j/kstream?

xi13:07:22

This is my code; I should maybe mention I'm using this in a TestTopologyDriver

(-> (j/kstream b (sut/topic sut/account-topic))
         (j/group-by (fn [[_k v]] (log/spy (get v ::pool/id))))
         (j/aggregate (constantly {})
                      (fn [a [_k v]] (merge a v))
                      (sut/topic "account-numbers.account-rekey")))

xi13:07:47

The account-topic works OK but it fails to aggregate

xi13:07:08

(aggregate
    [_ initializer-fn aggregator-fn {:keys [topic-name value-serde]}]
I think we have a winner 😂

party-corgi 4
xi13:07:32

Any idea why the key-serde might have been ignored here please?

👀 4
xi13:07:20

and would you like a PR?

cddr13:07:24

I think it's just because we haven't needed it ourselves yet. When we upgraded versions of kafka, we did "just enough" to get it working without really adding support for all the stuff that has been added. Looks like someone did add (doto (Materialized/as ^String topic-name) (.withValueSerde value-serde))))) but didn't allow for the key serde to be customized at the same time. But yes, if you have the time a PR would be great. One of my colleagues recently made a spreadsheet to document all the missing functionality so it will help us get that cleaned up. Here's the contributing guide if you hadn't noticed it already. https://github.com/FundingCircle/jackdaw/blob/master/CONTRIBUTING.md

👍 4
xi14:07:26

Do the Jackdaw tests rely on a local Kafka?

cddr14:07:01

Some of them do. And we use circleci docker containers to provide that at CI time. https://github.com/FundingCircle/jackdaw/blob/master/.circleci/config.yml#L43 For dev time, I tend to use docker-compose.

xi14:07:07

Do you have the commands available please?

xi14:07:51

I've not used circle ci or docker-compose very much

cddr14:07:32

Here's an old PR which tried to add docker-compose to the project. https://github.com/FundingCircle/jackdaw/pull/55/ If you take the docker-compose.yml file from there, copy it to your repo and gitignore it globally, then you should be able to do docker-compose up -d to get a working kafka cluster with all the services required by the tests. Beware that one of the rest-proxy tests is a little bit flakey at the moment so if that fails don't worry.

xi14:07:48

OK thanks

cddr15:07:13

When you say in the PR > This doesn't seem to work... What do you mean? You might want to try adding a test. There's a few already for the various types of aggregations so you might be able to copy one of those and adapt it to the problem of using a custom key-serde. https://github.com/FundingCircle/jackdaw/blob/master/test/jackdaw/streams_test.clj#L713