-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
monofunctor-tf example: run under both ZIO and Cats Effect
- Loading branch information
Showing
7 changed files
with
215 additions
and
197 deletions.
There are no files selected for viewing
41 changes: 23 additions & 18 deletions
41
distage-example-bifunctor-tf/src/main/scala/leaderboard/plugins/PostgresDockerPlugin.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
package leaderboard.plugins | ||
|
||
import distage.Scene | ||
import distage.{ModuleDef, Scene} | ||
import izumi.distage.docker.Docker.DockerPort | ||
import izumi.distage.docker.bundled.PostgresDocker | ||
import izumi.distage.docker.modules.DockerSupportModule | ||
import izumi.distage.plugins.PluginDef | ||
import izumi.reflect.TagKK | ||
import leaderboard.config.PostgresPortCfg | ||
import zio.Task | ||
import zio.IO | ||
|
||
object PostgresDockerPlugin extends PluginDef { | ||
// only enable postgres docker when Scene axis is set to Managed | ||
tag(Scene.Managed) | ||
include(dockerModule[IO]) | ||
|
||
// add docker support dependencies | ||
include(DockerSupportModule[Task]) | ||
def dockerModule[F[+_, +_]: TagKK]: ModuleDef = new ModuleDef { | ||
// only enable postgres docker when Scene axis is set to Managed | ||
tag(Scene.Managed) | ||
|
||
// launch postgres docker for tests | ||
make[PostgresDocker.Container] | ||
.fromResource(PostgresDocker.make[Task]) | ||
// add docker support dependencies | ||
include(DockerSupportModule[F[Throwable, _]]) | ||
|
||
// spawned docker container port is randomized | ||
// to prevent conflicts, so make PostgresPortCfg | ||
// point to the new port. This will also | ||
// cause the container to start before | ||
// integration check is performed | ||
make[PostgresPortCfg].from { | ||
(docker: PostgresDocker.Container) => | ||
val knownAddress = docker.availablePorts.first(DockerPort.TCP(5432)) | ||
PostgresPortCfg(knownAddress.hostString, knownAddress.port) | ||
// launch postgres docker for tests | ||
make[PostgresDocker.Container] | ||
.fromResource(PostgresDocker.make[F[Throwable, _]]) | ||
|
||
// spawned docker container port is randomized | ||
// to prevent conflicts, so make PostgresPortCfg | ||
// point to the new port. This will also | ||
// cause the container to start before | ||
// integration check is performed | ||
make[PostgresPortCfg].from { | ||
(docker: PostgresDocker.Container) => | ||
val knownAddress = docker.availablePorts.first(DockerPort.TCP(5432)) | ||
PostgresPortCfg(knownAddress.hostString, knownAddress.port) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 26 additions & 20 deletions
46
distage-example-monofunctor-tf/src/main/scala/leaderboard/plugins/PostgresDockerPlugin.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,38 @@ | ||
package leaderboard.plugins | ||
|
||
import distage.Scene | ||
import distage.{ModuleDef, Scene} | ||
import izumi.distage.docker.Docker.DockerPort | ||
import izumi.distage.docker.bundled.PostgresDocker | ||
import izumi.distage.docker.modules.DockerSupportModule | ||
import izumi.distage.plugins.PluginDef | ||
import izumi.distage.plugins.{PluginBase, PluginDef} | ||
import izumi.reflect.TagK | ||
import leaderboard.config.PostgresPortCfg | ||
import zio.Task | ||
|
||
object PostgresDockerPlugin extends PluginDef { | ||
// only enable postgres docker when Scene axis is set to Managed | ||
tag(Scene.Managed) | ||
object PostgresDockerPlugin { | ||
def apply[F[_]: TagK]: PluginBase = new PluginDef { | ||
include(dockerModule[F]) | ||
} | ||
|
||
def dockerModule[F[_]: TagK]: ModuleDef = new ModuleDef { | ||
// only enable postgres docker when Scene axis is set to Managed | ||
tag(Scene.Managed) | ||
|
||
// add docker support dependencies | ||
include(DockerSupportModule[Task]) | ||
// add docker support dependencies | ||
include(DockerSupportModule[F]) | ||
|
||
// launch postgres docker for tests | ||
make[PostgresDocker.Container] | ||
.fromResource(PostgresDocker.make[Task]) | ||
// launch postgres docker for tests | ||
make[PostgresDocker.Container] | ||
.fromResource(PostgresDocker.make[F]) | ||
|
||
// spawned docker container port is randomized | ||
// to prevent conflicts, so make PostgresPortCfg | ||
// point to the new port. This will also | ||
// cause the container to start before | ||
// integration check is performed | ||
make[PostgresPortCfg].from { | ||
(docker: PostgresDocker.Container) => | ||
val knownAddress = docker.availablePorts.first(DockerPort.TCP(5432)) | ||
PostgresPortCfg(knownAddress.hostString, knownAddress.port) | ||
// spawned docker container port is randomized | ||
// to prevent conflicts, so make PostgresPortCfg | ||
// point to the new port. This will also | ||
// cause the container to start before | ||
// integration check is performed | ||
make[PostgresPortCfg].from { | ||
(docker: PostgresDocker.Container) => | ||
val knownAddress = docker.availablePorts.first(DockerPort.TCP(5432)) | ||
PostgresPortCfg(knownAddress.hostString, knownAddress.port) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.