This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-04
Channels
- # architecture (27)
- # bangalore-clj (4)
- # beginners (22)
- # boot (35)
- # cider (26)
- # cljs-dev (2)
- # cljsrn (3)
- # clojure (156)
- # clojure-austria (3)
- # clojure-dev (9)
- # clojure-italy (25)
- # clojure-nl (10)
- # clojure-poland (5)
- # clojure-sanfrancisco (1)
- # clojure-spec (6)
- # clojure-uk (64)
- # clojurescript (169)
- # core-async (13)
- # cursive (13)
- # datomic (63)
- # dirac (50)
- # duct (21)
- # editors (1)
- # emacs (6)
- # events (1)
- # fulcro (1)
- # java (22)
- # keechma (14)
- # leiningen (2)
- # luminus (4)
- # off-topic (23)
- # onyx (4)
- # parinfer (5)
- # pedestal (4)
- # re-frame (6)
- # reagent (4)
- # ring-swagger (7)
- # rum (4)
- # shadow-cljs (84)
- # specter (5)
- # sql (36)
- # tools-deps (76)
- # uncomplicate (3)
- # yada (4)
Hi, Im playing around with a duct project and I’m trying to understand an integrant error i’m getting. In my main.clj, where duct is doing the read/prep/exct stuff, I’ve required a datomic module I wrote, in this case, the multimethod isn’t found. However, If I move the require into say one of my handlers, it works fine. This is a little confusing as I thought the requires, should be loaded/resolved before the actual code in the namespace starts to do its thing
@eoliphant can you post some example code?
sure
(ns gs2-grant-infra.main
(:gen-class)
(:require [ :as io]
[gs2-grant-infra.modules.datomic]
[duct.core :as duct]))
(duct/load-hierarchy)
(defn -main [& args]
(print "starting")
(let [keys (or (duct/parse-keys args) [:duct/daemon])]
(-> (duct/read-config (io/resource "gs2_grant_infra/config.edn"))
(duct/prep keys)
(duct/exec keys))))
That’s the ‘normal’ main, plus my module require
When I do a (dev), then (go), I get the No method in multimethod 'init-key' for dispatch value: :datomic/connection
, However if I then do a (reset) it’s finealso pretty vanilla at this point
{:duct.core/project-ns
gs2-grant-infra
:duct.core/environment
:production
:duct.module/logging
{}
:duct.module.web/api
{}
:duct.module/ataraxy
{[:get "/example"] [:example]
[:post "/command" {body :body-params}] [:command body]}
:gs2-grant-infra.handler/example
{}
:gs2-grant-infra.handler/command
{:conn #ig/ref :datomic/connection}
:datomic/connection
{:datomic/mode :peer
:datomic/uri "datomic:}}
Yeah, you’ll need to be explicit somewhere. The easiest “automatic” way is to have the key match a proper namespace. So like g2-grant-infra.datomic and then in there have a key for ::connection
ok will try that, once it’s all working, was going to refactor that out to it’s own lib, but can just update the key at that point
i also have a ‘philosophical’ lol, duct question. So I have a ‘command’ handler, thats accepting POSTS, that would in turn be dispatched off to handlers based on their type field. I was just going to do this with multimethods, but now I’m wondering if it might be useful to somehow wire all that up with duct as well
I have something like that, it’s an internal routing table defined in the config that’s passed to the “command” handler