|
28 | 28 | {:metadata (.metadata offset-metadata)
|
29 | 29 | :offset (.offset offset-metadata)})
|
30 | 30 |
|
31 |
| - |
32 | 31 | (defn admin-client
|
33 | 32 | "Instanciate an `Admin` from properties"
|
34 | 33 | {:added "3.2.0-1.7"}
|
|
38 | 37 | (dissoc :key.deserializer :value.deserializer :topics))]
|
39 | 38 | (Admin/create ^java.util.Map props*))))
|
40 | 39 |
|
41 |
| - |
42 | 40 | (defn admin-close
|
43 | 41 | "Close the Admin client and release all associated resources.
|
44 | 42 |
|
|
52 | 50 | ([^Admin ac]
|
53 | 51 | (.close ac)))
|
54 | 52 |
|
55 |
| - |
56 | 53 | (defn admin-metrics
|
57 | 54 | "Get the metrics kept by the adminClient"
|
58 | 55 | {:added "3.2.0-1.7"}
|
|
67 | 64 | :tags (.tags name)
|
68 | 65 | :value (.metricValue o)}))))))
|
69 | 66 |
|
70 |
| - |
71 | 67 | (defn describe-cluster
|
72 | 68 | "Get information about the nodes in the cluster,
|
73 | 69 | using the default options."
|
|
81 | 77 | :controller-node (->node (deref (.controller desc)))
|
82 | 78 | :nodes (map ->node (deref (.nodes desc)))})))
|
83 | 79 |
|
84 |
| - |
85 | 80 | (defn list-topics
|
86 | 81 | "List topics for the current `Admin` connection"
|
87 | 82 | {:added "3.2.0-1.7"}
|
|
90 | 85 | (.names)
|
91 | 86 | deref)))
|
92 | 87 |
|
93 |
| - |
94 | 88 | (defn- safely-resolve-field [class f]
|
95 | 89 | (try (.get (.getField class f) nil) (catch Exception _ nil)))
|
96 | 90 | (defn- static-field->props
|
|
109 | 103 | (sorted-map)
|
110 | 104 | m))
|
111 | 105 |
|
112 |
| - |
113 | 106 | (defn- mk-topic-instance
|
114 | 107 | ^NewTopic
|
115 | 108 | [^String topic-name partition-count replication-factor props]
|
|
188 | 181 | :status :kafka.topic/error})))))
|
189 | 182 | (throw (ex-info "Bad Topics spec" (s/explain-data (s/coll-of :kafka.topic/name) topics))))))
|
190 | 183 |
|
191 |
| - |
192 | 184 | (defn delete-topic
|
193 | 185 | "Delete a topic"
|
194 | 186 | {:added "3.2.0-1.7"}
|
195 | 187 | ([^Admin ac topic-name]
|
196 | 188 | (first (delete-topics ac #{topic-name}))))
|
197 | 189 |
|
198 |
| - |
199 | 190 | (defn describe-topics
|
200 | 191 | "Describe some topics in the cluster.
|
201 | 192 |
|
|
214 | 205 | :partitions (map ->topic-partition (.partitions o))}))
|
215 | 206 | (sorted-map))))))
|
216 | 207 |
|
217 |
| - |
218 | 208 | (defn describe-topic
|
219 | 209 | "Describe a topic."
|
220 | 210 | {:added "3.2.0-1.7"}
|
221 | 211 | ([^Admin ac topic]
|
222 | 212 | (first (describe-topic ac #{topic}))))
|
223 | 213 |
|
224 |
| - |
225 | 214 | (defn list-consumer-groups
|
226 | 215 | "List the consumer groups for the current `Admin`
|
227 | 216 | connection"
|
|
235 | 224 | :is-simple-consumer-group (.isSimpleConsumerGroup o)
|
236 | 225 | :state (keyword (.orElse (.state o) "unknown"))})))))
|
237 | 226 |
|
238 |
| - |
239 | 227 | (defn list-consumer-groups-offsets
|
240 | 228 | "List consumer group offsets, if no group id specified,
|
241 | 229 | compute for all the group-id well-known in the current
|
|
263 | 251 | [t (map #(dissoc % :topic-name) v)])
|
264 | 252 | per-topic-offsets))}))))
|
265 | 253 |
|
266 |
| - |
267 | 254 | (defn sum-consumer-groups-offsets
|
268 | 255 | "Sum consumer group offset over all partitions"
|
269 | 256 | {:added "3.2.0-1.7"}
|
|
280 | 267 | :sum (apply + (map #(get-in % [:metadata :offset])
|
281 | 268 | offsets))})))}))))
|
282 | 269 |
|
283 |
| - |
284 | 270 | (defn set-consumer-group-topic-offset
|
285 | 271 | "Alters offsets for the specified group of a specific topic.
|
286 | 272 |
|
|
310 | 296 | second)}
|
311 | 297 | (recur op)))))))
|
312 | 298 |
|
313 |
| - |
314 | 299 | (defn delete-consumer-groups
|
315 | 300 | "Delete consumer groups from the cluster with the default options."
|
316 | 301 | {:added "3.2.0-1.7"}
|
|
327 | 312 | :status :kafka.consumer-group/error
|
328 | 313 | :message (.getMessage e)})))))))
|
329 | 314 |
|
330 |
| - |
331 | 315 | (defn delete-consumer-group
|
332 | 316 | "Delete one consumer group from the cluster
|
333 | 317 | with the default options."
|
|
0 commit comments