integrant

2019-09-19T00:01:51.003Z

I’m looking for a good example showing how to use integrant and integrant.repl in the same project with separate configs and methods.

2019-09-19T00:03:12.004200Z

I’d like to use the dev config at the REPL and the prod config when run from the command-line use clj -m <namespace-with-my-main-function>

2019-09-19T00:04:52.005500Z

The issue isn’t really that I have different configs. It’s that I have different (defmethod ig/init-key :some-key [...] ... )

2019-09-19T14:03:30.011Z

@creese Is there a specific reason why you have different init-key for prod and dev?

2019-09-19T16:42:16.011700Z

maybe sth like this, with additional :dev true option passed to components. https://github.com/223kazuki/re-integrant-app/blob/master/dev/src/user.cljs#L10

2019-09-19T16:43:46.012Z

We use fake Kafka topic definitions with EDN serdes in dev to speed development. In production, use Avro. We also want to specify other things like the number of partitions the topic has which in dev is not as important.

2019-09-19T16:45:16.012200Z

Right now, I’m doing this for the prod intializers:

(if-not (get-method ig/init-key :topics)
  ;; Install this only if not already installed
...
)

2019-09-19T16:45:22.012400Z

Feels a bit smelly but it works.

2019-09-19T16:47:09.012600Z

For prod, there isn’t a problem because the user namespace isn’t loaded.

2019-09-19T16:48:42.012800Z

But the dev initializers can be overridden depending on which namespace is loaded first.

2019-09-19T00:05:42.006400Z

Both configs contain :some-key but when init-ing at the REPL or from the command-line, I’d like these to do different things.

2019-09-19T00:08:05.008300Z

This can be solved fairly easily at the command-line because the user namespace is not loaded. However, I haven’t found a good way to ignore the prod init-key methods when I’m in at the REPL.

2019-09-19T00:13:43.009400Z

I guess one way would be to only define the prod methods if the user namespace is absent, but that feels bit klugey.

2019-09-19T00:22:52.009800Z

This appears to work:

(if-not (get-method ig/init-key :some-key)
  (defmethod ig/init-key :some-key [ ... ]
    ...
    ))

2019-09-19T14:00:29.010900Z

Hello all. Is there a specific reason why integrant.core/load-namespaces is only available for clj?

2019-09-19T21:16:22.013300Z

oh, I guess you can't dynamically resolve symbols in cljs.