akka/akka-http

Provide an example for how to implement Http long polling

Ouverte

#63 ouverte le 8 sept. 2016

 (38 commentaires) (0 réaction) (0 personne assignée)Scala (598 forks)batch import
1 - triaged3 - in progresshelp wanted

Métriques du dépôt

Stars
 (1 311 étoiles)
Métriques de merge PR
 (Merge moyen 1j 10h) (2 PRs mergées en 30 j)

Description

Issue by agemooij Tuesday Mar 22, 2016 at 16:33 GMT Originally opened as https://github.com/akka/akka/issues/20121


Quoted from a Gitter discussion:

Hey hakkers. I'm still pretty new to doing complex things with streams and akka-http. Does anyone have an example of how to implement long polling with the client-side part of akka-http? I've got a Consul client written as Spray actors that I'm thinking of moving to akka-http but the conceptual model is (unsurprisingly) very different indeed.

The docs mention long polling a bunch of times when discussing the higher (i.e. connection pooling) API levels but I can't find any real information (docs, examples, blogs, SO questions, etc.) on how I would go about implementing a long polling client using akka-http and streams.

For instance: I want to poll forever but how do I automatically recreate the http connection produced by Http().outgoingConnection when it closes? And that method produces a Flow[HttpRequest, HttpResponse, Future[Http.OutgoingConnection]] but how do I turn that into a loop of requests where every next request is based on the response to the previous one (i.e. polling forchanges since the index that got sent with the previous change). Both of these are basically circular/recursive internal graph stages but conceptually what I want is a Source[ConsulChangeEvent].

Guide contributeur