Skip to content

Instantly share code, notes, and snippets.

@iarenaza
Created June 4, 2021 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iarenaza/866b5291a96ae6d757c8af8f11d6958e to your computer and use it in GitHub Desktop.
Save iarenaza/866b5291a96ae6d757c8af8f11d6958e to your computer and use it in GitHub Desktop.
Using two database connections (with separate db connection pools) with Duct.
{:duct.profile/base
{:duct.core/project-ns project-ns
[:duct.database.sql/hikaricp :duct.database.sql.hikaricp/postgres]
{:jdbc-url #duct/env ["JDBC_POSTGRES_URL" Str]
:minimum-idle 10
:maximum-pool-size 25
;; Other HikariCP options go here.
}
[:project-ns.boundary.adapter.persistence/sql :project-ns.boundary.adapter.persistence.sql/postgres]
#ig/ref :duct.database.sql.hikaricp/postgres
[:duct.database.sql/hikaricp :duct.database.sql.hikaricp/sqlserver]
{:jdbc-url #duct/env ["JDBC_SQLSERVER_URL" Str]
:minimum-idle 10
:maximum-pool-size 25
;; Other HikariCP options go here.
}
[:project-ns.boundary.adapter.persistence/sql :project-ns.boundary.adapter.persistence.sql/sqlserver]
#ig/ref :duct.database.sql.hikaricp/sqlserver
[:duct/const :project-ns/common-config] {:db-postgres #ig/ref :project-ns.boundary.adapter.persistence.sql/postgres
:db-sqlserver #ig/ref :project-ns.boundary.adapter.persistence.sql/sqlserver
;; More config options go here.
}
:project-ns.api/user #ig/ref :project-ns/common-config
:project-ns.api/device #ig/ref :project-ns/common-config
;; Other Intengrant keys go here.
} ;; Base profile ends here
:duct.profile/dev #duct/include "dev"
:duct.profile/local #duct/include "local"
:duct.profile/prod {}
;; More Duct modules and profiles go here.
}
(ns project-ns.boundary.adapter.persistence.connector)
(defrecord Sql [spec])
(ns project-ns.boundary.adapter.persistence.sql
(:require [project-ns.boundary.adapter.persistence.connector :as connector]
;; Other namespaces that implement different protocols on the
;; `connector/Sql` record type go here.
[integrant.core :as ig]))
(defmethod ig/init-key :project-ns.boundary.adapter.persistence/sql [_ {:keys [spec]}]
(connector/->Sql spec))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment