v3.0.0
NOTE: This release has been superseded by 3.1.0 shortly after, which rolls back the underlying behavioral changes described below but keeps the new syntax additions. Please update to 3.1.0 instead, to minimize necessary changes from the 2.x series.
The original release notes are below:
Fetch has been updated to 3.0.0. This release contains one behavioral breaking change, and several upstream library upgrades (Cats 2.7, Cats Effect 3.3.4) as well as patch releases of http4s (0.23.8)
PSA: If you upgrade to Cats 2.7.0 without upgrading to Fetch 3.0.0, this can affect behavior of auto-batching. We strongly recommend you upgrade to Fetch 3.x if you are on Cats 2.7.0, and follow migration instructions below to ensure batches are handled properly.
The breaking change involves how batches are created. Previously, if you ran functions like .traverse or .sequence to produce a list of fetch results, Fetch would implicitly try to batch requests together. For Fetch 3.0.0 we have decided to provide explicit batching syntax instead of guaranteeing implicit batching of fetches. This may be further expanded upon in future releases.
Currently, batching with Applicative syntax can still occur, but batching with traverse, sequence, or anything that internally uses map2Eval is unsupported. This may change in future releases as more explicit batching syntax is added.
For example, assume you have a function fetchName which fetches a user's name given an integer ID. You want to batch multiple requests to save on bandwidth, so you write the following code:
import cats.effect.{Concurrent, IO}
//Fetches a user's name by ID
def fetchName[F[_]: Concurrent](id: Int): Fetch[F, String] = ???
//Attempts to batch a request for users 1, 2, and 3
val batchedRequests = List(1, 2, 3).traverse(id => fetchName[IO](id))In older versions of Fetch this will batch requests so that it will try to get all three at once, but in the current version (3.0.0) this behavior has been made explicit. You should now opt-in to this behavior by either calling Fetch.batchAll or by using special syntax, like so:
//You can explicitly batch requests without syntax using Fetch.batchAll
//It uses varargs so you can manually put in any number of fetches, or expand a list with `: _*` syntax
val explicitBatchedRequest = Fetch.batchAll(fetchName[IO](1), fetchName[IO](2), fetchName[IO](3))
import fetch.syntax._
//batchAll syntax works similarly to `sequence` and operates on any `Seq[Fetch[F, A]]`
val batchedRequestSyntax = List(1, 2, 3).map(id => fetchName[IO](id)).batchAll
//batchAllWith syntax is similar, but works like `traverse` instead
val batchedRequestWithSyntax = List(1, 2, 3).batchAllWith(id => fetchName[IO](id))In your code, if you would like to retain batching in places where you use traverse or sequence already, you can simply replace them with batchAllWith and batchAll syntax respectively and retain the old functionality. Any traverse or sequence calls in Fetch >=3.0.0 are not guaranteed to be batched, and will be sequenced like any other flatMap chain or for-comprehension.
What's changed
- Update jedis to 4.1.0 (#592) @47erbot
- Update http4s-blaze-client, http4s-circe to 0.23.8 (#591) @47erbot
- Update scalatest to 3.2.11 (#589) @47erbot
- Update scalafmt-core to 3.3.3 (#588) @47erbot
- Update scalafmt-core to 3.3.2 (#587) @47erbot
- Update doobie-core, doobie-h2 to 1.0.0-RC2 (#584) @47erbot
- Update scala-library to 2.13.8 (#583) @47erbot
- Update sbt-github, sbt-github-header, ... to 0.11.2 (#581) @47erbot
- Update scalafmt-core to 3.3.1 (#579) @47erbot
- Update jedis to 4.0.1 (#578) @47erbot
- Update sbt to 1.6.1 (#576) @47erbot
- Update scalafmt-core to 3.3.0 (#575) @47erbot
- Update sbt-scalafmt to 2.4.6 (#574) @47erbot
- Update sbt to 1.6.0 (#573) @47erbot
- Update scalafmt-core to 3.2.2 (#572) @47erbot
- Update jedis to 4.0.0 (#571) @47erbot
- Update sbt to 1.5.8 (#569) @47erbot
- Update jedis to 3.8.0 (#568) @47erbot
- Update sbt to 1.5.7 (#567) @47erbot
- Update sbt to 1.5.6 (#565) @47erbot
- Update jedis to 3.7.1 (#566) @47erbot
- Update sbt-scalajs, scalajs-compiler, ... to 1.8.0 (#564) @47erbot
- Update http4s-blaze-client, http4s-circe to 0.23.7 (#563) @47erbot
- Update sbt-scalafmt to 2.4.5 (#561) @47erbot
- Update scalafmt-core to 3.2.1 (#562) @47erbot
- Update scalafmt-core to 3.2.0 (#560) @47erbot
- Update scalafmt-core to 3.1.2 (#558) @47erbot
- Update sbt-scalafmt to 2.4.4 (#557) @47erbot
- Update scalafmt-core to 3.1.1 (#556) @47erbot
- Update scalafmt-core to 3.1.0 (#555) @47erbot
- Update scala-library to 2.13.7 (#554) @47erbot
- Update scalafmt-core to 3.0.8 (#553) @47erbot
- Update sbt-github, sbt-github-header, ... to 0.11.1 (#552) @47erbot
- Update sbt-github, sbt-github-header, ... to 0.11.0 (#551) @47erbot
- Update mdoc, sbt-mdoc to 2.2.24 (#549) @47erbot
- Update scalafmt-core to 3.0.7 (#550) @47erbot
- Update sbt-github, sbt-github-header, ... to 0.10.1 (#547) @47erbot
- Update sbt-ci-release to 1.5.10 (#546) @47erbot
- Update http4s-blaze-client, http4s-circe to 0.23.6 (#545) @47erbot
- Update sbt-scalajs, scalajs-compiler, ... to 1.7.1 (#544) @47erbot
- Update http4s-blaze-client, http4s-circe to 0.23.5 (#543) @47erbot
- Update scalafmt-core to 3.0.6 (#542) @47erbot
- Update scalafmt-core to 3.0.5 (#541) @47erbot
- Update sbt-ci-release to 1.5.9 (#540) @47erbot
- Update sbt-github, sbt-github-header, ... to 0.10.0 (#539) @47erbot