Fork me on GitHub
#juxt
<
2023-11-10
>
imre13:11:58

Just checking here about juxt/aero: I need to merge configuration files at system startup (built-in config + environment-specific one, both edn files) and was under the impression I could use aero for that but checking the readme it doesn't seem like the case, am I reading that right?

imre13:11:06

The specific case I'm looking to get covered is the removal of keys from the built-in config as all other current usecases are supported by the current solution.

imre13:11:02

Example:

(magic-fn
 {:a 1
  :b 2
  :c {:x 1
      :y 2}}
 {:b ^:remove []
  :c {:x ^:remove []}})
;=> {:a 1 :c {:y 2}}

maleghast14:11:21

Aero allows you to have all config in one file and read it based on environment, so any config you want excluded from a particular environment in terms of runtime availability just needs to not be marked for that environment. Of course that does mean you will ship config that is unused / surplus to requirement for a given environment, but at least all your config is in the same place and as such is a simpler maintenance / update problem.

maleghast14:11:42

(hopefully that made sense)

maleghast14:11:45

^^ That's the bit of the documentation that you are going to want to read.

imre14:11:34

Cheers Oliver, unfortunately profiles don't help me here, I have a requirement to use multiple files. Looks like Aero isn't what I'm looking for

maleghast14:11:31

Why do you have to use multiple files?

maleghast14:11:38

Why not use one file and make use of profiles..?

maleghast14:11:22

(That was kinda the point I was trying to make anyway)

imre14:11:24

My base config which contains rarely-changed and environment-independent wiring is packaged into the uberjar. Environment-specific configuration has a different lifecycle (changes more often), lives elsewhere, and is versioned independently. At startup I deep-merge the env-specific one on top of the built-in one.

imre14:11:25

I want base config to live with the app source and I don't want to re-package the app when, say a port number changes.

maleghast14:11:12

OK, I think that this is pretty subjective. I would just use one file and benefit from profiles. Your not wanting to repackage the app when some config changes is a perfectly valid choice, just not one I would make. Nonetheless, you are right, the advantages of Aero are wiped out by the other concerns / requirements that you have. Sorry I was not more help \o/

imre14:11:20

In rare cases I want to override the base config in a way that some keys are completely removed in the effective config. That's what I had thought aero could perhaps help with but looks like I'm looking for something like meta-merge instead

imre14:11:42

Thanks for the discussion anyway 🙂

maleghast14:11:49

No problem - any time 🙂

seancorfield16:11:32

@U08BJGV6E We have the same setup as you and use Aero -- we just merge the config ourselves after reading.

imre16:11:21

Cheers for the input Sean, I suppose you don't merge it using Aero, but use Aero for some of its other features?

imre17:11:26

(I ended up just implementing removal myself in the deep-merge algo we use btw, inspired by https://github.com/weavejester/meta-merge)

seancorfield17:11:42

Right, we use Aero to read EDN and deal with #env / #include etc. We don't use profiles at all.

seancorfield17:11:27

We have a base EDN for each service (in resources -- ends up in the JAR) and then each server has one or more overriding EDN files per service.

1
imre17:11:24

Very similar to our usage yeah although we currently don't use env/include and so don't have a need for areo

jasonjckn20:11:50

@U08BJGV6E yah we use meta-merge

jasonjckn20:11:25

it allows for an interesting new level of abstraction, for config data, namely 'overrides'

👍 1
jasonjckn20:11:39

since the merge happens before #ref is resolved.

jasonjckn20:11:11

if you put juxt clip systems in your config , also adds new flexibility.

imre20:11:33

meta-merge doesn't support removing keys though, as far as I could tell

jasonjckn20:11:16

i think you're right, that's pretty useful, i wouldn't mind a fork.

jasonjckn20:11:25

I guess that's what you did internally 🙂

jasonjckn20:11:50

you would have to go up a level in the nested map structure, and do a ^:replace i think.

imre20:11:29

My addition was to an internal function, but I might consider a pr to meta-merge

👍 1
imre20:11:46

I'll ask James whether he'd be interested

🙌 1
jasonjckn20:11:30

any idea on the syntax? you can't associated metadata with keys

jasonjckn20:11:08

:key ^:remove {} maybe , I think we should avoid data_readers.clj for this one obviously.

imre20:11:21

That's what I supported internally

👍 1
imre20:11:29

My first idea was to put it on the key but quickly realized thst wont work

oly09:11:20

I have been using a multiple config strategy, I have a default config in the repo which is more a dev config that anything, but I have a function which will load another aero edn file and merge the two together so I can override and extend the base config. My reasoning for this is more for tinkering with the prod database I can load in the prod databases configuration and run queries against the prod database, feels safer doing this as I have to explicitly load the prod config, I do this instead of using a separate sql app as I can reuse my existing sql and create clerk notebooks when I need to do some db heavy data manipulation.