Skip to content

Commit

Permalink
Merge pull request #2 from sebastian-alfers/mssql-support-2nd-docs
Browse files Browse the repository at this point in the history
 sql server docs
  • Loading branch information
sebastian-alfers authored Jan 28, 2024
2 parents a23f901 + 853c933 commit 8c7572c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 5 deletions.
5 changes: 3 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions docs/src/main/paradox/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
22 changes: 22 additions & 0 deletions docs/src/main/paradox/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions docs/src/main/paradox/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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" }


18 changes: 18 additions & 0 deletions docs/src/test/resources/application-sqlserver.conf
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 8c7572c

Please sign in to comment.