Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #49 from githubmo/enhancement/remove_implicit_ec_f…
Browse files Browse the repository at this point in the history
…rom_constructor

Remove the need for adding an implicit ExecutionContext from ReactiveRepository Constructor
  • Loading branch information
duncancrawford committed Nov 6, 2015
2 parents 5b35fda + af7ad3b commit 6162ea3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/scala/uk/gov/hmrc/mongo/ReactiveRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import uk.gov.hmrc.mongo.json.ReactiveMongoFormats

import scala.concurrent.{ExecutionContext, Future}


abstract class ReactiveRepository[A <: Any, ID <: Any](collectionName: String,
mongo: () => DB,
domainFormat: Format[A],
idFormat: Format[ID] = ReactiveMongoFormats.objectIdFormats,
mc: Option[JSONCollection] = None)
(implicit manifest: Manifest[A], mid: Manifest[ID], ec : ExecutionContext)
mc: Option[JSONCollection] = None,
initialisingEc: ExecutionContext = scala.concurrent.ExecutionContext.global)
(implicit manifest: Manifest[A], mid: Manifest[ID])
extends Repository[A, ID] with Indexes with ImplicitBSONHandlers {

import play.api.libs.json.Json.JsValueWrapper
Expand All @@ -33,7 +33,7 @@ abstract class ReactiveRepository[A <: Any, ID <: Any](collectionName: String,
protected val logger = LoggerFactory.getLogger(this.getClass)
val message: String = "Failed to ensure index"

ensureIndexes
ensureIndexes(initialisingEc)

protected val _Id = "_id"
protected def _id(id : ID) = Json.obj(_Id -> id)
Expand Down Expand Up @@ -79,7 +79,6 @@ abstract class ReactiveRepository[A <: Any, ID <: Any](collectionName: String,
}
}


private val DuplicateKeyError = "E11000"
private def ensureIndex(index: Index)(implicit ec: ExecutionContext): Future[Boolean] = {
collection.indexesManager.create(index).map(wr => {
Expand Down

0 comments on commit 6162ea3

Please sign in to comment.