Liking cljdoc? Tell your friends :D

taoensso.telemere.postal

Email handler using `postal`,
Ref. <https://github.com/drewr/postal>.

a-handler:postalclj

(a-handler:postal)
(a-handler:postal signal)
source

format-signal->subject-fnclj

(format-signal->subject-fn)
(format-signal->subject-fn {:keys [max-len subject-signal-key]
                            :or {max-len 128
                                 subject-signal-key :postal/subject}})
Experimental, subject to change.
Returns a (fn format [signal]) that:
  - Takes a Telemere signal.
  - Returns a formatted email subject like:
    "INFO EVENT :taoensso.telemere.postal/ev-id1 - msg"
source

handler:postalclj

(handler:postal)
(handler:postal {:keys [postal/conn-opts postal/msg-opts format-signal-fn
                        format-signal->subject-fn]
                 :or {format-signal-fn (utils/format-signal->str-fn)
                      format-signal->subject-fn (format-signal->subject-fn)}})
Experimental, subject to change. Feedback welcome!

Needs `postal`,
  Ref. <https://github.com/drewr/postal>.

Returns a (fn handler [signal]) that:
  - Takes a Telemere signal.
  - Sends an email with formatted signal content to the configured recipient.

Useful for emailing important alerts to admins, etc.

NB can incur financial costs!!
See tips section re: protecting against unexpected costs.

Options:

  `:postal/conn-opts` - Map of connection opts provided to `postal`
    Examples:
      {:host "mail.isp.net",   :user "jsmith",           :pass "a-secret"},
      {:host "smtp.gmail.com", :user "jsmith@gmail.com", :pass "a-secret" :port 587 :tls true},
      {:host "email-smtp.us-east-1.amazonaws.com", :port 587, :tls true
       :user "AKIAIDTP........" :pass "AikCFhx1P......."}

  `:postal/msg-opts` - Map of message options
    Examples:
      {:from "foo@example.com",        :to "bar@example.com"},
      {:from "Alice <foo@example.com", :to "Bob <bar@example.com>"},
      {:from "no-reply@example.com",   :to ["first-responders@example.com",
                                              "devops@example.com"],
       :cc "engineering@example.com"
       :X-MyHeader "A custom header"}

  `:format-signal-fn`          - (fn [signal]) => output, see `help:signal-formatters`
  `:format-signal->subject-fn` - (fn [signal]) => email subject string

Tips:

  - Sending emails can incur financial costs!
    Use appropriate dispatch filtering options when calling `add-handler!` to prevent
    handler from sending unnecessary emails!

    At least ALWAYS set an appropriate `:rate-limit` option, e.g.:
      (add-handler! :my-postal-handler (handler:postal {<my-handler-opts})
        {:rate-limit {"Max 1 per min"     [1 (enc/msecs :mins  1)]
                      "Max 3 per 15 mins" [3 (enc/msecs :mins 15)]
                      "Max 5 per hour"    [5 (enc/msecs :hours 1)]}, ...}), etc.

  - Sending emails is slow!
    Use appropriate async dispatch options when calling `add-handler!` to prevent
    handler from blocking signal creator calls, e.g.:
      (add-handler! :my-postal-handler (handler:postal {<my-handler-opts>})
        {:async {:mode :dropping, :buffer-size 128, :n-threads 4} ...}), etc.

  - Ref. <https://github.com/drewr/postal> for more info on `postal` options.
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close