Skip to content

Commit

Permalink
fixup! [wip]
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenet committed Jan 27, 2025
1 parent c519ecb commit e966826
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
1 change: 0 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.2"}
exoscale/ex {:mvn/version "0.4.1"}
com.stuartsierra/component {:mvn/version "1.0.0"}
exoscale/telex {:mvn/version "0.1.7"}
io.prometheus/simpleclient {:mvn/version "0.12.0"}
io.prometheus/simpleclient_common {:mvn/version "0.12.0"}
io.prometheus/simpleclient_dropwizard {:mvn/version "0.12.0"}
Expand Down
22 changes: 7 additions & 15 deletions src/spootnik/reporter/alert.clj
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
(ns spootnik.reporter.alert
(:require [clojure.spec.alpha :as s]
(:require [aleph.http :as http]
[clojure.spec.alpha :as s]
[exoscale.ex :as ex]
[exoscale.telex :as http]
[jsonista.core :as json])
(:import (java.net.http HttpClient)
(java.time Instant)))

(defprotocol Alert
(-send! [client alerts opts]))

(s/def ::named (s/or :k ident? :s string?))

(s/def :spootnik.reporter.alert.annotation/key ::named)
Expand Down Expand Up @@ -54,14 +51,9 @@
generator-url
(assoc :generatorURL generator-url))))

(extend-protocol Alert
HttpClient
(-send! [client alert opts]
(http/request client
{:url "/api/v2/alerts"
:body (json/write-value-as-string
{:alerts [(->alert (into alert opts))]})})))

(defn send!
([client alert opts]
(-send! client alert opts)))
([alert opts]
(http/post "/api/v2/alerts"
(into {:body (json/write-value-as-string
{:alerts [(->alert (into alert opts))]})}
opts))))

0 comments on commit e966826

Please sign in to comment.