harp.config.applications

Inheritance diagram of harp.config.applications

class Application[source]

Bases: object

__init__(*, on_bind=None, on_bound=None, on_ready=None, on_shutdown=None, settings_type=None, dependencies=None)[source]
Parameters:
defaults()[source]
has_application_settings_mixin()[source]

Check if settings_type has ApplicationSettingsMixin in its inheritance chain.

normalize(settings)[source]
on_bind: Callable[[OnBindEvent], Awaitable[None]] = None

Placeholder for factory bind event, happening before the container is built. If set, it will be attached to the factory dispatcher automatically.

on_bound: Callable[[OnBoundEvent], Awaitable[None]] = None

Placeholder for factory bound event, happening after the container is built. If set, it will be attached to the factory dispatcher automatically.

on_ready: Callable[[OnReadyEvent], Awaitable[None]] = None

Placeholder for factory build event, happening after the kernel is built. If set, it will be attached to the factory dispatcher automatically.

on_shutdown: Callable[[OnShutdownEvent], Awaitable[None]] = None

Placeholder for factory dispose event, happening after the kernel is disposed. If set, it will be attached to the factory dispatcher automatically, in reverse order of appearance (first loaded application will be disposed last).

path: str | None = None

A placeholder for the source path of the application.

settings_type: Type = None

Type definition for configuration parsing.

class ApplicationsRegistry[source]

Bases: object

__init__(*, namespaces=None)[source]
Parameters:

namespaces (list[str] | None)

add(*names, autoload_dependencies=False)[source]

Add applications to the registry.

Args:

*names: Application names to add autoload_dependencies: If True, automatically add declared dependencies.

Defaults to False for backward compatibility.

Parameters:

autoload_dependencies (bool)

aslist()[source]
defaults()[source]
get_application(name)[source]

Returns the application class for the given application name.

todo: add name/full_name attributes with raise if already set to different value ?

Parameters:

name (str)

Returns:

Return type:

Application

items()[source]
Return type:

ItemsView[str, Application]

keys()[source]
Return type:

KeysView[str]

register_events(dispatcher)[source]
Parameters:

dispatcher (IAsyncEventDispatcher)

register_services(container, config)[source]
Parameters:
remove(*names)[source]
resolve_dependencies()[source]

Reorder applications based on dependency order using topological sort.

resolve_name(spec)[source]
resolve_short_name(full_name)[source]
validate_dependencies()[source]

Validate that all declared dependencies exist in the registry.

values()[source]
Return type:

ValuesView[Application]

namespaces = ['harp_apps']
applications = {}

Cache for applications