![]() ![]() You should size the pool to leave a safety margin large enough to account for failures. If you are doing any blocking work, including any kind of DNS work such as calling (), then you should use a custom execution context as described in ThreadPools, preferably through a CustomExecutionContext. This returns a Future where the Response contains the data returned from the server. val futureResponse: Future = complexRequest.get() This ends the chain, and uses all the options defined on the built request in the WSRequest. You end by calling a method corresponding to the HTTP method you want to use. addQueryStringParameters("search" -> "play") addHttpHeaders("Accept" -> "application/json") You can chain calls together to construct complex requests. This returns a WSRequest that you can use to specify various HTTP options, such as setting headers. To build an HTTP request, you start with ws.url() to specify the URL. We’ve called the WSClient instance ws, all the following examples will assume this name. Now any component that wants to use WS will have to declare a dependency on the WSClient: import Ĭlass Application (ws: WSClient, val controllerComponents: ControllerComponents) extends BaseController Using an HTTP cache means savings on repeated requests to backend REST services, and is especially useful when combined with resiliency features such as stale-on-error and stale-while-revalidate. Once you have the library dependencies, then enable the HTTP cache as shown on WS Cache Configuration page. Or you can use another JSR-107 compatible cache such as Caffeine. You can add ehcache: libraryDependencies += ehcache Play WS supports HTTP caching, but requires a JSR-107 cache implementation to enable this feature. To use WSClient, first add ws to your build.sbt file: libraryDependencies += ws Please see the 2.6 migration guide for more information. In addition, shaded versions of AsyncHttpClient and Netty are now used in Play WS to minimize library conflicts, primarily so that Play’s HTTP engine can use a different version of Netty. Note: In Play 2.6, Play WS has been split into two, with an underlying standalone client that does not depend on Play, and a wrapper on top that uses Play specific classes. Finally, we’ll discuss some common use cases. We’ll discuss how to make both GET and POST HTTP requests first, and then show how to process the response from WSClient. There are two important parts to using the WSClient: making a request, and processing the response. Play supports this via its WS (“WebService”) library, which provides a way to make asynchronous HTTP calls through a WSClient instance. Sometimes we would like to call other HTTP services from within a Play application. -Number of webfeeds processed per second.English ▾ English българин Français 日本語 Türkçe Calling REST APIs with Play WS.-Graphs show rough representation of throughput in # of message sent by units of time-Greater throughput with less computational capacity.Common pattern for handling futures in Akka actors.Ning’s async-http-client-library written in Java but some Scala wrappers exist-we use Play’s wrapper for convenience but access the underlying ning client for greater control of the configuration-easy to configure-returns a Future to map, compose, etc.actors (encapsulate state and behaviour - true encapsulation)mailboxesimmutable messagessupervisory hierarchyconcurrency and distribution is handled by the framework.Talk about the example of mailing a letter or getting your car/bike fixedWaiting around for something that someone else is doing to be finished is simply wasteful.-Show a rough sketch of php+gearman+cron-Latency, latency, latency everywhere!.-So, what am I going to talk about? RSS/Atom feeds?-XML? Is this guy for real?-Constant decline over the years as consumer-facing technology (graph)-But still used a great deal between "content services"-How are RSS/Atom feeds used at Hootsuite?-Webfeeds at Hootsuite how much?.-Who I am-What does Hootsuite do-What the Publishing team does-Mention move to service-oriented/microservices architecture-Scala+Akka at Hootsuite(not sure I need some slides for this material).O Easier to describe supervisor’s responsibilities O Easy to modify the actor topology (and it will Actors should only ever do one thing (and do.Be weary of the resulting load on the rest of.CPU utilization & load average - barely breaking a sweat!.O Responsive, Resilient, Elastic, Message-driven Adheres strictly to the Reactive Manifesto:.Akka: a short detour for the uninitiatedĬoncurrent, distributed, and fault tolerant.But latency isn’t the problem blocking is.O ~250K active feeds, ~400K messages daily ![]() O Post to social networks based on content Still very popular between “content services”.Scala + Akka + ning/async-http-client - Vancouver Scala meetup February 2015 ![]()
0 Comments
Leave a Reply. |