package lifecycle
- Alphabetic
- By Inheritance
- lifecycle
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- class AsyncCloseable extends AsyncOrSyncCloseable
- trait AsyncOrSyncCloseable extends AutoCloseable
- 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.
- trait CanAbortDueToShutdown0 extends AnyRef
- abstract class CancellationException extends RuntimeException
- 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.
- class ClosedCancellationException extends CancellationException
An operation has been cancelled due to shutdown/closing of a component.
- class DefaultPromiseUnlessShutdownFactory extends NamedLogging with FlagCloseable with HasCloseContext
- 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. - trait FlagCloseableAsync extends FlagCloseable
AutoCloseableAsync eases the proper closing of futures.
- 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
- sealed abstract class FutureUnlessShutdownImpl extends AnyRef
Monad combination of
Future
and UnlessShutdownMonad combination of
Future
and UnlessShutdownWe 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. - trait HasCloseContext extends PromiseUnlessShutdownFactory
Mix-in to obtain a CloseContext implicit based on the class's FlagCloseable
- sealed trait HasLifeCycleScope extends Any
Parent trait for anything that needs to deal with LifeCycleScopes.
- trait HasRunOnClosing extends HasUnlessClosing
- trait HasSynchronizeWithClosing extends HasRunOnClosing
- 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.
- trait HasUnlessClosing extends AnyRef
- 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:
- 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.
- 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.
- Synchronize with closing: The LifeCycleManager waits until all its HasSynchronizeWithClosing.synchronizeWithClosing computations have finished or until LifeCycleManager.synchronizeWithClosingPatience has elapsed.
- 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.
- trait LifeCycleRegistrationHandle extends AnyRef
- 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()
- 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.
- trait OnShutdownRunner extends HasRunOnClosing
- 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.
- 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.
- trait PromiseUnlessShutdownFactory extends AnyRef
- 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.
- trait RunOnClosing extends LifeCycleManagerTask
Trait that can be registered with a LifeCycleManager or OnShutdownRunner to run on closing / shutdown.
- class ShutdownFailedException extends RuntimeException
- class SyncCloseable extends AsyncOrSyncCloseable
- 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.
- 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
- object AsyncCloseable
- object CanAbortDueToShutdown extends CanAbortDueToShutdown0
- object CloseContext extends Serializable
- object ClosingException
Helper to pattern match for exceptions that may happen during shutdown/closing.
- object FlagCloseable
- object FutureUnlessShutdown
- object FutureUnlessShutdownImpl
- object HasLifeCycleScope
- object HasSynchronizeWithReaders
- object LifeCycle extends NoTracing
Utilities for working with instances that support our life cycle pattern.
- object LifeCycleManager
- object OnShutdownRunner
- object PromiseUnlessShutdown
- object PromiseUnlessShutdownImpl
- object SyncCloseable
- object UnlessShutdown extends Serializable