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

Provide Default Handler for Scheduler Events #8

Closed
9 tasks done
oubiwann opened this issue Aug 2, 2016 · 1 comment
Closed
9 tasks done

Provide Default Handler for Scheduler Events #8

oubiwann opened this issue Aug 2, 2016 · 1 comment
Assignees
Milestone

Comments

@oubiwann
Copy link
Member

oubiwann commented Aug 2, 2016

Tasks:

  • Identify a good location for the default handlers
  • SUBSCRIBED
  • OFFERS
  • RESCIND
  • UPDATE
  • MESSAGE
  • FAILURE
  • ERROR
  • HEARTBEAT
@oubiwann oubiwann added this to the 0.1.0 milestone Aug 2, 2016
@oubiwann oubiwann mentioned this issue Aug 2, 2016
3 tasks
@oubiwann oubiwann added task and removed feature labels Aug 2, 2016
@oubiwann oubiwann changed the title Implement Scheduler Events Provide Default Handler for Scheduler Events Oct 16, 2016
@oubiwann
Copy link
Member Author

So far:

(defmulti handle-msg
  ""
  (comp :type last vector))

(defmethod handle-msg :subscribed
  [state msg]
  (log/debug "Got SUBSCRIBED message.")
  (log/trace msg))

(defmethod handle-msg :heartbeat
  [state msg]
  (log/debug "Got HEARTBEAT message.")
  (log/trace msg))

(defmethod handle-msg :offers
  [state msg]
  (log/debug "Got OFFERS message.")
  (log/trace msg))

(defmethod handle-msg :default
  [state msg]
  (log/error "Unknown type ...")
  (log/trace msg))

These will be called (at least initially) in the following manner:

(defn read-stream [ch stream]
  (async/go-loop []
    (async/put! ch (recordio/next! stream :json))
    (recur)))

(def response (master/subscribe c framework-info))
(def stream (:body response))
(def ch (async/chan))

(async/reduce handle-msg {:client c :stream stream :channel ch} ch)
(read-stream ch stream)

As such, it might make sense to:

  • put these in the meson.scheduler.handlers
  • name them default
  • and then call it with:
(async/reduce handlers/default {:client c :stream stream :channel ch} ch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant