What is displace metadata in duct.core.merge/displace
?
From the readme: βWeβve also added merge metadata using merge/displace. This tells merge-configs not to override the port if it already exists in the configuraton.β
>In this example we've changed the requirement from :duct.server.http/jetty
to the more generic :duct.server/http
, which the latter derives from.
So, here :duct.server.http/jetty
is more specific than :duct.server/http
. Right?
>The merge-configs function is smart enough to merge :duct.server/http into a more specific derived key, if one exists.
What does this mean?
:duct.server.http/jetty
derives from :duct.server/http
https://github.com/duct-framework/server.http.jetty/blob/master/src/duct_hierarchy.edn
In the example, the module is merging :port
into your config under :duct.server/http
. However if your config contains a key that derives from :duct.server/http
(for example, :duct.server.http/jetty
), it will merge the port into that
(def config1 {:duct.server.http/jetty {}})
(def config2 {:duct.server/http {}})
(duct/merge-configs
config1
{:duct.server/http {:port 8080}})
;; => {:duct.server.http/jetty {:port 8080}}
(duct/merge-configs
config2
{:duct.server/http {:port 8080}})
;; => {:duct.server/http {:port 8080}}
Something along those lines
(Note that I just wrote out the idea)
@kevin.van.rooijen Thanks.
Youβre welcome