liveBook · Manning

futureSource

As explained in Akka in Action, Second Edition

futureSource is an Akka Streams source operation that creates a source from a future producing another source.

futureSource creates an Akka Streams source from a Future that produces another source. It is useful when an external asynchronous call, such as a gRPC request, returns a stream only after the Future completes. section 16.3.4

Wrapping a gRPC streaming call

Source.futureSource { val responseStream: Source[Location, NotUsed] = client.follow() Future(responseStream) }

Combined with RestartSource.withBackoff, futureSource lets a stream retry a failed service call. Backoff increases between attempts, while restart limits and jitter control retry duration and synchronization. section 16.3.4

How Akka in Action, Second Edition covers it

How deep it goes
Defines the wrapping pattern and its role in retries, but does not detail future or stream implementation internals.
Examples
Demonstrates a LocatorService Follow call returning Location values through a restarted gRPC stream.
What it assumes
Assumes familiarity with Akka Streams Source, Scala Future, and asynchronous gRPC clients.
What you can do after
Apply it via Akka Streams to turn a Future-wrapped streaming response into a restartable source.
How it connects
Connects Future, Source, RestartSource, backoff, and gRPC streaming.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Akka in Action, Second Edition. The section links point to the parts of the book it draws on.