akka / akka/akka-http

Provide an example for how to implement Http long polling

Open
#63 38 comments 0 reactions 0 assignees View on GitHub
1 - triaged 3 - in progress help wanted
Dominant language
Scala
Stars
1.4k
Forks
584
Avg merge
14h 33m
Merged PRs (30d)
24

Description

**Issue by [agemooij](https://github.com/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].

Contributor guide

Open the contributing guide

Research direction

Start with the client-side akka-http and streams APIs named in the issue, especially Http().outgoingConnection and its Flow[HttpRequest, HttpResponse, Future[Http.OutgoingConnection]]. Done means the documentation includes a working long-polling example that recreates a closed connection and bases each request on the previous response, producing a Source of Consul change events.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.