Skip to content
Permalink
8e76c5d6eb
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
53 lines (52 sloc) 2.69 KB
(ns overseer.component.endpoints-session-superuser
(:require [clojure.tools.logging :refer [info error]]
[com.stuartsierra.component :as component]
[datascript.core :as d]
[clojure.core.async :as async]
[de.mpg.shh.util-message-server.helpers :as message-helpers]
[de.mpg.shh.util-overseer.server :as overseer-server]
[overseer.utils :as utils]))
(defrecord EndpointsSessionSuperUser [response-context response-address overseer]
component/Lifecycle
(start [this]
(let [reply (fn [request-channel target message]
(message-helpers/synch-send request-channel
(:host response-context)
(:port response-context)
(:username response-context)
(:password response-context)
response-address
message
:properties (merge {"origin" "overseer-datastore"}
(when-not (nil? target)
{"target" target}))
:timeout 1))
conn-overseer (:conn overseer)
receive (fn [conn-overseer destination data]
(try
(overseer-server/receive conn-overseer (assoc data :destination destination))
(catch Throwable t
(error "failed to receive '" (pr-str destination) "' message " (pr-str data) " " (utils/stack-trace-to-string t)))))]
{
:error
(fn [request-channel message]
(error "error endpoint received: " message))
:workflow-create
(fn [request-channel {data :data :as message}]
(receive conn-overseer :workflow-create data))
:workflow-play
(fn [request-channel {data :data :as message}]
(receive conn-overseer :workflow-play data))
:workflow-pause
(fn [request-channel {data :data :as message}]
(receive conn-overseer :workflow-pause data))
:workflow-clear-failed
(fn [request-channel {data :data :as message}]
(receive conn-overseer :workflow-clear-failed data))
:workflow-clear-all
(fn [request-channel {data :data :as message}]
(receive conn-overseer :workflow-clear-all data))
:workflow-restart-from-step
(fn [request-channel {data :data :as message}]
(receive conn-overseer :workflow-restart-from-step data))
})))