Skip to content

Allow response sizes larger than 2MiB in JettyRPCFramework client #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object JettyRPCFramework extends StandardRPCFramework with LazyLogging {
case class Call(chain: List[Invocation], leaf: Invocation)
object Call extends HasGenCodec[Call]

class RPCClient(httpClient: HttpClient, uri: String)(implicit ec: ExecutionContext) {
class RPCClient(httpClient: HttpClient, uri: String, maxResponseLength: Int)(implicit ec: ExecutionContext) {
private class RawRPCImpl(chain: List[Invocation]) extends RawRPC {
override def fire(rpcName: String)(args: List[RawValue]): Unit =
put(Call(chain, Invocation(rpcName, args)))
Expand All @@ -60,7 +60,7 @@ object JettyRPCFramework extends StandardRPCFramework with LazyLogging {
def request(method: HttpMethod, call: Call): Future[RawValue] = {
val promise = Promise[RawValue]

val listener = new BufferingResponseListener() {
val listener = new BufferingResponseListener(maxResponseLength) {
override def onComplete(result: Result): Unit = {
if (result.isFailed) {
promise.tryFailure(result.getFailure)
Expand Down Expand Up @@ -140,6 +140,7 @@ object JettyRPCFramework extends StandardRPCFramework with LazyLogging {
def newHandler[T](impl: T)(implicit ec: ExecutionContext, asRawRPC: AsRawRPC[T]): Handler =
new RPCHandler(asRawRPC.asRaw(impl))

def newClient[T](httpClient: HttpClient, uri: String)(implicit ec: ExecutionContext, asRealRPC: AsRealRPC[T]): T =
asRealRPC.asReal(new RPCClient(httpClient, uri).rawRPC)
def newClient[T](httpClient: HttpClient, uri: String, maxResponseLength: Int = 2 * 1024 * 1024)(
implicit ec: ExecutionContext, asRealRPC: AsRealRPC[T]): T =
asRealRPC.asReal(new RPCClient(httpClient, uri, maxResponseLength).rawRPC)
}