Skip to content

Static evaluation of activators #642

@Tishka17

Description

@Tishka17

Based on #9

Though it is not set explicitly, each activation function can be static or dynamic

  • Static activator is called only once when graph is built. All inactive providers are stripped from graph
  • Dynamic activator is called each time we need to decide which provider should be used.

If a dependency has multiple dynamically activated providers they are moved to a temporary component, while new factory is generated.
This factory will call all activators consequently and once it gets True - requests dependency from corresponding factory.

Rules to detect is it dynamic or not:

  • async functions are always dynamic
  • sync function with no arguments is static
  • sync function which requests objects available in Root context is static
  • sync function which requests Object which is not registered in graph is static
  • sync function dependent on result of other static activators is static
  • all other functions are dynamic

Currently, only dynamic calculation is implemented.
Note, that Has() can be evaluated statically only in some cases, though the implementation is generic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions