This repository has been archived by the owner on Jun 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
91 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,8 @@ | |
[lambdacd.steps.manualtrigger :as manualtrigger] | ||
[lambdacd.steps.support :as support] | ||
[clojure.core.async :as async] | ||
[clojure.tools.logging :as log])) | ||
[clojure.tools.logging :as log] | ||
[lambdacd.debug.core-async :as async-debug])) | ||
|
||
;; Let's define some constants | ||
(def backend-repo "[email protected]:flosell/todo-backend-compojure.git") | ||
|
@@ -49,10 +50,7 @@ | |
(doall (for [i (range 800)] | ||
(support/if-not-killed ctx | ||
(do | ||
(log/info (str "trying write to " (:result-channel ctx) " " i)) | ||
(async/>!! (:result-channel ctx) [:xyz i]) | ||
(log/info (str "tried write to " (:result-channel ctx) " " i))) | ||
))) | ||
(async-debug/>!! (:result-channel ctx) [:xyz i]))))) | ||
{:status :success})) | ||
|
||
(defn log-lots-of-output-in-chaining [args ctx] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
(ns lambdacd.debug.core-async | ||
(:require [clojure.core.async :as async]) | ||
(:import (java.util UUID) | ||
(org.apache.commons.lang.exception ExceptionUtils))) | ||
|
||
(defonce chans (atom {})) | ||
(defonce open-writes (atom {})) | ||
|
||
(defn reset-state [] | ||
(reset! chans {}) | ||
(reset! open-writes {})) | ||
|
||
(defn channels-with-open-writes [] | ||
(let [mapper (fn [[k v]] | ||
(assoc v :name (get @chans (:port v))))] | ||
(map mapper @open-writes))) | ||
|
||
(defn open-writes-infos[] | ||
(doall (map #(println (:name %) (:trace %)) (channels-with-open-writes))) | ||
(doall (map #(println (:name %)) (channels-with-open-writes)))) | ||
|
||
(defn chan [name & args] | ||
(let [ch (apply async/chan args)] | ||
(swap! chans #(assoc % ch name)) | ||
ch)) | ||
|
||
(defn stacktrace [] | ||
(ExceptionUtils/getStackTrace (Exception.))) | ||
|
||
(defn before-write [write-id port val] | ||
(let [payload {:port port | ||
:trace (stacktrace)}] | ||
(swap! open-writes #(assoc % write-id payload)))) | ||
|
||
(defn after-write [write-id port val] | ||
(swap! open-writes #(dissoc % write-id))) | ||
|
||
(defmacro >! [port val] | ||
`(let [write-id# (UUID/randomUUID)] | ||
(before-write write-id# ~port ~val) | ||
(async/>! ~port ~val) | ||
(after-write write-id# ~port ~val))) | ||
|
||
(defn >!! [port val] | ||
(let [write-id (UUID/randomUUID)] | ||
(before-write write-id port val) | ||
(async/>!! port val) | ||
(after-write write-id port val))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters