jjttjj/iboga

What dispatch mechanism should be used for extension points?

Opened this issue · 1 comments

Currently Iboga uses its own "dispatch mechanism", as seen here. Essentially it just keeps a big map in an atom of qualified keywords to maps of functionality implemented for that keyword.

This could also be implemented as multimethods, which has the advantage of being a standard clojure.core feature. However, multimethods feel like they're a bit overkill when they just dispatch on a keyword, and are a bit awkward when we really want to associate data with a keyword and not functionality.

I'm not in love with the naming and terminology of the current setup: set-schema! and "attributes".

An example of multimethods being used can be seen here:

iboga/dev/iboga/wip2.clj

Lines 32 to 44 in 4074360

(defmulti filterer
"Takes a qualified request and returns a transducer which filters
incoming messages to respond to for that request"
(fn [[msg-key argmap]] msg-key))
(defmulti taker
"Takes a qualified request and returns a transducers which 'takes'
incoming messages to respond to for that request. Should return a reduced value"
(fn [[msg-key argmap]] msg-key))
(defmulti cleanup
"Cleanup code to run after request has been 'finished'"
(fn [conn [msg-key argmap]] msg-key))