-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor ship before introducing save summary feature
- Loading branch information
Simon Dumas
committed
Apr 15, 2024
1 parent
7470269
commit 9c5f811
Showing
21 changed files
with
349 additions
and
296 deletions.
There are no files selected for viewing
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
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
32 changes: 32 additions & 0 deletions
32
ship/src/main/scala/ch/epfl/bluebrain/nexus/ship/InitShip.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ch.epfl.bluebrain.nexus.ship | ||
|
||
import cats.effect.IO | ||
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.s3.client.S3StorageClient | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.exporter.RowEvent | ||
import ch.epfl.bluebrain.nexus.ship.ShipCommand.RunCommand | ||
import ch.epfl.bluebrain.nexus.ship.config.ShipConfig | ||
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider | ||
|
||
object InitShip { | ||
|
||
def apply(run: RunCommand): IO[(ShipConfig, fs2.Stream[IO, RowEvent])] = run.mode match { | ||
case RunMode.Local => | ||
val eventsStream = EventStreamer.localStreamer.stream(run.path, run.offset) | ||
ShipConfig.load(run.config).map(_ -> eventsStream) | ||
case RunMode.S3 => | ||
for { | ||
localConfig <- ShipConfig.load(None) | ||
s3Config = localConfig.s3 | ||
(config, eventsStream) <- | ||
S3StorageClient.resource(s3Config.endpoint, DefaultCredentialsProvider.create()).use { client => | ||
val eventsStream = EventStreamer.s3eventStreamer(client, s3Config.importBucket).stream(run.path, run.offset) | ||
val config = run.config match { | ||
case Some(configPath) => ShipConfig.loadFromS3(client, s3Config.importBucket, configPath) | ||
case None => IO.pure(localConfig) | ||
} | ||
config.map(_ -> eventsStream) | ||
} | ||
} yield (config, eventsStream) | ||
} | ||
|
||
} |
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
2 changes: 1 addition & 1 deletion
2
ship/src/main/scala/ch/epfl/bluebrain/nexus/ship/ProjectMapper.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
11 changes: 11 additions & 0 deletions
11
ship/src/main/scala/ch/epfl/bluebrain/nexus/ship/RunMode.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package ch.epfl.bluebrain.nexus.ship | ||
|
||
sealed trait RunMode extends Product with Serializable | ||
|
||
object RunMode { | ||
|
||
final case object Local extends RunMode | ||
|
||
final case object S3 extends RunMode | ||
|
||
} |
Oops, something went wrong.