I don't understand what you mean by "redef the new read-only datasource state with the older state". Judging from the error you are using with-redefs wrong, you should drop the "constantly" call. Some of this might be helpful: https://github.com/tolitius/mount/#swapping-alternate-implementations
I have looked into that, but I can’t figure out how to swap my state with alternate implementation. I have these macros defined on the 2 datasources:
(defstate datasource
:start (do (log/info "Starting DB connection pool")
(hikari/make-datasource (:db config/config)))
:stop (do (hikari/close-datasource datasource)
(log/info "Closed DB connection pool")))
(defstate read-only-datasource
:start (do (log/info "Starting read-only DB connection pool")
(hikari/make-datasource (merge (:db config/config)
(:read-only-db config/config))))
:stop (do (hikari/close-datasource datasource)
(log/info "Closed read-only DB connection pool")))
(defmacro with-transaction [[transaction] & body]
`(jdbc/with-db-transaction
[~transaction {:datasource datasource}]
~@body))
(defmacro with-read-only-transaction [[transaction] & body]
`(jdbc/with-db-transaction
[~transaction {:datasource read-only-datasource}]
~@body))
and I want to either replace the state within with-read-only-transaction to use the normal datasource in testsX-posting https://clojurians.slack.com/archives/C03S1KBA2/p1688475389326749 question here as it’s related to mount: