Fork me on GitHub
#duct
<
2024-03-10
>
hadils18:03:43

Hi! I am very interested in using duct for a commercial application server. I think I need to write a module for my db replacement, but I am stumped as to how to proceed. I have this module implementation:

(ns com.yardwerkz.module.rama
  (:require
   [integrant.core :as ig]
   [duct.core :as duct]))

(defmethod ig/init-key :com.yardwerkz.module/rama [_ options]
  (fn [config]
    (duct/merge-configs
     config
     {:com.yardwerkz.module.rama/external-name "localhost"
      :com.yardwerkz.module.rama/serializations
      [com.yardwerkz.serialization.YardwerkzSerialization
       com.yardwerkz.serialization.YardwerkzTEnumSerialization]})))
and this config:
{:duct.profile/base
 {:duct.core/project-ns com.yardwerkz

  :duct.router/ataraxy
  {:routes {[:get "/"] [:com.yardwerkz.handler/index]}}

  [:duct.handler.static/ok :com.yardwerkz.handler/index]
  {:body {:entries "/entries"}}

  :duct.handler.static/not-found
  {:body "I can't find what you want!"}

  :duct.server.http/http-kit
  {:port 3000}}

 :duct.profile/dev   #duct/include "dev"
 :duct.profile/local #duct/include "local"
 :duct.profile/prod  {}

 :duct.module/logging {}
 :duct.module.web/api {}
 :com.yardwerkz.module/rama {}}
and I am getting this error:
Execution error (IllegalArgumentException) at integrant.core/resume$fn (core.cljc:450).
No method in multimethod 'init-key' for dispatch value: :com.yardwerkz.module.rama/external-name
Thanks in advance for any help you can offer.

ts150318:03:00

All your keys, that ended up being in the config edn should be defined as integrant keys. In your example you should have :com.yardwerkz.module.rama/external-name integrant key somewhere in your namespaces

hadils19:03:01

Thank you. I added these keys and they work! I am thinking I don’t really need a module after all though. Still learning…