 (defn events->combo
   "
   Returns a lazy sequence of combo messages. Each message is at most
-  xymon-max-line long.
+  message-max-length long.
   "
   ([formatter events]
    (events->combo formatter events combo-header combo-header-len))

    (format "disable %s.%s %s %s"
            host service (int (ceil (/ ttl 60))) description)))

(defn *send-line-error-handler*
  "
  Logs given exception as an error message.

  *send-line-error-handler* is the default error handler invoked by
  send-line if none is provided.
  "
  [opts exception]
  (error exception (format "cannot reach xymon host (%s:%s)"
                           (:host opts) (:port opts))))

(defn send-line
  "
  Connects to Xymon server, sends line, then closes the connection.
  This is a blocking operation and should happen on a dedicated
  thread.

  If any exception is raised during the connect/send process, the
  result of (:error-handler opts *send-line-error-handler*) is invoked
  as a function with the exception as its parameter.
  "
  [opts line]
  (let [opts (merge
              {:host "127.0.0.1" :port 1984 :timeout 5
               :error-handler *send-line-error-handler*}
              opts)]
    (try
      (let [addr (InetSocketAddress. (:host opts) (:port opts))

  [opts events]
  (let [formatter (or (:formatter opts) event->status)]
    (doseq [combo-message (events->combo formatter events)]
      (send-message opts combo-message))))

(defn xymon-batch
  "
