config¶
Configuration management module for Bridgic.
GlobalSetting ¶
Bases: BaseModel
Global configuration settings for the Bridgic framework.
This class implements a singleton pattern to provide centralized configuration that applies across all Automa instances. The main methods are:
GlobalSetting.read(): Get the singleton global setting instance.GlobalSetting.set(): Set the specific fields of the global setting instance.
Attributes:
| Name | Type | Description |
|---|---|---|
callback_builders | List[WorkerCallbackBuilder] | Callback builders that will be automatically applied to all workers across all Automa instances. |
Source code in bridgic/core/config/_global_setting.py
callback_builders class-attribute instance-attribute ¶
callback_builders: List[WorkerCallbackBuilder] = []
Global callback builders that will be applied to all workers.
read ¶
classmethod read() -> GlobalSetting
Get the singleton global setting instance.
Returns:
| Type | Description |
|---|---|
GlobalSetting | The singleton global setting instance. |
Source code in bridgic/core/config/_global_setting.py
set ¶
classmethod set(
callback_builders: Optional[
List[WorkerCallbackBuilder]
] = None,
) -> None
Set global setting fields.
This method allows you to update specific fields of the global setting without needing to create a complete GlobalSetting object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback_builders | Optional[List[WorkerCallbackBuilder]] | Global callback builders that will be applied to all workers. If None, the current callback_builders are not changed. | None |
Source code in bridgic/core/config/_global_setting.py
add ¶
classmethod add(
callback_builder: Optional[
WorkerCallbackBuilder
] = None,
) -> None
Add new element to the existing field(s) of the GlobalSetting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback_builder | Optional[WorkerCallbackBuilder] | The callback builder to add to the global setting callback builders. If None is passed in, nothing will be done. | None |
Source code in bridgic/core/config/_global_setting.py
HttpClientConfig ¶
Bases: TypedDict
Serializable configuration for creating an HTTP client.
This configuration can be serialized and deserialized, allowing the framework to recreate HTTP clients after serialization.
Attributes:
| Name | Type | Description |
|---|---|---|
headers | Optional[Dict[str, str]] | HTTP headers to include with all requests. |
timeout | Optional[HttpClientTimeoutConfig] | Timeout configuration for the HTTP client. |
auth | Optional[HttpClientAuthConfig] | Authentication configuration for the HTTP client. |
Source code in bridgic/core/config/_http_client_config.py
HttpClientTimeoutConfig ¶
Bases: TypedDict
Configuration for HTTP client timeout settings.
Attributes:
| Name | Type | Description |
|---|---|---|
connect | Optional[float] | Timeout for establishing a connection (seconds). |
read | Optional[float] | Timeout for reading data (seconds). |
write | Optional[float] | Timeout for writing data (seconds). |
pool | Optional[float] | Timeout for acquiring a connection from the pool (seconds). |
Source code in bridgic/core/config/_http_client_config.py
HttpClientAuthConfig ¶
Bases: TypedDict
Configuration for HTTP client authentication.
Attributes:
| Name | Type | Description |
|---|---|---|
type | Literal['basic', 'bearer'] | The type of authentication. |
username | Optional[str] | Username for basic auth (required if type is "basic"). |
password | Optional[str] | Password for basic auth (required if type is "basic"). |
token | Optional[str] | Bearer token (required if type is "bearer"). |
Source code in bridgic/core/config/_http_client_config.py
create_http_client_from_config ¶
create_http_client_from_config(
config: Optional[HttpClientConfig],
is_async: bool = True,
) -> Optional[Union[AsyncClient, Client]]
Create an HTTP client (sync or async) from a serializable configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Optional[HttpClientConfig] | The HTTP client configuration. If None, returns None. | required |
is_async | bool | If True, creates an | True |
Returns:
| Type | Description |
|---|---|
Optional[Union[AsyncClient, Client]] | The created HTTP client, or None if config is None. |
Raises:
| Type | Description |
|---|---|
ValueError | If the auth configuration is invalid (missing required fields or unsupported type). |
Examples:
Create async client with custom headers:
Create async client with custom timeout:
Source code in bridgic/core/config/_http_client_config.py
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 | |