typelevel / typelevel/cats-effect

Fiber identity

Open
#828 9 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

It seems like Cats Effect today doesn't support any notion of fiber identity, at least via the public API. This has several interesting use cases:

  1. Fiber logging: There is a disconnect between existing JVM logging libraries and fiber-based runtimes (or more generally, asynchronous code). The loggers typically output the ID of the thread on which it is running, but oftentimes that name is useless since fiber execution can take place on potentially many threads. Being able to aggregate the logs produced by a fiber could be pretty powerful.
  2. Fiber-local state: Useful in situations where you want to pass along state for dealing with cross-cutting concerns, like passing along a trace ID that is exchanged in a chain of microservice calls. There is an argument that it suffers from similar problems as thread-local storage.
  3. Fiber ancestry: fiber forking generates a directed acyclic graph where there are directed edges between a parent and its children. Unsure if there are any compelling use cases for this but it could provide for some interesting analysis.
  4. Fiber tracing: There's already an issue open for this and it might not strictly fall under fiber identity, but I could see some overlap here in tracking state.

Some other effect types already support fiber identity to some degree, so maybe there's room for some effect class here, but I don't really know how much abstraction can be captured.

Does any of this make sense and does it even fall under the scope of Cats Effect IO or its classes? Would be interested in fleshing it out more if so.

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

No files, tests, or entry points are named. Start by reviewing Cats Effect's public IO and effect abstractions, along with the existing fiber-tracing issue referenced here, then clarify whether fiber identity is in scope. Done would require an agreed API and design, which this issue does not yet specify.

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.