Scrooge v17.12.0 Release Notes
-
- scrooge: Introduce
scrooge.Request
andscrooge.Response
envelopes which are used inReqRepServicePerEndpoint
interfaces and associated code. The scroogeRequest
andResponse
allow for passing "header" information (via ThriftMux Message contexts) between clients and servers. For instance, a server can implement aReqRepServicePerEndpoint
, and set response headers along with a method response, e.g.,
.. code-block:: scala
class MyService extends MyService.ReqRepServicePerEndpoint { def foo: Service[Request[Foo.Args], Response[Foo.SuccessType]] = { Service.mk[Request[Foo.Args], Response[Foo.SuccessType]] { request: Request[Foo.Args] => val result = ... // computations Future .value( Response( headers = Map("myservice.foo.header" -> Seq(Buf.Utf8("value1"))), result) } } }
This
ServicePerEndpoint
can then be served usingThriftMux
:.. code-block:: scala
ThriftMux.server.serveIface(":9999", new MyService().toThriftService)
These response headers will be transported as
Mux#contexts
to the client. If the client is using the client-sideReqRepServicePerEndpoint
it will be able to read the headers from the returnedResponse
directly. E.g.,.. code-block:: scala
val client = ThriftMux.client.reqRepServicePerEndpoint[MyService.ReqRepServicePerEndpoint] val response: Response[Foo.SuccessType] = Await.result(client.foo(..)) if (response.headers.contains("myservice.foo.header")) { ...
Users can also choose to wrap the
ReqRepServicePerEndpoint
with aMethodPerEndpoint
viaThriftMux.client.reqRepMethodPerEndpoint(reqRepServicePerEndpoint)
in order to deal with methods instead of services. See the scrooge documentation for more information.PHAB_ID=D107397
- scrooge: Introduce