forked from mhjort/clojider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples.clj
49 lines (40 loc) · 1.52 KB
/
examples.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
(ns clojider.examples
(:require [clojure.core.async :refer [chan go >!]]
[org.httpkit.client :as http]))
(def base-url "http://clj-gatling-demo-server.herokuapp.com")
(defn- http-get [url _]
(let [response (chan)
check-status (fn [{:keys [status]}]
(go (>! response (= 200 status))))]
(http/get (str base-url url) {} check-status)
response))
(defn- http-get-with-ids [url ids {:keys [user-id]}]
(let [response (chan)
check-status (fn [{:keys [status]}]
(go (>! response (= 200 status))))
id (nth ids user-id)]
(http/get (str base-url url id) {} check-status)
response))
(def ping
(partial http-get "/ping"))
(def ping-simulation
{:name "Ping simulation"
:scenarios [{:name "Ping scenario"
:steps [{:name "Ping Endpoint" :request ping}]}]})
(def article-read
(partial http-get-with-ids "/metrics/article/read/" (cycle (range 100 200))))
(def program-start
(partial http-get-with-ids "/metrics/program/start/" (cycle (range 200 400))))
(def metrics-simulation
{:name "Metrics simulation"
:scenarios [{:name "Article read scenario"
:weight 2
:steps [{:name "Article read request"
:request article-read}]}
{:name "Program start scenario"
:weight 1
:steps [{:name "Program start request"
:request program-start}]}]})
(def simulations
{:ping ping-simulation
:metrics metrics-simulation})