typelevel / typelevel/cats-effect

"`ResourceSupervisor`"

Open
#3,376 2 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

:mushroom: enhancement
Dominant language
Scala
Stars
2.2k
Forks
576
Avg merge
2d 11h
Merged PRs (30d)
18

Description

This is an idea @TimWSpence and I cooked up once on Discord, starting from https://github.com/typelevel/fs2/pull/2300#issuecomment-1325010963.

The idea is very similar to the existing Supervisor which allows to start a fiber, and bind its lifecycle to some outer scope. Here, we want to allocate a Resource and bind its lifecycle to the outer scope.

ResourceSupervisor[F].use { supervisor =>
  resourceA.allocateSupervised(supervisor).flatMap { (a, release) =>
    // do stuff
  }
}

allocateSupervised (or superviseAllocated ?) would work like allocated, except in case the release is not invoked for some reason, it will be cleaned up once the supervisor scope ends.

tl;dr start is to allocated what supervise is to (we need something here :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked PR discussion and the existing Supervisor, allocated, and Resource APIs. Clarify the proposed ResourceSupervisor and allocateSupervised lifecycle semantics, including cleanup when release is not invoked, then define the API and tests needed to demonstrate cleanup at supervisor-scope end.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.