                :message (str "Invalid service_status_version. Should be an "
                           "integer but was " level)}))))
 
-(schema/defn ^:always-validate summarize-states
+(schema/defn ^:always-validate summarize-states :- State
   "Given a map of service statuses:
    * if all of the statuses have the same :state, returns that :state
    * if not all of the statuses are the same, returns :unknown"
-  [statuses :- ServicesStatus] :- State
+  [statuses :- ServicesStatus]
   (let [state-set (->> statuses
                        vals
                        (map :state)

    (validation-error-explain schema-failure)
    schema-failure))

(schema/defn check-timeout
  "Given a status level keyword, returns a number of seconds to use as a timeout
  when calling a status function."
  [level :- ServiceStatusDetailLevel] :- schema/Int
  (case level
    :critical 5
    :info 60

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Public

(schema/defn ^:always-validate nominal? :- schema/Bool
  [status :- ServiceStatus]
  (= (:state status) :running))

(schema/defn ^:always-validate all-nominal? :- schema/Bool
  [statuses :- ServicesStatus]
  (every? nominal? (vals statuses)))

