Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

This branch is even with develop

scrooge: Generate a finagle Service per thrift method

Problem

Scrooge-generated services are not finagle Services, so they do not allow using Filters.

Solution

Generate a wrapper service that delegates to the underlying thrift service.

Result

For a thrift service, e.g.

service Logger {
  string log(1: string message, 2: i32 logLevel);
  i32 getLogSize();
}

Scrooge generates:

class Logger$ServiceImpl(underlying: Logger[Future]) {
  val log: com.twitter.finagle.Service[(String, Int), String] = ...
  val getLogSize: com.twitter.finagle.Service[Unit, Int] = ...
}

Usage in finagle:

val client = ThriftMux.newServiceIface(Logger, "localhost:8080")

client.log(Logger.Log.Args("message", 1)) onSuccess {...}

This avoids the reflection-based initialization (ThriftRichClient) by collecting the relevant types during generation.

Compatibility constructor to build a FutureIface from a ServiceIface:

val loggerFutureIface = Logger.newFutureIface(loggerServiceIface)
loggerFutureIface.log("msg")

Client configuration is done by e.g.

ThriftMux.client.withClientId(ClientId("asdf")).newServiceIface(Logger, dest)

RB_ID=663690
latest commit 3fbb635936
@nshkrob nshkrob authored
Something went wrong with that request. Please try again.