Packages

package lifecycle

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. lifecycle
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. class AsyncCloseable extends AsyncOrSyncCloseable
  2. trait AsyncOrSyncCloseable extends AutoCloseable
  3. trait CanAbortDueToShutdown[F[_]] extends AnyRef

    Type class for effect types that embed the UnlessShutdown effect.

    Type class for effect types that embed the UnlessShutdown effect. Allows to merge an explicit UnlessShutdown wrapping into the effect type itself.

  4. trait CanAbortDueToShutdown0 extends AnyRef
  5. abstract class CancellationException extends RuntimeException
  6. final case class CloseContext(flagCloseable: FlagCloseable) extends Product with Serializable

    Context to capture and pass through a caller's closing state.

    Context to capture and pass through a caller's closing state.

    This allows us for example to stop operations down the call graph if either the caller or the current component executing an operation is closed.

  7. class ClosedCancellationException extends CancellationException

    An operation has been cancelled due to shutdown/closing of a component.

  8. class DefaultPromiseUnlessShutdownFactory extends NamedLogging with FlagCloseable with HasCloseContext
  9. trait FlagCloseable extends AutoCloseable with PerformUnlessClosing

    Adds the java.lang.AutoCloseable.close method to the interface of PerformUnlessClosing.

    Adds the java.lang.AutoCloseable.close method to the interface of PerformUnlessClosing. The component's custom shutdown behaviour should override the onClosed method.

  10. trait FlagCloseableAsync extends FlagCloseable

    AutoCloseableAsync eases the proper closing of futures.

  11. type FutureUnlessShutdown[+A] = lifecycle.FutureUnlessShutdownImpl.FutureUnlessShutdown[A]

    The monad combination of scala.concurrent.Future with UnlessShutdown as an abstract type

    The monad combination of scala.concurrent.Future with UnlessShutdown as an abstract type

    See also

    FutureUnlessShutdownSig.Ops for extension methods on the abstract type

  12. sealed abstract class FutureUnlessShutdownImpl extends AnyRef

    Monad combination of Future and UnlessShutdown

    Monad combination of Future and UnlessShutdown

    We avoid wrapping and unwrapping it by emulating Scala 3's opaque types. This makes the asynchronous detection magic work out of the box for FutureUnlessShutdown because FutureUnlessShutdown(x).isInstanceOf[Future] holds at runtime.

  13. trait HasCloseContext extends PromiseUnlessShutdownFactory

    Mix-in to obtain a CloseContext implicit based on the class's FlagCloseable

  14. sealed trait HasLifeCycleScope extends Any

    Parent trait for anything that needs to deal with LifeCycleScopes.

  15. trait HasRunOnClosing extends HasUnlessClosing
  16. trait HasSynchronizeWithClosing extends HasRunOnClosing
  17. trait HasSynchronizeWithReaders extends HasRunOnClosing

    Mix-in for keeping track of a set of the readers.

    Mix-in for keeping track of a set of the readers. Used for implementing the HasSynchronizeWithClosing logic: Each computation acquires one permit before it starts and released it when done. HasSynchronizeWithReaders.synchronizeWithReaders attempts to acquire all permits and logs progress if slow.

  18. trait HasUnlessClosing extends AnyRef
  19. sealed trait LifeCycleManager extends HasSynchronizeWithClosing

    Ensures orderly shutdown for a set of LifeCycleManager.ManagedResources and dependent LifeCycleManagers.

    Ensures orderly shutdown for a set of LifeCycleManager.ManagedResources and dependent LifeCycleManagers. This creates a shutdown hierarchy.

    When a LifeCycleManager is closed with LifeCycleManager.closeAsync, the following shutdown procedure is applied:

    1. Close signal propagation: The LifeCycleManager and all its dependent LifeCycleManagers are notified that closing is in progress. Thereafter, their HasRunOnClosing.isClosing returns true. Transitive dependents are also notified, but this need not be synchronized with the next step.
    2. Run on closing: The RunOnClosing tasks registered with the LifeCycleManager. Exceptions from the RunOnClosing tasks are logged and then discarded. The dependent LifeCycleManagers also start running their RunOnClosing tasks.
    3. Synchronize with closing: The LifeCycleManager waits until all its HasSynchronizeWithClosing.synchronizeWithClosing computations have finished or until LifeCycleManager.synchronizeWithClosingPatience has elapsed.
    4. Release: The LifeCycleManager releases all its LifeCycleManager.ManagedResources and instructs dependent LifeCycleManagers to do so in ascending priority order. Within the same priority, releasing is unordered and possibly in parallel. When a dependent LifeCycleManager is instructed, it waits until step 2 has finished and then performs steps 3 and 4 of this procedure.

    Exceptions thrown in the last step "release" are propagated as a ShutdownFailedException with proper exception chaining. If the third step completes because the patience has elapsed and some HasSynchronizeWithClosing.synchronizeWithClosing computations are still running at the end of the last step, a ShutdownFailedException signals such a synchronization failure.

    Rationale for this exception handling policy:

    • When an exception happens in the last step, it is unknown whether all dependencies have successfully finished all their business. So we must signal to the caller that the unexpected happened.
    • When some HasSynchronizeWithClosing.synchronizeWithClosing is still running after everything has been released, we cannot guarantee that all side effects guarded by this shutdown hierarchy are over. We signal this to the caller via an exception.
    • In contrast, RunOnClosing tasks are meant to quickly clean up stuff upon closing. They are not synchronized with closing, and therefore we merely log exceptions, but do not propagate them.
  20. trait LifeCycleRegistrationHandle extends AnyRef
  21. sealed trait LifeCycleScope[Discriminator] extends AnyRef

    Tracks the LifeCycleManagers that have been accumulated as part of processing the current call.

    Tracks the LifeCycleManagers that have been accumulated as part of processing the current call. This trait is typically used only in the forms of HasLifeCycleScope.ContextLifeCycleScope and HasLifeCycleScope.OwnLifeCycleScope.

    Unlike LifeCycleScopeImpl, this trait does not expose any synchronization methods. This ensures that client code cannot accidentally call them on HasLifeCycleScope.ContextLifeCycleScopes, which could miss out on the manager of a ManagedLifeCycle object.

    Discriminator

    Phantom type parameter to tie a life cycle scope to individual HasLifeCycleScope instances, and to distinguish within such an individual HasLifeCycleScope between HasLifeCycleScope.ContextLifeCycleScope and HasLifeCycleScope.OwnLifeCycleScope.

    Annotations
    @implicitNotFound()
  22. trait ManagedLifeCycle extends HasLifeCycleScope

    Trait for all objects that are managed by a LifeCycleManager.

    Trait for all objects that are managed by a LifeCycleManager. HasLifeCycleScope.OwnLifeCycleScopes always include this manager.

  23. trait OnShutdownRunner extends HasRunOnClosing
  24. trait PerformUnlessClosing extends OnShutdownRunner with HasSynchronizeWithReaders

    Provides a way to synchronize closing with other running tasks in the class, such that new tasks aren't scheduled while closing, and such that closing waits for the scheduled tasks.

    Provides a way to synchronize closing with other running tasks in the class, such that new tasks aren't scheduled while closing, and such that closing waits for the scheduled tasks.

    Use this type to pass such synchronization objects to other objects that merely need to synchronize, but should not be able to initiate closing themselves. To that end, this trait does not expose the java.lang.AutoCloseable.close method.

    See also

    FlagCloseable does expose the java.lang.AutoCloseable.close method.

  25. type PromiseUnlessShutdown[A] = lifecycle.PromiseUnlessShutdownImpl.PromiseUnlessShutdown[A]

    A wrapper for scala.concurrent.Promise with UnlessShutdown with convenience methods that hide the UnlessShutdown type parameter.

    A wrapper for scala.concurrent.Promise with UnlessShutdown with convenience methods that hide the UnlessShutdown type parameter.

    Analogous to FutureUnlessShutdown.

  26. trait PromiseUnlessShutdownFactory extends AnyRef
  27. sealed abstract class PromiseUnlessShutdownImpl extends AnyRef

    Combines a scala.concurrent.Promise with UnlessShutdown.

    Combines a scala.concurrent.Promise with UnlessShutdown.

    We avoid wrapping and unwrapping it by emulating Scala 3's opaque types.

  28. trait RunOnClosing extends LifeCycleManagerTask

    Trait that can be registered with a LifeCycleManager or OnShutdownRunner to run on closing / shutdown.

  29. class ShutdownFailedException extends RuntimeException
  30. class SyncCloseable extends AsyncOrSyncCloseable
  31. sealed trait UnlessShutdown[+A] extends Product with Serializable

    The outcome of a computation (UnlessShutdown.Outcome) unless the computation has aborted due to a shutdown (UnlessShutdown.AbortedDueToShutdown).

    The outcome of a computation (UnlessShutdown.Outcome) unless the computation has aborted due to a shutdown (UnlessShutdown.AbortedDueToShutdown).

    A copy of scala.Option. We use a separate class to document the purpose.

    A

    The type of the outcome.

  32. trait UnmanagedLifeCycle extends HasLifeCycleScope

    Trait for all objects that are not managed by a LifeCycleManager, but that still deal with LifeCycleScopes.

    Trait for all objects that are not managed by a LifeCycleManager, but that still deal with LifeCycleScopes. OwnLifeCycleScope and ContextLifeCycleScopes are the same w.r.t. LifeCycleManagers.

Value Members

  1. object AsyncCloseable
  2. object CanAbortDueToShutdown extends CanAbortDueToShutdown0
  3. object CloseContext extends Serializable
  4. object ClosingException

    Helper to pattern match for exceptions that may happen during shutdown/closing.

  5. object FlagCloseable
  6. object FutureUnlessShutdown
  7. object FutureUnlessShutdownImpl
  8. object HasLifeCycleScope
  9. object HasSynchronizeWithReaders
  10. object LifeCycle extends NoTracing

    Utilities for working with instances that support our life cycle pattern.

  11. object LifeCycleManager
  12. object OnShutdownRunner
  13. object PromiseUnlessShutdown
  14. object PromiseUnlessShutdownImpl
  15. object SyncCloseable
  16. object UnlessShutdown extends Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped