Skip to content

Commit

Permalink
[lint] Remove unused bindings
Browse files Browse the repository at this point in the history
Only left the more tricky ones which will be tackled in a later commit
  • Loading branch information
Gilles Philippart committed Jun 7, 2022
1 parent 6a2aa1d commit aff8e0e
Show file tree
Hide file tree
Showing 29 changed files with 141 additions and 165 deletions.
2 changes: 1 addition & 1 deletion src/jackdaw/admin.clj
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
{:pre [(client? client)
(sequential? topics)]}
(->> @(describe-topics* client (map :topic-name topics))
(every? (fn [[topic-name {:keys [partition-info]}]]
(every? (fn [[_topic-name {:keys [partition-info]}]]
(every? (fn [part-info]
(and (boolean (:leader part-info))
(seq (:isr part-info))))
Expand Down
2 changes: 1 addition & 1 deletion src/jackdaw/client.clj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
Callbacks are `void`, so the return value is ignored."
^Callback [on-completion]
(reify Callback
(onCompletion [this record-meta exception]
(onCompletion [_this record-meta exception]
(on-completion record-meta exception))))

(defn send!
Expand Down
16 changes: 8 additions & 8 deletions src/jackdaw/client/partitioning.clj
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

(defn default-partition
"The kafka default partitioner. As a `::partition-fn`"
[{:keys [topic-name key-serde]} key value partitions]
[{:keys [topic-name key-serde]} key _value partitions]
(let [key-bytes (.serialize (.serializer ^Serde key-serde) topic-name key)]
(default-partitioner* key-bytes partitions)))

Expand Down Expand Up @@ -92,11 +92,11 @@
(partition-fn t key value %)
(->ProducerRecord producer t % key value))
(jd/->ProducerRecord t key value)))
([^Producer producer topic partition key value]
([^Producer _producer topic partition key value]
(jd/->ProducerRecord topic (int partition) key value))
([^Producer producer topic partition timestamp key value]
([^Producer _producer topic partition timestamp key value]
(jd/->ProducerRecord topic partition timestamp key value))
([^Producer producer topic partition timestamp key value headers]
([^Producer _producer topic partition timestamp key value headers]
(jd/->ProducerRecord topic partition timestamp key value headers)))

(defn produce!
Expand All @@ -108,15 +108,15 @@
([producer topic value]
(jc/send! producer
(->ProducerRecord producer topic value)))
([producer topic key value]
([producer topic _key value]
(jc/send! producer
(->ProducerRecord producer topic value)))
([producer topic partition key value]
([producer topic partition _key value]
(jc/send! producer
(->ProducerRecord producer topic partition topic value)))
([producer topic partition timestamp key value]
([producer topic partition timestamp _key value]
(jc/send! producer
(->ProducerRecord producer topic partition timestamp topic value)))
([producer topic partition timestamp key value headers]
([producer topic partition timestamp _key value headers]
(jc/send! producer
(->ProducerRecord producer topic partition timestamp topic value headers))))
6 changes: 2 additions & 4 deletions src/jackdaw/data/common.clj
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@
(TopicPartition. topic-name (int partition)))

(defn map->TopicPartition
"Given a `::topic-parititon`, build an equivalent `TopicPartition`.
"Given a `topic-partition`, build an equivalent `TopicPartition`.
Inverts `(datafy ^TopicPartition tp)`."
[{:keys [topic-name
partition]
:as m}]
[{:keys [partition] :as m}]
(->TopicPartition m partition))

(defn->data TopicPartition->data [^TopicPartition tp]
Expand Down
3 changes: 1 addition & 2 deletions src/jackdaw/data/consumer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@
{:offset (.offset ots)
:timestamp (.timestamp ots)})

(defn map->OffsetAndTimestamp
[{:keys [offset timestamp] :as m}]
(defn map->OffsetAndTimestamp [m]
(->OffsetAndTimestamp m))

(defn as-OffsetAndTimestamp
Expand Down
6 changes: 3 additions & 3 deletions src/jackdaw/data/producer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@
required. The third arity allows a user to provide a checksum. This
arity may be removed in the future pending further breaking changes
to the Kafka APIs."
([{:keys [:topic-name] :as t} partition offset timestamp key-size value-size]
([t partition offset timestamp key-size value-size]
(RecordMetadata. (->TopicPartition t partition)
offset 0 ;; Force absolute offset
timestamp
nil ;; No checksum, it's deprecated
^Integer (when key-size (int key-size))
^Integer (when value-size (int value-size))))
([{:keys [:topic-name] :as t} partition base-offset relative-offset timestamp
([t partition base-offset relative-offset timestamp
key-size value-size]
(RecordMetadata. (->TopicPartition t partition)
base-offset
Expand All @@ -98,7 +98,7 @@
nil ;; No checksum, it's depreciated
^Integer (when key-size (int key-size))
^Integer (when value-size (int value-size))))
([{:keys [:topic-name] :as t} partition base-offset relative-offset timestamp checksum
([t partition base-offset relative-offset timestamp checksum
key-size value-size]
(RecordMetadata. (->TopicPartition t partition)
base-offset
Expand Down
25 changes: 11 additions & 14 deletions src/jackdaw/serdes/avro.clj
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
(try
(and (number? x)
(coercion-fn (bigint x)))
(catch RuntimeException e
(catch RuntimeException _e
false)))

(defrecord DoubleType []
Expand Down Expand Up @@ -260,12 +260,14 @@

(defrecord SchemalessType []
SchemaCoercion
(match-clj? [_ x]
(match-clj? [_schema-type _clj-data]
true)
(match-avro? [_ x]
(match-avro? [_schema-type _avro-data]
true)
(avro->clj [_ x] x)
(clj->avro [_ x path] x))
(avro->clj [_schema-type avro-data]
avro-data)
(clj->avro [_schema-type clj-data _path]
clj-data))

;; UUID :disapprove:

Expand All @@ -278,7 +280,7 @@
(avro->clj [_ uuid-utf8]
(try
(UUID/fromString (str uuid-utf8))
(catch Exception e
(catch Exception _e
(str uuid-utf8))))
(clj->avro [this uuid path]
(validate-clj! this uuid path "uuid")
Expand Down Expand Up @@ -639,17 +641,14 @@
(get @coercion-cache avro-schema)))))

(defn- coercion-type
[avro-schema {:keys [type-registry
coercion-cache] :as coercion-stack}]
[avro-schema coercion-stack]
((schema->coercion coercion-stack) avro-schema))

(defn as-json
"Returns the json representation of the supplied `edn+avro`
`edn+avro` is an avro object represented as an edn object (compatible with the jackdaw avro serde)"
[{:keys [type-registry
avro-schema
coercion-cache] :as coercion-stack} edn+avro]
[{:keys [avro-schema] :as coercion-stack} edn+avro]
(let [schema (parse-schema-str avro-schema)
record (clj->avro (coercion-type schema coercion-stack) edn+avro [])
out-stream (ByteArrayOutputStream.)
Expand All @@ -665,9 +664,7 @@
"Returns the edn representation of the supplied `json+avro`
`json+avro` is an avro object represented as a json string"
[{:keys [type-registry
coercion-cache
avro-schema] :as coercion-stack} json+avro]
[{:keys [avro-schema] :as coercion-stack} json+avro]
(let [schema (parse-schema-str avro-schema)
decoder (.jsonDecoder ^DecoderFactory (DecoderFactory.)
^Schema schema
Expand Down
8 changes: 4 additions & 4 deletions src/jackdaw/streams/extras.clj
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@

(^void onBatchRestored [_
^TopicPartition topicPartition
^String storeName
^long batchEndOffset
^long numRestored]
^String _storeName
^long _batchEndOffset
^long _numRestored]
(log/warnf "Restored a batch from (%s.%d)"
(.topic topicPartition) (.partition topicPartition)))
(^void onRestoreEnd [_
^TopicPartition topicPartition
^String storeName
^long totalRestored]
^long _totalRestored]
(let [start-date (get @restore-tracker storeName)
elapsed-sec (.getSeconds (Duration/between start-date
(Instant/now)))]
Expand Down
42 changes: 21 additions & 21 deletions src/jackdaw/streams/lambdas.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

(deftype FnAggregator [aggregator-fn]
Aggregator
(apply [this agg-key value aggregate]
(apply [_this agg-key value aggregate]
(aggregator-fn aggregate [agg-key value])))

(defn aggregator
Expand All @@ -28,7 +28,7 @@

(deftype FnForeachAction [foreach-action-fn]
ForeachAction
(apply [this key value]
(apply [_this key value]
(foreach-action-fn [key value])
nil))

Expand All @@ -39,7 +39,7 @@

(deftype FnInitializer [initializer-fn]
Initializer
(apply [this]
(apply [_this]
(initializer-fn)))

(defn initializer
Expand All @@ -49,7 +49,7 @@

(deftype FnKeyValueMapper [key-value-mapper-fn]
KeyValueMapper
(apply [this key value]
(apply [_this key value]
(key-value (key-value-mapper-fn [key value]))))

(defn key-value-mapper
Expand All @@ -59,7 +59,7 @@

(deftype FnSelectKeyValueMapper [select-key-value-mapper-fn]
KeyValueMapper
(apply [this key value]
(apply [_this key value]
(select-key-value-mapper-fn [key value])))

(defn select-key-value-mapper
Expand All @@ -70,7 +70,7 @@

(deftype FnKeyValueFlatMapper [key-value-flatmapper-fn]
KeyValueMapper
(apply [this key value]
(apply [_this key value]
(mapv key-value (key-value-flatmapper-fn [key value]))))

(defn key-value-flatmapper
Expand All @@ -83,7 +83,7 @@

(deftype FnMerger [merger-fn]
Merger
(apply [this agg-key aggregate1 aggregate2]
(apply [_this agg-key aggregate1 aggregate2]
(merger-fn agg-key aggregate1 aggregate2)))

(defn merger
Expand All @@ -93,7 +93,7 @@

(deftype FnPredicate [predicate-fn]
Predicate
(test [this key value]
(test [_this key value]
(boolean (predicate-fn [key value]))))

(defn predicate
Expand All @@ -103,7 +103,7 @@

(deftype FnReducer [reducer-fn]
Reducer
(apply [this value1 value2]
(apply [_this value1 value2]
(reducer-fn value1 value2)))

(defn reducer
Expand All @@ -113,7 +113,7 @@

(deftype FnValueJoiner [value-joiner-fn]
ValueJoiner
(apply [this value1 value2]
(apply [_this value1 value2]
(value-joiner-fn value1 value2)))

(defn value-joiner
Expand All @@ -123,7 +123,7 @@

(deftype FnValueMapper [value-mapper-fn]
ValueMapper
(apply [this value]
(apply [_this value]
(value-mapper-fn value)))

(defn value-mapper
Expand All @@ -133,7 +133,7 @@

(deftype FnStreamPartitioner [stream-partitioner-fn]
StreamPartitioner
(partition [this topic-name key val partition-count]
(partition [_this topic-name key val partition-count]
(stream-partitioner-fn topic-name key val partition-count)))

(defn stream-partitioner
Expand All @@ -157,7 +157,7 @@

(deftype FnProcessorSupplier [processor-supplier-fn]
ProcessorSupplier
(get [this]
(get [_this]
(processor processor-supplier-fn)))

(defn processor-supplier
Expand All @@ -167,7 +167,7 @@

(deftype FnTransformerSupplier [transformer-supplier-fn]
TransformerSupplier
(get [this]
(get [_this]
(transformer-supplier-fn)))

(defn transformer-supplier
Expand All @@ -177,7 +177,7 @@

(deftype FnValueTransformerSupplier [value-transformer-supplier-fn]
ValueTransformerSupplier
(get [this]
(get [_this]
(value-transformer-supplier-fn)))

(defn value-transformer-supplier
Expand All @@ -187,10 +187,10 @@

(deftype FnTransformer [context xfm-fn]
Transformer
(init [this transformer-context]
(init [_this transformer-context]
(reset! context transformer-context))
(close [this])
(transform [this k v]
(close [_this])
(transform [_this k v]
(xfm-fn @context k v)))

(defn transformer-with-ctx
Expand All @@ -211,10 +211,10 @@

(deftype FnValueTransformer [context xfm-fn]
ValueTransformer
(init [this transformer-context]
(init [_this transformer-context]
(reset! context transformer-context))
(close [this])
(transform [this v]
(close [_this])
(transform [_this v]
(xfm-fn @context v)))

(defn value-transformer-with-ctx
Expand Down
2 changes: 1 addition & 1 deletion src/jackdaw/test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
consumer
producer]
java.io.Closeable
(close [this]
(close [_this]
(doseq [hook exit-hooks]
(hook))
(log/info "destroyed test machine")))
Expand Down
6 changes: 3 additions & 3 deletions src/jackdaw/test/commands/base.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
(def command-map
{:stop (constantly true)

:sleep (fn [machine [sleep-ms]]
:sleep (fn [_machine [sleep-ms]]
(Thread/sleep sleep-ms))

:println (fn [machine params]
:println (fn [_machine params]
(println (apply str params)))

:pprint (fn [machine params]
:pprint (fn [_machine params]
(pprint/pprint params))

:do (fn [machine [do-fn]]
Expand Down
2 changes: 1 addition & 1 deletion src/jackdaw/test/commands/write.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

(set! *warn-on-reflection* true)

(defn default-partition-fn [topic-map topic-name k v partition-count]
(defn default-partition-fn [topic-map _topic-name k _v partition-count]
(int (partitioning/default-partition topic-map k nil partition-count)))

(defn create-message [topic-map message opts]
Expand Down
Loading

0 comments on commit aff8e0e

Please sign in to comment.