diff --git a/build.sbt b/build.sbt index 072abf04..56c4a774 100644 --- a/build.sbt +++ b/build.sbt @@ -141,7 +141,7 @@ lazy val docs = project Paradox / siteSubdirName := s"docs/akka-persistence-r2dbc/${projectInfoVersion.value}", paradoxGroups := Map( "Language" -> Seq("Java", "Scala"), - "Dialect" -> Seq("Postgres", "Yugabyte", "SQL Server", "H2")), + "Dialect" -> Seq("Postgres", "Yugabyte", "H2", "SQLServer")), Compile / paradoxProperties ++= Map( "project.url" -> "https://doc.akka.io/docs/akka-persistence-r2dbc/current/", "canonical.base_url" -> "https://doc.akka.io/docs/akka-persistence-r2dbc/current", @@ -159,7 +159,8 @@ lazy val docs = project "javadoc.akka.persistence.r2dbc.base_url" -> "", // no Javadoc is published "scaladoc.akka.base_url" -> s"https://doc.akka.io/api/akka/${Dependencies.AkkaVersionInDocs}/", "javadoc.akka.base_url" -> s"https://doc.akka.io/japi/akka/${Dependencies.AkkaVersionInDocs}/", - "scaladoc.com.typesafe.config.base_url" -> s"https://lightbend.github.io/config/latest/api/"), + "scaladoc.com.typesafe.config.base_url" -> s"https://lightbend.github.io/config/latest/api/", + "sqlserver.version" -> Dependencies.SqlServerVersion), ApidocPlugin.autoImport.apidocRootPackage := "akka", apidocRootPackage := "akka", resolvers += Resolver.jcenterRepo, diff --git a/docs/src/main/paradox/config.md b/docs/src/main/paradox/config.md index a48005f2..57f27673 100644 --- a/docs/src/main/paradox/config.md +++ b/docs/src/main/paradox/config.md @@ -16,6 +16,9 @@ Yugabyte: H2: : @@snip [application.conf](/docs/src/test/resources/application-h2.conf) { #connection-settings } +SQLServer: +: @@snip [application.conf](/docs/src/test/resources/application-sqlserver.conf) { #connection-settings } + Full set of settings that can be overridden for each of the dialects, and their default values: Postgres: @@ -27,6 +30,9 @@ Yugabyte: H2: : @@snip [reference.conf](/core/src/main/resources/reference.conf) { #connection-settings-h2 } +SQLServer: +: @@snip [reference.conf](/core/src/main/resources/reference.conf) { #connection-settings-sqlserver } + Connection pool settings are the same across the different dialects, but are defined in-line in the connection factory block: ```shell diff --git a/docs/src/main/paradox/getting-started.md b/docs/src/main/paradox/getting-started.md index a72c74d0..46050baa 100644 --- a/docs/src/main/paradox/getting-started.md +++ b/docs/src/main/paradox/getting-started.md @@ -99,6 +99,28 @@ akka.persistence.r2dbc.connection-factory = { See @ref[Configuration](config.md) for more configuration details. +#### Using Microsoft SQL Server + +The SQL Server dependency is marked as `provided` dependencies of `akka-persistence-r2dbc` to not be pulled in for projects not using SQL Server. It must be listed explicitly as dependencies in the build configuration for projects that use it. The required artifacts is: + +@@dependency [Maven,sbt,Gradle] { +group=io.r2dbc +artifact=r2dbc-mssql_$scala.binary.version$ +version=$sqlserver.version$ +} + +With the dependencies added to your project, configure the connection factory to the default SQL Server block: + +```hocon +akka.persistence.r2dbc.connection-factory = ${akka.persistence.r2dbc.sqlserver} +akka.persistence.r2dbc.connection-factory = { + # overrides for default values from the 'akka.persistence.r2dbc.sqlserver' config block + user = "myuser" +} +``` + +See @ref[Configuration](config.md) for more configuration details. + ## Local testing with docker The database can be run in Docker. Here's a sample docker compose file: diff --git a/docs/src/main/paradox/overview.md b/docs/src/main/paradox/overview.md index 8621bb70..8663bef4 100644 --- a/docs/src/main/paradox/overview.md +++ b/docs/src/main/paradox/overview.md @@ -7,6 +7,7 @@ Currently, the R2DBC plugin has support for: * [PostgreSQL](https://www.postgresql.org) * [Yugabyte](https://www.yugabyte.com) * [H2](https://h2database.com) - As a minimal in-process memory or file based database. + * [Microsoft SQL Server](https://microsoft.com/sqlserver) It is specifically designed to work well for distributed SQL databases. @@ -40,5 +41,3 @@ dependencies are in the same version, so it is recommended to depend on them exp with transient dependencies causing an unlucky mix of versions. @@dependencies{ projectId="core" } - - diff --git a/docs/src/test/resources/application-sqlserver.conf b/docs/src/test/resources/application-sqlserver.conf new file mode 100644 index 00000000..2d0a0bfd --- /dev/null +++ b/docs/src/test/resources/application-sqlserver.conf @@ -0,0 +1,18 @@ + +akka.persistence.journal.plugin = "akka.persistence.r2dbc.journal" +akka.persistence.snapshot-store.plugin = "akka.persistence.r2dbc.snapshot" +akka.persistence.state.plugin = "akka.persistence.r2dbc.state" + +// #connection-settings +akka.persistence.r2dbc.connection-factory = ${akka.persistence.r2dbc.sqlserver} +akka.persistence.r2dbc.connection-factory { + host = "localhost" + host = ${?DB_HOST} + database = "db" + database = ${?DB_NAME} + user = "user" + user = ${?DB_USER} + password = "password" + password = ${?DB_PASSWORD} +} +// #connection-settings diff --git a/project/Dependencies.scala b/project/Dependencies.scala index f57ac49c..95c39202 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -15,6 +15,7 @@ object Dependencies { val AkkaProjectionVersionInDocs = "current" val H2Version = "2.2.224" val R2dbcH2Version = "1.0.0.RELEASE" + val SqlServerVersion = "1.0.2.RELEASE" object Compile { val akkaActorTyped = "com.typesafe.akka" %% "akka-actor-typed" % AkkaVersion @@ -29,7 +30,7 @@ object Dependencies { val h2 = "com.h2database" % "h2" % H2Version % Provided // EPL 1.0 val r2dbcH2 = "io.r2dbc" % "r2dbc-h2" % R2dbcH2Version % Provided // ApacheV2 - val r2dbcSqlServer = "io.r2dbc" % "r2dbc-mssql" % "1.0.2.RELEASE" % Provided // ApacheV2 + val r2dbcSqlServer = "io.r2dbc" % "r2dbc-mssql" % SqlServerVersion % Provided // ApacheV2 } object TestDeps {