Generator for iterated api calls

Description

Problem

Consuming iterated/pagenated APIs is a frequent need for Clojure devs but writing code that consumes them efficiently and handles various flow patterns is nuanced.

Approach

Add a generator function to clojure.core for iterated API calls, that can represent iteration e.g. HTTP endpoints that return continuation tokens.

Background

Examples of tasks within this problem category include:

  1. using aws-api everyday - lots of APIs return continuation tokens and you have to stitch calls together

  2. walking up a superclass hierarchy: Long -> Number -> Object

  3. collecting exception cause chains

Common approaches use some combination of iterate and take-while and while expedient, this approach couples the "beget" part of the iteration protocol with the "has-more?" part of the protocol. A ticket that attempted to address iterated protocols was CLJ-1906. Rich created an example iteration function that provided an a la carte iterated API consumer.

Screened By: Fogus

Patch: clj-2555-iteration.patch

Environment

None

Attachments

2

Activity

Show:

Alex MillerJanuary 14, 2022 at 4:35 PM

-2 patch was rebased to master and was what was actually applied

Alex MillerJanuary 13, 2022 at 10:05 PM

Released in 1.11.0-alpha4

Alex MillerJanuary 13, 2022 at 8:30 PM

-2 patch rebases against master, no changes, attribution retained

Fixed

Details

Assignee

Reporter

Approval

Ok

Patch

Code and Test

Priority

Fix versions

Created January 31, 2020 at 11:11 PM
Updated January 14, 2022 at 4:35 PM
Resolved January 13, 2022 at 10:05 PM