p

izumi.distage

planning

package planning

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Package Members

  1. package extensions
  2. package gc

Type Members

  1. class AssignableFromAutoSetHook[INSTANCE, BINDING] extends PlanningHook

    A hook that will collect all implementations with types that are

    A hook that will collect all implementations with types that are

    _ <: T

    into a Set[T] set binding available for summoning

    Usage:

    val collectCloseables = new AssignableFromAutoSetHook[AutoCloseable, AutoCloseable](identity)
    
    val injector = Injector(new BootstrapModuleDef {
      many[PlanningHook]
        .add(collectCloseables)
    })

    Then, in any class created from injector:

    class App(allCloseables: Set[AutoCloseable]) {
      ...
    }

    These Auto-Sets can be used to implement custom lifetimes:

    val locator = injector.produce(modules)
    
    val closeables = locator.get[Set[AutoCloseable]]
    try { locator.get[App].runMain() } finally {
      // reverse closeables list, Auto-Sets preserve order, in the order of *initialization*
      // Therefore resources should closed in the *opposite order*
      // e.g. if C depends on B depends on A, create: A -> B -> C, close: C -> B -> A
      closeables.reverse.foreach(_.close())
    }

    Auto-Sets are NOT subject to Garbage Collection, they are assembled *after* garbage collection is done, as such they can't contain garbage by construction.

    _ <: T }}} available for summoning

    Usage:

    val collectCloseables = new AssignableFromAutoSetHook[AutoCloseable, AutoCloseable](identity)
    
    val injector = Injector(new BootstrapModuleDef {
      many[PlanningHook]
        .add(collectCloseables)
    })

    Then, in any class created from injector:

    class App(allCloseables: Set[AutoCloseable]) {
      ...
    }

    These Auto-Sets can be used to implement custom lifetimes:

    val locator = injector.produce(modules)
    
    val closeables = locator.get[Set[AutoCloseable]]
    try { locator.get[App].runMain() } finally {
      // reverse closeables list, Auto-Sets preserve order, in the order of *initialization*
      // Therefore resources should closed in the *opposite order*
      // e.g. if C depends on B depends on A, create: A -> B -> C, close: C -> B -> A
      closeables.reverse.foreach(_.close())
    }

    Auto-Sets are NOT subject to Garbage Collection, they are assembled *after* garbage collection is done, as such they can't contain garbage by construction.

  2. abstract class AutoSetModule extends BootstrapModuleDef

    Auto-Sets collect all bindings with static types <: T into a summonable Set[T]

    Auto-Sets collect all bindings with static types <: T into a summonable Set[T]

    See also

    same concept in MacWire: https://github.com/softwaremill/macwire#multi-wiring-wireset

  3. trait BindingTranslator extends AnyRef
  4. class BindingTranslatorImpl extends BindingTranslator
  5. class ForwardingRefResolverDefaultImpl extends ForwardingRefResolver
  6. class PlanAnalyzerDefaultImpl extends PlanAnalyzer
  7. class PlanMergingPolicyDefaultImpl extends PlanMergingPolicy with WithResolve
  8. final class PlannerDefaultImpl extends Planner
  9. final class PlanningHookAggregate extends PlanningHook
  10. final class PlanningObserverAggregate extends PlanningObserver
  11. class SanityCheckerDefaultImpl extends SanityChecker

Value Members

  1. object AutoSetModule

Ungrouped