com.codemettle.akkasolr.client.package.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of akka-solr_2.11 Show documentation
Show all versions of akka-solr_2.11 Show documentation
Solr HTTP client using Akka and Spray
The newest version!
package com.codemettle.akkasolr
import com.codemettle.akkasolr.solrtypes.SolrQueryResponse
import scala.concurrent.{ExecutionContext, Future}
/**
* Created by steven on 5/17/2018.
*/
package object client {
implicit class RichResponse(val res: SolrQueryResponse) extends AnyVal {
def toFailMessage(implicit opts: Solr.UpdateOptions): Either[Solr.UpdateError, SolrQueryResponse] =
res.status match {
case status if status != 0 && opts.failOnNonZeroStatus => Left(Solr.UpdateError(status, res.errorMessageOpt))
case _ => Right(res)
}
}
implicit class RichResponseFuture(val resF: Future[SolrQueryResponse]) extends AnyVal {
def failIfNeeded(implicit opts: Solr.UpdateOptions, ec: ExecutionContext): Future[SolrQueryResponse] =
resF.map(_.toFailMessage) flatMap {
case Left(err) => Future.failed(err)
case Right(res) => Future.successful(res)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy