-
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.
Create S3 storage on project creation during nexus ship import (#4870)
- Loading branch information
1 parent
481c5a6
commit 26d0fc5
Showing
17 changed files
with
337 additions
and
82 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
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
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
18 changes: 4 additions & 14 deletions
18
ship/src/main/scala/ch/epfl/bluebrain/nexus/ship/config/S3Config.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,29 +1,19 @@ | ||
package ch.epfl.bluebrain.nexus.ship.config | ||
|
||
import cats.implicits.toBifunctorOps | ||
import eu.timepit.refined.collection.NonEmpty | ||
import eu.timepit.refined.refineV | ||
import fs2.aws.s3.models.Models.BucketName | ||
import pureconfig.ConfigReader | ||
import pureconfig.error.FailureReason | ||
import pureconfig.generic.semiauto.deriveReader | ||
|
||
import java.net.URI | ||
import scala.annotation.nowarn | ||
|
||
final case class S3Config(endpoint: URI, importBucket: BucketName) | ||
|
||
object S3Config { | ||
|
||
@nowarn("cat=unused") | ||
implicit final val s3ConfigReader: ConfigReader[S3Config] = { | ||
val emptyBucketName = new FailureReason { | ||
override def description: String = "The s3 bucket name cannot be empty" | ||
} | ||
implicit val bucketNameReader: ConfigReader[BucketName] = | ||
ConfigReader[String] | ||
.emap(str => refineV[NonEmpty](str).leftMap(_ => emptyBucketName).map(BucketName.apply)) | ||
implicit final val bucketNameReader: ConfigReader[BucketName] = | ||
InputConfig.bucketNameReader | ||
|
||
implicit final val s3ConfigReader: ConfigReader[S3Config] = | ||
deriveReader[S3Config] | ||
} | ||
|
||
} |
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
34 changes: 34 additions & 0 deletions
34
ship/src/main/scala/ch/epfl/bluebrain/nexus/ship/projects/ScopeInitializerWiring.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,34 @@ | ||
package ch.epfl.bluebrain.nexus.ship.projects | ||
|
||
import cats.effect.IO | ||
import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF | ||
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.JsonLdApi | ||
import ch.epfl.bluebrain.nexus.delta.sdk.ScopeInitializer | ||
import ch.epfl.bluebrain.nexus.delta.sdk.projects.{FetchContext, ScopeInitializationErrorStore} | ||
import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.ResolverContextResolution | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.Transactors | ||
import ch.epfl.bluebrain.nexus.ship.EventClock | ||
import ch.epfl.bluebrain.nexus.ship.config.InputConfig | ||
import ch.epfl.bluebrain.nexus.ship.storages.StorageWiring | ||
import ch.epfl.bluebrain.nexus.ship.storages.StorageWiring.s3StorageInitializer | ||
import ch.epfl.bluebrain.nexus.ship.views.ViewWiring.{blazegraphViews, elasticSearchViews, viewInitializers} | ||
|
||
object ScopeInitializerWiring { | ||
|
||
def initializer( | ||
fetchContext: FetchContext, | ||
rcr: ResolverContextResolution, | ||
config: InputConfig, | ||
clock: EventClock, | ||
xas: Transactors | ||
)(implicit jsonLdApi: JsonLdApi): IO[ScopeInitializer] = | ||
for { | ||
esViews <- elasticSearchViews(fetchContext, rcr, config.eventLog, clock, UUIDF.random, xas) | ||
bgViews <- blazegraphViews(fetchContext, rcr, config.eventLog, clock, UUIDF.random, xas) | ||
storages <- StorageWiring.storages(fetchContext, rcr, config, clock, xas) | ||
storageInit <- s3StorageInitializer(storages, config) | ||
allInits = viewInitializers(esViews, bgViews, config) + storageInit | ||
errorStore = ScopeInitializationErrorStore(xas, clock) | ||
} yield ScopeInitializer(allInits, errorStore) | ||
|
||
} |
Oops, something went wrong.