/
common_config.clj
59 lines (45 loc) · 1.22 KB
/
common_config.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
(in-ns 'jackdaw.data)
(import '[org.apache.kafka.common.config
ConfigResource ConfigResource$Type])
;;; ConfigResource.Type
(def +broker-config-resource-type+
""
ConfigResource$Type/BROKER)
(def +topic-config-resource-type+
""
ConfigResource$Type/TOPIC)
(def +unknown-config-resource-type+
""
ConfigResource$Type/UNKNOWN)
(defn ->ConfigResourceType [o]
(case o
:config-resource/broker +broker-config-resource-type+
:config-resource/topic +topic-config-resource-type+
+unknown-config-resource-type+))
(defn->data ConfigResourceType->data
""
[^ConfigResource$Type crt]
(cond (= +broker-config-resource-type+ crt)
:config-resource/broker
(= +topic-config-resource-type+ crt)
:config-resource/topic
:else
:config-resource/unknown))
;;; ConfigResource
(defn ->ConfigResource
""
[^ConfigResource$Type type ^String name]
(ConfigResource. type name))
(defn ->topic-resource
""
[name]
(->ConfigResource +topic-config-resource-type+ name))
(defn ->broker-resource
""
[name]
(->ConfigResource +broker-config-resource-type+ name))
(defn->data ConfigResource->data
""
[^ConfigResource cr]
{:name (.name cr)
:type (datafy (.type cr))})