harp.config.builders.system¶
- class System[source]¶
Bases:
object
The core, global-like system objects, encapsulated together. Useful to manipulate the system from a high-level perspective, either from a server adapter point of view or from tests.
Bootstrapping will create a System instance, which will be used to start the various subsystems. Then, the subsystems will work on their own, and should not need to have a system view.
- Attributes:
config (GlobalSettings): The global configuration settings for the application. dispatcher (IAsyncEventDispatcher): The event dispatcher for handling application-wide events. provider (Services): The service provider for dependency injection and service management. kernel (ASGIKernel): The ASGI kernel for handling HTTP requests. binds (list[Bind]): A list of network binds specifying where the application should listen for incoming requests.
- Methods:
dispose(): Asynchronously disposes of the system resources, primarily the ASGI kernel.
- __init__(config, dispatcher, provider, /, *, asgi_app, binds)[source]¶
- Parameters:
config (GlobalSettings)
dispatcher (IAsyncEventDispatcher)
provider (Services)
asgi_app (Type[ASGI2Protocol] | Callable[[HTTPScope | WebSocketScope | LifespanScope, Callable[[], Awaitable[HTTPRequestEvent | HTTPDisconnectEvent | WebSocketConnectEvent | WebSocketReceiveEvent | WebSocketDisconnectEvent | LifespanStartupEvent | LifespanShutdownEvent]], Callable[[HTTPResponseStartEvent | HTTPResponseBodyEvent | HTTPResponseTrailersEvent | HTTPServerPushEvent | HTTPDisconnectEvent | WebSocketAcceptEvent | WebSocketSendEvent | WebSocketResponseStartEvent | WebSocketResponseBodyEvent | WebSocketCloseEvent | LifespanStartupCompleteEvent | LifespanStartupFailedEvent | LifespanShutdownCompleteEvent | LifespanShutdownFailedEvent], Awaitable[None]]], Awaitable[None]])
- async dispose()[source]¶
Asynchronously disposes of the system resources, primarily the ASGI kernel.
- property asgi_app: Type[ASGI2Protocol] | Callable[[HTTPScope | WebSocketScope | LifespanScope, Callable[[], Awaitable[HTTPRequestEvent | HTTPDisconnectEvent | WebSocketConnectEvent | WebSocketReceiveEvent | WebSocketDisconnectEvent | LifespanStartupEvent | LifespanShutdownEvent]], Callable[[HTTPResponseStartEvent | HTTPResponseBodyEvent | HTTPResponseTrailersEvent | HTTPServerPushEvent | HTTPDisconnectEvent | WebSocketAcceptEvent | WebSocketSendEvent | WebSocketResponseStartEvent | WebSocketResponseBodyEvent | WebSocketCloseEvent | LifespanStartupCompleteEvent | LifespanStartupFailedEvent | LifespanShutdownCompleteEvent | LifespanShutdownFailedEvent], Awaitable[None]]], Awaitable[None]]¶
- property config: GlobalSettings¶
- property dispatcher: IAsyncEventDispatcher¶
- class SystemBuilder[source]¶
Bases:
object
A builder class for constructing the System instance, which represents the core of the HARP application.
This class is responsible for assembling the necessary components of the System, including the global configuration, event dispatcher, service provider, and ASGI kernel, based on the provided configuration.
- Attributes:
AsyncEventDispatcherType (Type[IAsyncEventDispatcher]): The type of the event dispatcher to use. ContainerType (Type[Container]): The type of the container to use for dependency injection. KernelType (Type[ASGIKernel]): The type of the ASGI kernel to use for handling HTTP requests. configuration_builder (ConfigurationBuilder): The configuration builder used to assemble the global configuration. hostname (str): The hostname where the application should listen for incoming requests.
- Methods:
abuild() -> System: Asynchronously builds and returns an instance of the System class.
- AsyncEventDispatcherType¶
alias of
LoggingAsyncEventDispatcher
- KernelType¶
alias of
ASGIKernel
- __init__(applications=typing.Union[harp.config.applications.ApplicationsRegistry, typing.Callable[[], harp.config.applications.ApplicationsRegistry]], configuration=typing.Union[harp.typing.global_settings.GlobalSettings, typing.Callable[[], harp.typing.global_settings.GlobalSettings]], /, *, hostname='[::]')[source]¶
- Parameters:
hostname (str)
- async abuild()[source]¶
Asynchronously builds and returns an instance of the System class, ready for use.
- Returns:
System: An instance of the System class, assembled based on the provided configuration and components.
- Return type:
- async dispatch_bind_event(dispatcher, container, config)[source]¶
- Parameters:
dispatcher (IAsyncEventDispatcher)
container (Container)
- Return type:
- async dispatch_bound_event(dispatcher, provider, resolver)[source]¶
- Parameters:
dispatcher (IAsyncEventDispatcher)
provider (Services)
resolver (ProxyControllerResolver)
- Return type:
- async dispatch_ready_event(dispatcher, provider, controller_resolver)[source]¶
- Parameters:
dispatcher (IAsyncEventDispatcher)
provider (Services)
controller_resolver (ProxyControllerResolver)
- property applications: ApplicationsRegistry¶
- property configuration: GlobalSettings¶