Skip to content

Support user-defined custom scopes #175

@lesnik512

Description

@lesnik512

Problem

The Scope enum is fixed with 5 levels: APP=1, SESSION=2, REQUEST=3, ACTION=4, STEP=5. Applications with non-standard lifecycle requirements (background-job scope, tenant scope, etc.) cannot express their needs.

Proposed Solution

Allow extending Scope with custom values while preserving ordering. Users could subclass Scope and add values:

class MyScope(Scope):
    TENANT = 6
    BACKGROUND_JOB = 7

As long as integer ordering is preserved, the existing scope hierarchy logic should work.

Impact

Flexibility for non-standard lifecycle requirements.

Complexity

Low — IntEnum supports extension; main work is ensuring build_child_container and find_container handle custom values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions