Liking cljdoc? Tell your friends :D

taoensso.telemere.sockets

Basic TCP/UDP socket handlers.

handler:tcp-socketclj

(handler:tcp-socket {:keys [socket-opts output-fn]
                     :or {output-fn (utils/format-signal-fn)}})
Experimental, subject to change.

Returns a (fn handler [signal]) that:
  - Takes a Telemere signal (map).
  - Sends the signal as a string to specified TCP socket.

Can output signals as human or machine-readable (edn, JSON) strings.

Options:
  `:socket-opts` - {:keys [host port ssl? connect-timeout-msecs]}
    `:host`      - Destination TCP socket hostname string
    `:port`      - Destination TCP socket port     int
    `:ssl?`      - Use SSL/TLS (default false)
    `:connect-timeout-msecs` - Connection timeout (default 3000 msecs)

  `:output-fn`   - (fn [signal]) => string, see `format-signal-fn` or `pr-signal-fn`

Limitations:
  - Failed writes will be retried only once.
  - Writes lock on a single underlying socket, so IO won't benefit from adding
    extra handler threads. Let me know if there's demand for socket pooling.
source

handler:udp-socketclj

(handler:udp-socket {:keys [socket-opts output-fn truncation-warning-fn]
                     :or {socket-opts {:max-packet-bytes 512}
                          output-fn (utils/format-signal-fn)}})
Experimental, subject to change. Feedback welcome!

Returns a (fn handler [signal]) that:
  - Takes a Telemere signal (map).
  - Sends the signal as a string to specified UDP socket.

Can output signals as human or machine-readable (edn, JSON) strings.

Options:
  `:socket-opts`        - {:keys [host port max-packet-bytes]}
    `:host`             - Destination UDP socket hostname string
    `:port`             - Destination UDP socket port     int
    `:max-packet-bytes` - Max packet size (in bytes) before truncating output (default 512)

  `:output-fn`             - (fn [signal]) => string, see `format-signal-fn` or `pr-signal-fn`
  `:truncation-warning-fn` - Optional (fn [{:keys [max actual signal]}]) to call whenever
                             output is truncated. Should be appropriately rate-limited!

Limitations:
  - Due to UDP limitations, truncates output to `max-packet-bytes`!
  - Failed writes will be retried only once.
  - Writes lock on a single underlying socket, so IO won't benefit from adding
    extra handler threads. Let me know if there's demand for socket pooling.
  - No DTLS (Datagram Transport Layer Security) support,
    please let me know if there's demand.
source

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

× close