Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added default handlers. #79

Merged
merged 1 commit into from
Oct 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev-resources/src/meson/dev.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
[meson.protobuf :as protobuf]
[meson.protobuf.mesos :as pb-mesos]
[meson.protobuf.scheduler :as pb-scheduler]
[meson.scheduler.handlers :as scheduler-handlers]
[meson.util :as util]
[meson.util.recordio :as recordio]))

Expand Down
54 changes: 54 additions & 0 deletions src/meson/scheduler/handlers.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
(ns meson.scheduler.handlers
(:require [clojure.tools.logging :as log]))

(defn- debug-trace
[type msg]
(log/debugf "Got %s message." type)
(log/trace msg))

(defmulti default
"Provides a default handling for scheduler messages. No action is taken
by the methods, rather the message types are logged (and the message
contents are traced). The intent is to make available a simple default
for developers creating new frameworks.

For the types of messages that are handled, see the 'Events' section here:

* http://mesos.apache.org/documentation/latest/scheduler-http-api/"
(comp :type last vector))

(defmethod default :subscribed
[state msg]
(debug-trace "SUBSCRIBED" msg))

(defmethod default :offers
[state msg]
(debug-trace "OFFERS" msg))

(defmethod default :offers
[state msg]
(debug-trace "RESCIND" msg))

(defmethod default :offers
[state msg]
(debug-trace "UPDATE" msg))

(defmethod default :offers
[state msg]
(debug-trace "MESSAGE" msg))

(defmethod default :offers
[state msg]
(debug-trace "FAILURE" msg))

(defmethod default :offers
[state msg]
(debug-trace "ERROR" msg))

(defmethod default :heartbeat
[state msg]
(debug-trace "HEARTBEAT" msg))

(defmethod default :default
[state msg]
(debug-trace "unknown type of" msg))