From 7f0f24dcec82f895a6d09450f2ecbb1dbd50d6d3 Mon Sep 17 00:00:00 2001 From: Roman Langolf Date: Sun, 13 Oct 2024 13:50:47 +0700 Subject: [PATCH] minor refactoring --- README.md | 2 +- .../core/shared/src/main/scala/dumbo/Dumbo.scala | 13 ++----------- .../shared/src/main/scala/ffstest/FFramework.scala | 2 +- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6944a0b..4eeb010 100644 --- a/README.md +++ b/README.md @@ -250,7 +250,7 @@ dumboWithResouces.withMigrationStateLogAfter[IO](5.seconds)( // NOTE: given a connection config, dumbo will construct a session that will include given schemas into the search path via session parameters // for custom sessions the search_path will be updated via the SET command if it doesn't match given schemas config which is not recommended (see https://typelevel.org/skunk/reference/Sessions.html#session-parameters) // you may consider adding the search_path to the parameters yourself in that case, dumbo will log it as a warning -dumboWithResouces.bySession( +dumboWithResouces.withSession( defaultSchema = "schema_1", // consider updating the search_path for non default schema settings sessionResource = skunk.Session.single[IO]( host = "localhost", diff --git a/modules/core/shared/src/main/scala/dumbo/Dumbo.scala b/modules/core/shared/src/main/scala/dumbo/Dumbo.scala index 9191d3e..f789723 100644 --- a/modules/core/shared/src/main/scala/dumbo/Dumbo.scala +++ b/modules/core/shared/src/main/scala/dumbo/Dumbo.scala @@ -35,16 +35,7 @@ final class DumboWithResourcesPartiallyApplied[F[_]](reader: ResourceReader[F]) schemaHistoryTable: String = Dumbo.defaults.schemaHistoryTable, validateOnMigrate: Boolean = Dumbo.defaults.validateOnMigrate, )(implicit S: Sync[F], T: Temporal[F], C: Console[F], TRC: Tracer[F], N: Network[F]): Dumbo[F] = - byConnectionConfig(connection, defaultSchema, schemas, schemaHistoryTable, validateOnMigrate) - - def byConnectionConfig( - connection: ConnectionConfig, - defaultSchema: String = Dumbo.defaults.defaultSchema, - schemas: Set[String] = Dumbo.defaults.schemas, - schemaHistoryTable: String = Dumbo.defaults.schemaHistoryTable, - validateOnMigrate: Boolean = Dumbo.defaults.validateOnMigrate, - )(implicit S: Sync[F], T: Temporal[F], C: Console[F], TRC: Tracer[F], N: Network[F]): Dumbo[F] = - bySession( + withSession( sessionResource = toSessionResource(connection, defaultSchema, schemas), defaultSchema = defaultSchema, schemas = schemas, @@ -52,7 +43,7 @@ final class DumboWithResourcesPartiallyApplied[F[_]](reader: ResourceReader[F]) validateOnMigrate = validateOnMigrate, ) - def bySession( + def withSession( sessionResource: Resource[F, Session[F]], defaultSchema: String = Dumbo.defaults.defaultSchema, schemas: Set[String] = Dumbo.defaults.schemas, diff --git a/modules/tests/shared/src/main/scala/ffstest/FFramework.scala b/modules/tests/shared/src/main/scala/ffstest/FFramework.scala index 8f7f073..0a1306e 100644 --- a/modules/tests/shared/src/main/scala/ffstest/FFramework.scala +++ b/modules/tests/shared/src/main/scala/ffstest/FFramework.scala @@ -85,7 +85,7 @@ trait FTest extends CatsEffectSuite with FTestPlatform { validateOnMigrate: Boolean = true, )(implicit c: std.Console[IO]): IO[Dumbo.MigrationResult] = withResources - .bySession( + .withSession( sessionResource = session, defaultSchema = defaultSchema, schemas = schemas.toSet,