-
Notifications
You must be signed in to change notification settings - Fork 7
/
context.clj
60 lines (45 loc) · 1.56 KB
/
context.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
(ns unleash-client-clojure.context
(:import [no.finn.unleash UnleashContext UnleashContext$Builder]))
(defn build ^UnleashContext
[& fs]
(let [bldr (UnleashContext$Builder.)]
(.build ^UnleashContext$Builder
(reduce
(fn
([] bldr)
([bldr f]
(f bldr)))
bldr
fs))))
(defn get-app-name [^UnleashContext ctx]
(.get (.getAppName ctx)))
(defn get-environment [^UnleashContext ctx]
(.get (.getEnvironment ctx)))
(defn get-user-id [^UnleashContext ctx]
(.get (.getUserId ctx)))
(defn get-session-id [^UnleashContext ctx]
(.get (.getSessionId ctx)))
(defn get-remote-address [^UnleashContext ctx]
(.get (.getRemoteAddress ctx)))
(defn get-property [^UnleashContext ctx ^String property-name]
(.get (.getProperties ctx) property-name))
(defn get-by-name [^UnleashContext ctx ^String contextName]
(.get (.getByName ctx contextName)))
(defn app-name [^String app-name]
(fn [^UnleashContext$Builder bldr]
(.appName bldr app-name)))
(defn environment [^String environment]
(fn [^UnleashContext$Builder bldr]
(.environment bldr environment)))
(defn user-id [^String id]
(fn [^UnleashContext$Builder bldr]
(.userId bldr id)))
(defn session-id [^String id]
(fn [^UnleashContext$Builder bldr]
(.sessionId bldr id)))
(defn remote-address [^String address]
(fn [^UnleashContext$Builder bldr]
(.remoteAddress bldr address)))
(defn add-property [^String name ^String value]
(fn [^UnleashContext$Builder bldr]
(.addProperty bldr name value)))