typelevel / typelevel/cats-effect

Idea: Managed resource map

Open
#1,345 11 comments 2 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

trait Manager[F[_], K, V] {

  def +=(pair: (K, Resource[F, V])): F[Unit]

  def -=(key: K): F[Unit]

  def apply(key: K): F[Option[V]]

  def join(key: K): F[V]
}

object Manager {
  def apply[F[_]: Sync, K, V]: Resource[F, Manager[F, K, V]] = ???
}

The idea here is that it's often useful to have a concurrent map-like data structure which manages Resource lifecycles for you, indexed by some key (so you can retrieve the results). These resources can be submitted (via +=) and will be evaluated in background, with their value stored in the map once complete. Removing the key from the map would close the resource scope. Similarly, closing the resource scope on the Manager would close all constituent Resources and cancel any outstanding computations.

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 with the proposed Manager trait and Manager.apply signature in this issue, then trace the Resource and Sync abstractions used by cats-effect. Done means defining and implementing the requested submission, lookup, join, removal, and manager-shutdown lifecycle semantics, including pending computations.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.