Skip to content

Instantly share code, notes, and snippets.

@thomascothran
Created March 7, 2025 16:04
Show Gist options
  • Save thomascothran/c6580d503fdc98ca2a4cf99cd83447cf to your computer and use it in GitHub Desktop.
Save thomascothran/c6580d503fdc98ca2a4cf99cd83447cf to your computer and use it in GitHub Desktop.
Mulog tap publisher
{:paths ["."]}
;; ---------------------------------------------------------
;; Mulog Custom Publishers
;; - tap publisher for use with Portal and other tap sources
;; h/t Practicalli - https://practical.li/clojure/data-inspector/portal/#tap-logs-to-portal
;; ---------------------------------------------------------
(ns tap-publisher
(:require
[com.brunobonacci.mulog.buffer :as mulog-buffer]
[portal.api :as p]))
(deftype TapPublisher [buffer transform]
com.brunobonacci.mulog.publisher.PPublisher
(agent-buffer [_] buffer)
(publish-delay [_] 200)
(publish [_ buffer]
(doseq [item (transform (map second (mulog-buffer/items buffer)))]
(tap> item))
(mulog-buffer/clear buffer)))
(defn tap
[{:keys [transform] :as _config}]
(TapPublisher. (mulog-buffer/agent-buffer 10000) (or transform identity)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment