forked from actionml/universal-recommender
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for Future-based predict-method, see apache/predictionio#495
- Loading branch information
Chris Wewerka
committed
Nov 9, 2018
1 parent
5445b93
commit 2267d9d
Showing
4 changed files
with
167 additions
and
126 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.actionml | ||
|
||
import org.apache.http.{Header, HttpEntity} | ||
import org.elasticsearch.client.{Response, ResponseListener, RestClient} | ||
import scala.collection.JavaConverters._ | ||
import scala.concurrent.{Future, Promise} | ||
|
||
object ScalaRestClient { | ||
|
||
implicit class ExtendedScalaRestClient(restClient: RestClient) { | ||
|
||
def performRequestFuture(method: String, endpoint: String, params: Map[String, String], | ||
entity: HttpEntity, headers: Header*): Future[Response] = { | ||
val promise: Promise[Response] = Promise() | ||
val responseListener = new ResponseListener { | ||
override def onSuccess(response: Response): Unit = promise.success(response) | ||
override def onFailure(exception: Exception): Unit = promise.failure(exception) | ||
} | ||
restClient.performRequestAsync(method, endpoint, params.asJava, entity, responseListener, headers: _*) | ||
promise.future | ||
} | ||
} | ||
} |
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