jackdaw icon indicating copy to clipboard operation
jackdaw copied to clipboard

Created a new string namespace in jackdaw.serdes

Open funderbar opened this issue 5 years ago • 1 comments

funderbar avatar Mar 12 '19 14:03 funderbar

I think having lots of different namespaces all with function of the same name (in this case serde) is a bit of an anti-pattern in Clojure and if we're going to re-organize this namespace, I'd prefer if we went in the other direction. To illustrate, consider the case where you want to use a bunch of different serdes in some program....

This would be my preference as a user of jackdaw...

(ns my.cool.prog
  (:require
     [jackdaw.serdes :as serde]))

(def topics
  {:foo {:key-serde (serde/string-serde)
            :value-serde (serde/avro-serde avro-options)}
    :bar {:key-serde (serde/integer-serde)
             :value-serde (serde/edn-serde)}
    :baz {:key-serde (serde/long-serde)
             :value-serde (serde/json-serde)})

vs

(ns my.cool.prog
  (:require
     [jackdaw.serdes.edn :as edn-serde]
     [jackdaw.serdes.string :as string-serde]
     [jackdaw.serdes.json :as json-serde]
     [jackdaw.serdes.avro :as avro-serde]))

(def topics
  {:foo {:key-serde (string-serde/serde)
            :value-serde (avro-serde/serde avro-options)}
    :bar {:key-serde (integer-serde/serde)
             :value-serde (edn-serde/serde)}
    :baz {:key-serde (long-serde/serde)
             :value-serde (json-serde/serde)})

cddr avatar Jun 17 '19 23:06 cddr

Stale PR

99-not-out avatar Nov 15 '22 11:11 99-not-out