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

Define a best-practice and mechanism for event handlers #53

Closed
oubiwann opened this issue Oct 15, 2016 · 1 comment
Closed

Define a best-practice and mechanism for event handlers #53

oubiwann opened this issue Oct 15, 2016 · 1 comment
Assignees
Milestone

Comments

@oubiwann
Copy link
Member

oubiwann commented Oct 15, 2016

This will essentially be how developers will define Mesos HTTP APIs in Meson for events. In particular, it needs to provide an example (e.g., defmulti and defmethods) for how to dispatch callbacks based on a message type parsed from the stream.

Subtask of feature #56.

@oubiwann oubiwann added this to the 0.1.0 milestone Oct 15, 2016
@oubiwann oubiwann self-assigned this Oct 15, 2016
@oubiwann oubiwann mentioned this issue Oct 15, 2016
4 tasks
@oubiwann
Copy link
Member Author

We have adopted the same approach used by @pyr in Mesomatic: define callbacks for use in an async/reduce call by means of defmulti and defmethod.

How this gets included in the codebase is another matter. Perhaps default, no-op+logging methods that can be used by developers to get started, to serve as a starting point when they need to override one or more of the event-handling methods for any of the SUBSCRIBE-enabled APIs (scheduler, executor, operator).

Here is a sample of what I've been testing with in the scheduler HTTP API:

(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))

As the ultimate location for these methods will be defined in the individual API feature tasks, and as the best practice id defined, I'm closing this ticket now.

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