Skip to content

Commit

Permalink
#466 Prevent global fail if one Cortex fails
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Mar 20, 2018
1 parent 617b801 commit 984dbf5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions thehive-cortex/app/connectors/cortex/services/CortexSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@ class CortexSrv @Inject() (
createSrv[JobModel, Job, Artifact](jobModel, artifact, fields.set("artifactId", artifact.id))
}

private[CortexSrv] def update(jobId: String, fields: Fields)(implicit Context: AuthContext): Future[Job] =
private[CortexSrv] def update(jobId: String, fields: Fields)(implicit authContext: AuthContext): Future[Job] =
update(jobId, fields, ModifyConfig.default)

private[CortexSrv] def update(jobId: String, fields: Fields, modifyConfig: ModifyConfig)(implicit Context: AuthContext): Future[Job] =
private[CortexSrv] def update(jobId: String, fields: Fields, modifyConfig: ModifyConfig)(implicit authContext: AuthContext): Future[Job] =
getJob(jobId).flatMap(job update(job, fields, modifyConfig))

private[CortexSrv] def update(job: Job, fields: Fields)(implicit Context: AuthContext): Future[Job] =
private[CortexSrv] def update(job: Job, fields: Fields)(implicit authContext: AuthContext): Future[Job] =
update(job, fields, ModifyConfig.default)

private[CortexSrv] def update(job: Job, fields: Fields, modifyConfig: ModifyConfig)(implicit Context: AuthContext): Future[Job] =
private[CortexSrv] def update(job: Job, fields: Fields, modifyConfig: ModifyConfig)(implicit authContext: AuthContext): Future[Job] =
updateSrv[Job](job, fields, modifyConfig)

def find(queryDef: QueryDef, range: Option[String], sortBy: Seq[String]): (Source[Job, NotUsed], Future[Long]) = {
Expand All @@ -169,15 +169,15 @@ class CortexSrv @Inject() (
def askAnalyzersOnAllCortex(f: CortexClient Future[Seq[Analyzer]]): Future[Seq[Analyzer]] = {
Future
.traverse(cortexConfig.instances) { cortex
f(cortex)
f(cortex).recover { case _ Nil }
}
.map(_.flatten)
}

def getAnalyzersFor(dataType: String): Future[Seq[Analyzer]] = {
Future
.traverse(cortexConfig.instances) { cortex
cortex.listAnalyzerForType(dataType)
cortex.listAnalyzerForType(dataType).recover { case _ Nil }
}
.map { listOfListOfAnalyzers
val analysers = listOfListOfAnalyzers.flatten
Expand All @@ -192,7 +192,7 @@ class CortexSrv @Inject() (
def listAnalyzer: Future[Seq[Analyzer]] = {
Future
.traverse(cortexConfig.instances) { cortex
cortex.listAnalyzer
cortex.listAnalyzer.recover { case _ Nil }
}
.map { listOfListOfAnalyzers
val analysers = listOfListOfAnalyzers.flatten
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ReportTemplateSrv @Inject() (
def bulkUpdate(ids: Seq[String], fields: Fields, modifyConfig: ModifyConfig)(implicit authContext: AuthContext): Future[Seq[Try[ReportTemplate]]] =
updateSrv[ReportTemplateModel, ReportTemplate](reportTemplateModel, ids, fields, modifyConfig)

def delete(id: String)(implicit Context: AuthContext): Future[Unit] =
def delete(id: String)(implicit authContext: AuthContext): Future[Unit] =
deleteSrv.realDelete[ReportTemplateModel, ReportTemplate](reportTemplateModel, id)

def find(queryDef: QueryDef, range: Option[String], sortBy: Seq[String]): (Source[ReportTemplate, NotUsed], Future[Long]) =
Expand Down

0 comments on commit 984dbf5

Please sign in to comment.