Virtual container¶
VirtualContainer
¶
Bases: DynamicContainer, Loggable
Data exchange and dependency injection layer.
VirtualContainer is a [DynamicContainer][dependency_injector.containers.DynamicContainer]
that also acts as a runtime signal bus and data sharing layer for an application.
Source code in src/redsun/virtual/_container.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
schema_version
property
¶
The plugin schema version specified in the configuration.
metadata
property
¶
The session metadata specified in the configuration.
callbacks
property
¶
The currently registered document callbacks.
register_signals
¶
register_signals(
owner: HasName,
name: str | None = None,
only: Iterable[str] | None = None,
) -> None
Register the signals of an object in the virtual container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
HasName
|
The instance whose class's signals are to be cached.
Must provide a |
required |
name
|
str | None
|
An optional name to use as the key for caching the signals.
If not provided, the |
None
|
only
|
Iterable[str]
|
A list of signal names to cache. If not provided, all signals in the class will be cached automatically by inspecting the class attributes. |
None
|
Notes
This method inspects the attributes of the owner's class to find
psygnal.Signal descriptors. For each such descriptor, it
retrieves the psygnal.SignalInstance from the owner using
the descriptor protocol and stores it in the registry.
Source code in src/redsun/virtual/_container.py
register_callbacks
¶
register_callbacks(
owner: HasName,
name: str | None = None,
callback_map: dict[str, CallbackType] | None = None,
) -> None
Register one or more document callbacks in the virtual container.
Accepts any object that is a valid CallbackType and exposes a
name attribute used as the registry key. Two forms are supported:
- A [DocumentRouter][event_model.DocumentRouter] subclass instance;
- Any other object that implements
__call__(self, name, doc)with the correct two-parameter signature.
When callback_map is provided the owner itself is not registered; instead each entry in the mapping is validated and registered independently under its own key, allowing a single owner to expose multiple callbacks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
HasName
|
The component registering callbacks. Must expose a |
required |
name
|
str | None
|
Override for the registry key used when registering owner
directly. Ignored when callback_map is provided.
Defaults to |
None
|
callback_map
|
dict[str, CallbackType] | None
|
Optional mapping of registry key to callback object. When supplied, each value is validated and registered under its corresponding key; name is ignored. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a callback is not callable or its signature is incompatible
with |
Source code in src/redsun/virtual/_container.py
RedSunConfig
¶
Bases: TypedDict
Base configuration schema for Redsun applications.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema_version
|
Required[float]
|
Plugin schema version. |
required |
frontend
|
Required[str]
|
Frontend toolkit identifier (e.g. |
required |
session
|
NotRequired[str]
|
Session display name. If not provided, default is |
required |
metadata
|
NotRequired[dict[str, Any]]
|
Additional session-specific metadata to include in the configuration. |
required |
Source code in src/redsun/virtual/_config.py
HasShutdown
¶
Bases: Protocol
Protocol marking your class as capable of shutting down.