Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #4528 - Support mirroring FiberRef contents to ThreadLocal #5907

Merged
merged 12 commits into from
May 27, 2022

Conversation

dkarlinsky
Copy link
Contributor

@dkarlinsky dkarlinsky commented Oct 30, 2021

Defineds a new layer ThreadLocalBridge.
The layer installs a supervisor that handles syncing on async boundaries (unsafeOnResume, unsafeOnSuspend).
ThreadLocalBridge provides makeFiberRef method to create a special FiberRef that syncs the changes

issue #4528

@dkarlinsky
Copy link
Contributor Author

@jdegoes need your input on possible ways to reset to the fiber ref's previous value at the end of FiberRef.locally
Currently I intercept FiberRefLocally (in unsafeOnEffect) effects and call link(locally.localValue) but I don't see a way reset to the fiber refs previous value after

Copy link
Contributor

@adamgfraser adamgfraser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long time coming! 😃

@adamgfraser adamgfraser merged commit 64ab5e6 into zio:series/2.x May 27, 2022
dkarlinsky added a commit to dkarlinsky/zio that referenced this pull request May 29, 2022
adamgfraser pushed a commit that referenced this pull request May 30, 2022
* Rewritten based on the merged version of PR #5907

* call Supervisor.unsafeOnResume() even if `superviseOperations` is false (same as ZIO 2)
adamgfraser pushed a commit that referenced this pull request Jun 24, 2022
* Add Prezi to adopters list (#6864)

* Fix ZIO 1.x sidebars (#6863)

* remove extra sidebar
rename how-to to guides

* rename howto to guides.

* issue #5878 - Backport ThreadLocalBridge (#5980)

* Rewritten based on the merged version of PR #5907

* call Supervisor.unsafeOnResume() even if `superviseOperations` is false (same as ZIO 2)

* chore(deps): update zio.version to v1.0.15 (#6899)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

* add 7 and 8 arg for check, checkM, checkAll and checkAllM (#6916)

* Fix frontmatters (#6949)

* remove extra usecases sidebar.

Co-authored-by: Mate Borcsok <mate.borcsok@prezi.com>
Co-authored-by: Dmitry Karlinsky <dmitryka@wix.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: LUC DUZAN <strokyl@users.noreply.github.com>
Co-authored-by: Daniel Vigovszky <daniel.vigovszky@gmail.com>
adamgfraser pushed a commit that referenced this pull request Jun 24, 2022
* remove handle error page.

* expected errors vs. unexpected errors.

* don't type unexpected errors.

* add a general note for when importing effects.

* modeling domain errors using algebraic data types.

* typed errors using union types.

* using union type to be more specific about error types.

* don't reflexively log errors.

* exceptional and unexceptional effects.

* imperative vs. functional error handling.

* lossless error model.

* either and absolve.

* some note about orDie.

* sandbox and unsandbox.

* zio defects and fatal errors.

* default

* converting defects to failures and vice versa.

* refining and unrefining the type of the error channel.

* absorbing or resurrecting vs. dying.

* converting defects to failures.

* write an introduction to sandboxing errors.

* a better title for sandbox section.

* three type of errors in zio.

* add examples.

* add tslib.

* create a new page for error management.

* some and unsome zio values.

* use compile-only modifier for mdoc blocks.

* creating a ZIO of optional values.

* ZIO.getOrFail constructor.

* explain more on getOrFail constructors.

* flattening optional error types.

* ZIO#getOrElse

* document the ZIO#someOrElseZIO operator.

* someOrFail operation.

* add a note on some or fail exception.

* fix the example of ZIO#sandboxWith.

* introduction for error management.

* add example for sandboxWith operator.

* fallback on optional error types.

* ZIO#orElseFail.

* more note on ZIO#orElseFail and also add documentation for ZIO#orElseSucceed.

* document ZIO#orElse operator.

* clean up code blocks and their imports.

* document ZIO#orElseEither.

* document fold operators.

* document ZIO#foldTraceZIO

* remove extra table.

* write a note on fiber interruption and the fold operator.

* retry and retryOrElse operators.

* retryOrElseEither.

* ZIO#retryN

* retryUntil and retryUntilZIO

* retryUntilEqual

* retryWhile, retryWhileZIO and retryWhileEquals

* timeout operator

* cleanup

* using ZIO#disconnect with ZIO#timeout.

* ZIO#timeoutTo

* producing error message in case of timeout.

* cleanup absolve and either section.

* cleanup sandbox examples.

* catchAll convert exceptional effects to unexceptional effects.

* catchSome section

* note on catching defects and fiber interruptions.

* catching defects.

* catching all errors.

* catching traces.

* typed errors don't guarantee the absence of defects and interruptions.

* fix mdoc's error.

* cause is a semiring and show how the cause designed.

* cause internals.

* failure cause.

* wip on cause page.

* wip on cause.

* then cause for sequential errors.

* cleanup the cause page.

* clean-up.

* definition of the exit data type.

* cause internals.

* add result type.

* fix mdoc failure.

* fix `mdoc -watch` breakage.

* update mdoc version.

* complete failure section.

* clean up fatal errors section.

* reorder topics.

* fix title.

* sequential and parallel errors.

* change header levels.

* exposing parallel failure errors.

* error accumulation.

* introduce ZIO#validate and ZIO#validatePar operators.

* cleanup.

* add function definitions.

* write a note about ZIO#validateWith.

* merging the error channel into success channel.

* flipping the error and success channels.

* firstSuccessOf

* add more explanation.

* nonOrFail

* getOrFail and nonOrFail.

* rejecting some values.

* fix method name.

* map and flatMap on error channels.

* introduce all error refinement methods.

* introduce left/unleft, right/unright operations.

* cleanup.

* converting optional values to optional errors and vice versa.

* rename left and right section.

* uncovering the underlying cause of an effect.

* cleanup

* catching non-fatal.

* filtering the success channel values.

* complete ZIO#someOrElse section.

* tapping.

* tapping errors.

* add definition of ZIO#resurrect and ZIO#absorb.

* add definition of ZIO#either and ZIO#absolve.

* add tapSome.

* write a note about why we need to catch defects.

* remove extra note.

* add definition of all catch methods.

* cleanup.

* proofreading.

* cleanup zio.md page.

* fix mdoc errors.

* fix validate output.

* examples

* cleanup.

* remove default services from the zio environment.

* fix imports.

* fix typo.

* use ZIO instead of IO.

* fix mdoc errors.

# Conflicts:
#	docs/datatypes/core/zio/zio.md

* regarding removal of RuntimeConfig.

* fix warning.

* Switch ZIO version for 1.0 docs to 1.0.14

* Upgrade to docusaurus beta-20

* Add appId to docusaurus config

* Make Overview link version aware

* testing versioned links

* another try on versioned links

* Trying a version relative link

* yet another relative link try

* Playing with config vars

* trying docsVersion without statis override

* Try version specific navbar

* Swizzling Navbar component for version resolution

* Switch navbar links to doc links

* Correct docid in sidebar

* Break site build on broken links

* Add Prezi to adopters list (#6864)

* Fix ZIO 1.x sidebars (#6863)

* remove extra sidebar
rename how-to to guides

* rename howto to guides.

* issue #5878 - Backport ThreadLocalBridge (#5980)

* Rewritten based on the merged version of PR #5907

* call Supervisor.unsafeOnResume() even if `superviseOperations` is false (same as ZIO 2)

* chore(deps): update zio.version to v1.0.15 (#6899)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

* workaround.

* remove empty article.

* prepare for publish.

* fix mdoc errors.

* minor change.

* update zio-kafka ecosystem page.

* add 7 and 8 arg for check, checkM, checkAll and checkAllM (#6916)

* initial work.

* conclusion section.

* fix sidebar.

* fix site build problem.

* initial work.

* Fix frontmatters (#6949)

* Use master for version 1 build for now

* remove extra usecases sidebar.

* orrect navbar

* Switch back version 1 docs ref

* Remove docusaurus site build from sbt message

* Fix some broken links

* Fix checkSite build step

* Remove obsolete link

* Replace occurrences of ZTrace with Trace

Co-authored-by: Milad Khajavi <khajavi@gmail.com>
Co-authored-by: Mate Borcsok <mate.borcsok@prezi.com>
Co-authored-by: Dmitry Karlinsky <dmitryka@wix.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: LUC DUZAN <strokyl@users.noreply.github.com>
Co-authored-by: Daniel Vigovszky <daniel.vigovszky@gmail.com>
vigoo added a commit that referenced this pull request Jun 25, 2022
* remove handle error page.

* expected errors vs. unexpected errors.

* don't type unexpected errors.

* add a general note for when importing effects.

* modeling domain errors using algebraic data types.

* typed errors using union types.

* using union type to be more specific about error types.

* don't reflexively log errors.

* exceptional and unexceptional effects.

* imperative vs. functional error handling.

* lossless error model.

* either and absolve.

* some note about orDie.

* sandbox and unsandbox.

* zio defects and fatal errors.

* default

* converting defects to failures and vice versa.

* refining and unrefining the type of the error channel.

* absorbing or resurrecting vs. dying.

* converting defects to failures.

* write an introduction to sandboxing errors.

* a better title for sandbox section.

* three type of errors in zio.

* add examples.

* add tslib.

* create a new page for error management.

* some and unsome zio values.

* use compile-only modifier for mdoc blocks.

* creating a ZIO of optional values.

* ZIO.getOrFail constructor.

* explain more on getOrFail constructors.

* flattening optional error types.

* ZIO#getOrElse

* document the ZIO#someOrElseZIO operator.

* someOrFail operation.

* add a note on some or fail exception.

* fix the example of ZIO#sandboxWith.

* introduction for error management.

* add example for sandboxWith operator.

* fallback on optional error types.

* ZIO#orElseFail.

* more note on ZIO#orElseFail and also add documentation for ZIO#orElseSucceed.

* document ZIO#orElse operator.

* clean up code blocks and their imports.

* document ZIO#orElseEither.

* document fold operators.

* document ZIO#foldTraceZIO

* remove extra table.

* write a note on fiber interruption and the fold operator.

* retry and retryOrElse operators.

* retryOrElseEither.

* ZIO#retryN

* retryUntil and retryUntilZIO

* retryUntilEqual

* retryWhile, retryWhileZIO and retryWhileEquals

* timeout operator

* cleanup

* using ZIO#disconnect with ZIO#timeout.

* ZIO#timeoutTo

* producing error message in case of timeout.

* cleanup absolve and either section.

* cleanup sandbox examples.

* catchAll convert exceptional effects to unexceptional effects.

* catchSome section

* note on catching defects and fiber interruptions.

* catching defects.

* catching all errors.

* catching traces.

* typed errors don't guarantee the absence of defects and interruptions.

* fix mdoc's error.

* cause is a semiring and show how the cause designed.

* cause internals.

* failure cause.

* wip on cause page.

* wip on cause.

* then cause for sequential errors.

* cleanup the cause page.

* clean-up.

* definition of the exit data type.

* cause internals.

* add result type.

* fix mdoc failure.

* fix `mdoc -watch` breakage.

* update mdoc version.

* complete failure section.

* clean up fatal errors section.

* reorder topics.

* fix title.

* sequential and parallel errors.

* change header levels.

* exposing parallel failure errors.

* error accumulation.

* introduce ZIO#validate and ZIO#validatePar operators.

* cleanup.

* add function definitions.

* write a note about ZIO#validateWith.

* merging the error channel into success channel.

* flipping the error and success channels.

* firstSuccessOf

* add more explanation.

* nonOrFail

* getOrFail and nonOrFail.

* rejecting some values.

* fix method name.

* map and flatMap on error channels.

* introduce all error refinement methods.

* introduce left/unleft, right/unright operations.

* cleanup.

* converting optional values to optional errors and vice versa.

* rename left and right section.

* uncovering the underlying cause of an effect.

* cleanup

* catching non-fatal.

* filtering the success channel values.

* complete ZIO#someOrElse section.

* tapping.

* tapping errors.

* add definition of ZIO#resurrect and ZIO#absorb.

* add definition of ZIO#either and ZIO#absolve.

* add tapSome.

* write a note about why we need to catch defects.

* remove extra note.

* add definition of all catch methods.

* cleanup.

* proofreading.

* cleanup zio.md page.

* fix mdoc errors.

* fix validate output.

* examples

* cleanup.

* remove default services from the zio environment.

* fix imports.

* fix typo.

* use ZIO instead of IO.

* fix mdoc errors.

# Conflicts:
#	docs/datatypes/core/zio/zio.md

* regarding removal of RuntimeConfig.

* fix warning.

* Switch ZIO version for 1.0 docs to 1.0.14

* Upgrade to docusaurus beta-20

* Add appId to docusaurus config

* Make Overview link version aware

* testing versioned links

* another try on versioned links

* Trying a version relative link

* yet another relative link try

* Playing with config vars

* trying docsVersion without statis override

* Try version specific navbar

* Swizzling Navbar component for version resolution

* Switch navbar links to doc links

* Correct docid in sidebar

* Break site build on broken links

* Add Prezi to adopters list (#6864)

* Fix ZIO 1.x sidebars (#6863)

* remove extra sidebar
rename how-to to guides

* rename howto to guides.

* issue #5878 - Backport ThreadLocalBridge (#5980)

* Rewritten based on the merged version of PR #5907

* call Supervisor.unsafeOnResume() even if `superviseOperations` is false (same as ZIO 2)

* chore(deps): update zio.version to v1.0.15 (#6899)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

* workaround.

* remove empty article.

* prepare for publish.

* fix mdoc errors.

* minor change.

* update zio-kafka ecosystem page.

* add 7 and 8 arg for check, checkM, checkAll and checkAllM (#6916)

* initial work.

* conclusion section.

* fix sidebar.

* fix site build problem.

* initial work.

* Fix frontmatters (#6949)

* Use master for version 1 build for now

* remove extra usecases sidebar.

* orrect navbar

* Switch back version 1 docs ref

* Remove docusaurus site build from sbt message

* Fix some broken links

* Fix checkSite build step

* Remove obsolete link

* Replace occurrences of ZTrace with Trace

* Make version 2 the default docs version
Rewire the getting started button

* Update package.json to compatible packages

* Fix time call

* Fix sidebar tirles

Co-authored-by: Milad Khajavi <khajavi@gmail.com>
Co-authored-by: Mate Borcsok <mate.borcsok@prezi.com>
Co-authored-by: Dmitry Karlinsky <dmitryka@wix.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: LUC DUZAN <strokyl@users.noreply.github.com>
Co-authored-by: Daniel Vigovszky <daniel.vigovszky@gmail.com>
adamgfraser pushed a commit that referenced this pull request Jul 1, 2022
* Add Prezi to adopters list (#6864)

* Fix ZIO 1.x sidebars (#6863)

* remove extra sidebar
rename how-to to guides

* rename howto to guides.

* issue #5878 - Backport ThreadLocalBridge (#5980)

* Rewritten based on the merged version of PR #5907

* call Supervisor.unsafeOnResume() even if `superviseOperations` is false (same as ZIO 2)

* chore(deps): update zio.version to v1.0.15 (#6899)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

* add 7 and 8 arg for check, checkM, checkAll and checkAllM (#6916)

* Fix frontmatters (#6949)

* Update cause.md (#6988)

Fixed wrong indentation level for examples

* Scala Native on Scala 3 (#6310)

* Scala Native on Scala 3

* Update BuildHelper.scala

* Use scala-java-time for both JS and Native, compatible with Scala 3

* drop dottySettings, use the same settings for all versions

* Scala JS 1.10.0

* izumi-reflect 2.1.1-SNAPSHOT

* Add scalajs-java-securerandom

* don't change ci.yml

* Update scalacheck to support Scala 3 Native

* Update libraries

* Work around issues in Scala 3 Native when overriding members without ()

* Work around issues in Scala 3 Native when overriding members without ()

* izumi-reflect 2.1.1

* Update plugins.sbt (#6996)

* Compile tests on Scala Native (#6283)

* Scala Native 0.4.3

* Minimize changes

* Use scala-java-time instead of sjavatime for Scala Native

* Run tests on Scala Native, not just compile

* Update plugins.sbt

* native-loop-core 0.2.1

* Update ci.yml

* format

* fix Scala 2.11

* fix Scala 2.11

* fix Scala 2.11

* More memory for non-JVM processes

* Just build tests, don't run them

* Add nativeSettings to streamsTests and testTests

* fix 2.11 Native

* fix 2.11 Native

* -Xmx4G

* izumi-reflect 2.1.3

* fix Scala 3

Co-authored-by: Mate Borcsok <mate.borcsok@prezi.com>
Co-authored-by: Milad Khajavi <khajavi@gmail.com>
Co-authored-by: Dmitry Karlinsky <dmitryka@wix.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: LUC DUZAN <strokyl@users.noreply.github.com>
Co-authored-by: Daniel Vigovszky <daniel.vigovszky@gmail.com>
Co-authored-by: felix-hedenstrom <39419603+felix-hedenstrom@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants