Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
rolang committed Oct 16, 2024
1 parent e8c2839 commit 7f0f24d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 2 additions & 11 deletions modules/core/shared/src/main/scala/dumbo/Dumbo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,15 @@ 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,
schemaHistoryTable = schemaHistoryTable,
validateOnMigrate = validateOnMigrate,
)

def bySession(
def withSession(
sessionResource: Resource[F, Session[F]],
defaultSchema: String = Dumbo.defaults.defaultSchema,
schemas: Set[String] = Dumbo.defaults.schemas,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7f0f24d

Please sign in to comment.