processcube-etw-library 2026.1.22.73503b0__py3-none-any.whl → 2026.1.22.120215b0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ from .health import (
11
11
  LivezResponse,
12
12
  )
13
13
  from .etw_app import new_external_task_worker_app
14
- from .settings import get_settings, init_settings
14
+ from .settings import load_settings, load_settings
15
15
 
16
16
  __all__ = [
17
17
  "create_url_health_check",
@@ -21,6 +21,5 @@ __all__ = [
21
21
  "HealthConditionInfo",
22
22
  "LivezResponse",
23
23
  "new_external_task_worker_app",
24
- "get_settings",
25
- "init_settings",
24
+ "load_settings",
26
25
  ]
@@ -5,11 +5,11 @@
5
5
  from processcube_client.external_task import ExternalTaskClient
6
6
 
7
7
  from .identity_provider import IdentityProvider
8
- from .settings import get_settings
8
+ from .settings import load_settings
9
9
 
10
10
 
11
11
  def create_external_task_client() -> ExternalTaskClient:
12
- settings = get_settings()
12
+ settings = load_settings()
13
13
  authority_url = settings.processcube_authority_url
14
14
  engine_url = settings.processcube_engine_url
15
15
  client_name = settings.processcube_etw_client_id
@@ -15,7 +15,6 @@ from .health import (
15
15
  from .create_external_task_client import create_external_task_client
16
16
  from .server_config import get_server_config
17
17
  from .typed_handler import create_typed_handler_wrapper
18
- from .settings import get_settings
19
18
  from processcube_client.external_task import ExternalTaskClient
20
19
 
21
20
 
@@ -92,8 +91,6 @@ class ExternalTaskWorkerApp:
92
91
  def new_external_task_worker_app(
93
92
  built_in_health_checks: bool = True,
94
93
  ) -> ExternalTaskWorkerApp:
95
- settings = get_settings()
96
-
97
94
  external_task_client = create_external_task_client()
98
95
 
99
96
  return ExternalTaskWorkerApp(
@@ -1,10 +1,10 @@
1
- from ..settings import get_settings
1
+ from ..settings import load_settings
2
2
  from .check import HealthCheck, create_url_health_check
3
3
  from .registry import HealthCheckRegistry
4
4
 
5
5
 
6
6
  def add_built_in_health_checks(registry: HealthCheckRegistry) -> None:
7
- settings = get_settings()
7
+ settings = load_settings()
8
8
 
9
9
  engine_url = (
10
10
  settings.processcube_engine_url.strip("/")
@@ -1,6 +1,6 @@
1
1
  from typing import TypedDict
2
2
 
3
- from .settings import get_settings
3
+ from .settings import load_settings
4
4
 
5
5
 
6
6
  class ServerConfig(TypedDict, total=False):
@@ -12,7 +12,7 @@ class ServerConfig(TypedDict, total=False):
12
12
 
13
13
 
14
14
  def get_server_config() -> ServerConfig:
15
- settings = get_settings()
15
+ settings = load_settings()
16
16
 
17
17
  if settings.environment == "production":
18
18
  return ServerConfig(
@@ -44,8 +44,8 @@ class ETWSettings(BaseSettings):
44
44
  class MySettings(ETWSettings):
45
45
  my_custom_var: str = Field(default="default_value")
46
46
 
47
- # Initialize with custom settings class
48
- init_settings(MySettings)
47
+ # Load with custom settings class
48
+ settings = load_settings(MySettings)
49
49
  """
50
50
 
51
51
  model_config = SettingsConfigDict(
@@ -89,29 +89,18 @@ class ETWSettings(BaseSettings):
89
89
  _settings: Optional[ETWSettings] = None
90
90
 
91
91
 
92
- def init_settings(settings_class: Type[T] = ETWSettings) -> T:
93
- """
94
- Initialize the global settings instance.
95
92
 
93
+ def load_settings(settings_class: Type[T] = ETWSettings) -> T:
94
+ """
96
95
  Call this with a custom settings class to extend the base settings:
97
96
 
98
97
  class MySettings(ETWSettings):
99
98
  my_var: str = Field(default="value")
100
99
 
101
- init_settings(MySettings)
100
+ settings = load_settings(MySettings)
102
101
  """
103
- global _settings
104
- _settings = settings_class()
105
- return _settings
106
-
107
102
 
108
- def get_settings() -> ETWSettings:
109
- """
110
- Get the global settings instance.
111
-
112
- If settings haven't been initialized, creates a default ETWSettings instance.
113
- """
114
103
  global _settings
115
104
  if _settings is None:
116
- _settings = ETWSettings()
117
- return _settings
105
+ _settings = settings_class()
106
+ return _settings # type: ignore
@@ -0,0 +1,197 @@
1
+ Metadata-Version: 2.4
2
+ Name: processcube-etw-library
3
+ Version: 2026.1.22.120215b0
4
+ Summary: A library to create ETW apps with the ProcessCube platform.
5
+ Author-email: Jeremy Hill <jeremy.hill@profection.de>
6
+ License: MIT
7
+ Requires-Python: >=3.12
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: fastapi[standard]>=0.128.0
10
+ Requires-Dist: oauth2-client>=1.4.2
11
+ Requires-Dist: processcube-client>=5.0.0
12
+ Requires-Dist: tenacity>=9.1.2
13
+
14
+ # ProcessCube ETW Library
15
+
16
+ Build External Task Workers (ETW) for ProcessCube, featuring health checks, typed handlers, and environment-based configuration.
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ uv add processcube-etw-library
22
+ ```
23
+
24
+ ## Configuration
25
+
26
+ ### Environment Variables
27
+
28
+ The library uses environment variables for configuration. You can set these in your environment or in a `.env` file in your project root.
29
+
30
+ | Variable | Default | Description |
31
+ | ------------------------------------ | -------------------------------------- | ------------------------------------------------ |
32
+ | `PROCESSCUBE_ENGINE_URL` | `http://localhost:56000` | URL of the ProcessCube Engine |
33
+ | `PROCESSCUBE_AUTHORITY_URL` | Auto-discovered from engine | URL of the ProcessCube Authority (OAuth server) |
34
+ | `PROCESSCUBE_ETW_CLIENT_ID` | `test_etw` | OAuth client ID for the External Task Worker |
35
+ | `PROCESSCUBE_ETW_CLIENT_SECRET` | `3ef62eb3-fe49-4c2c-ba6f-73e4d234321b` | OAuth client secret for the External Task Worker |
36
+ | `PROCESSCUBE_ETW_CLIENT_SCOPES` | `engine_etw` | OAuth scopes for the External Task Worker |
37
+ | `MAX_GET_OAUTH_ACCESS_TOKEN_RETRIES` | `10` | Maximum retries for obtaining OAuth access token |
38
+ | `ENVIRONMENT` | `development` | Environment mode (`development` or `production`) |
39
+
40
+ #### Example `.env` File
41
+
42
+ ```env
43
+ PROCESSCUBE_ENGINE_URL=http://localhost:56000
44
+ PROCESSCUBE_ETW_CLIENT_ID=my_etw_client
45
+ PROCESSCUBE_ETW_CLIENT_SECRET=my_secret_key
46
+ PROCESSCUBE_ETW_CLIENT_SCOPES=engine_etw
47
+ ENVIRONMENT=production
48
+ ```
49
+
50
+ ### Extending Settings
51
+
52
+ You can extend the base settings class to add your own environment variables:
53
+
54
+ ```python
55
+ from pydantic import Field
56
+ from processcube_etw_library.settings import ETWSettings, load_settings
57
+
58
+ class MyAppSettings(ETWSettings):
59
+ database_url: str = Field(default="sqlite:///app.db")
60
+ api_key: str = Field(default="")
61
+
62
+ # Load settings with your custom class
63
+ settings = load_settings(MyAppSettings)
64
+ ```
65
+
66
+ ## Usage
67
+
68
+ ### Start the ETW Application
69
+
70
+ ```python
71
+ from processcube_etw_library import new_external_task_worker_app
72
+
73
+ # Create the application
74
+ app = new_external_task_worker_app()
75
+
76
+ # Run the application
77
+ app.run()
78
+ ```
79
+
80
+ ### Subscribe to External Task Topics
81
+
82
+ ```python
83
+ from processcube_etw_library import new_external_task_worker_app
84
+
85
+ app = new_external_task_worker_app()
86
+
87
+ def my_handler(task):
88
+ # Process the task
89
+ result = {"processed": True}
90
+ return result
91
+
92
+ # Subscribe to a topic
93
+ app.subscribe_to_external_task_for_topic("my-topic", my_handler)
94
+
95
+ app.run()
96
+ ```
97
+
98
+ ### Typed Handlers
99
+
100
+ Use typed handlers for automatic payload validation with Pydantic models:
101
+
102
+ ```python
103
+ from pydantic import BaseModel
104
+ from processcube_etw_library import new_external_task_worker_app
105
+
106
+ class MyInput(BaseModel):
107
+ name: str
108
+ value: int
109
+
110
+ class MyOutput(BaseModel):
111
+ result: str
112
+
113
+ app = new_external_task_worker_app()
114
+
115
+ def my_typed_handler(payload: MyInput) -> MyOutput:
116
+ return MyOutput(result=f"Processed {payload.name} with value {payload.value}")
117
+
118
+ app.subscribe_to_external_task_for_topic_typed("my-typed-topic", my_typed_handler)
119
+
120
+ app.run()
121
+ ```
122
+
123
+ ### Add a Custom Health Check
124
+
125
+ ```python
126
+ from processcube_etw_library import new_external_task_worker_app
127
+ from processcube_etw_library.health import HealthCheck, create_url_health_check
128
+
129
+ app = new_external_task_worker_app()
130
+
131
+ # Add a URL-based health check
132
+ app.add_health_check(
133
+ HealthCheck(
134
+ create_url_health_check("http://my-service:8080/health"),
135
+ service_name="My Service",
136
+ tags=["backend", "api"],
137
+ comments=["Checks if My Service is reachable"],
138
+ )
139
+ )
140
+
141
+ # Add a custom health check function
142
+ def check_database():
143
+ # Return True if healthy, False otherwise
144
+ try:
145
+ # Your database check logic here
146
+ return True
147
+ except Exception:
148
+ return False
149
+
150
+ app.add_health_check(
151
+ HealthCheck(
152
+ check_database,
153
+ service_name="Database",
154
+ tags=["backend", "database"],
155
+ comments=["Checks database connectivity"],
156
+ )
157
+ )
158
+
159
+ app.run()
160
+ ```
161
+
162
+ ### Managing Health Checks
163
+
164
+ ```python
165
+ # Get all registered health checks
166
+ checks = app.get_health_checks()
167
+
168
+ # Get a specific health check by service name
169
+ db_check = app.get_health_check("Database")
170
+
171
+ # Remove a health check
172
+ app.remove_health_check("Database")
173
+ ```
174
+
175
+ ### Disabling Built-in Health Checks
176
+
177
+ By default, the library registers health checks for the ProcessCube Engine and Authority. You can disable these:
178
+
179
+ ```python
180
+ app = new_external_task_worker_app(built_in_health_checks=False)
181
+ ```
182
+
183
+ ## Health Endpoints
184
+
185
+ The application exposes health endpoints at `/healthyz` and `/readyz` that return the status of all registered health checks.
186
+ To check if the application is running without performing health checks, use `/livez`.
187
+
188
+ ## Server Configuration
189
+
190
+ The server configuration is determined by the `ENVIRONMENT` variable:
191
+
192
+ | Setting | Development | Production |
193
+ | ---------- | ----------- | ---------- |
194
+ | Host | `0.0.0.0` | `0.0.0.0` |
195
+ | Port | `8000` | `8000` |
196
+ | Log Level | `debug` | `warning` |
197
+ | Access Log | `true` | `false` |
@@ -0,0 +1,18 @@
1
+ processcube_etw_library/__init__.py,sha256=-Kf99BVV-XUw9xJBAmDoZRcFH0BUp3jGOMQA0on2sNI,662
2
+ processcube_etw_library/create_external_task_client.py,sha256=nxrZh5U7PkSkx6vLLrcLCPpEBzZv11CGfb6cXIXSXog,1112
3
+ processcube_etw_library/etw_app.py,sha256=CiRvZC5N6lSfu_IDoKmrAgCkS4xZpIll-QAaObRfGos,3260
4
+ processcube_etw_library/identity_provider.py,sha256=X33lOEPrB-HaZGc5DjTSPHynU7EdbTVFJ6vPg0K_boc,2785
5
+ processcube_etw_library/server_config.py,sha256=qgKiNjgf2GzteZ1rAdSLH8GHt_i9rVpy32ttvKI4CGA,630
6
+ processcube_etw_library/settings.py,sha256=06OeG9oT73XlNfa2uK17J1_HwFJ_mKWyyCzv4uiUB9I,3691
7
+ processcube_etw_library/typed_handler.py,sha256=ipfKK09D4zP8exz9PnMRBj2hSVJwJFS85v7x7h9IGrs,1670
8
+ processcube_etw_library/health/__init__.py,sha256=-x-XcvovAF-4CIGFY_SaxBGz60tPg3VoPMavxvOWxQ4,588
9
+ processcube_etw_library/health/built_in.py,sha256=nix40LwD8vPzsTLzVqvjvc1V8oLPvJnARWedhhYRbx8,1022
10
+ processcube_etw_library/health/check.py,sha256=2NiyMXsHCZmB9KD5XB3PprpgJK1HFblM-E9c1Ermt2E,1335
11
+ processcube_etw_library/health/handlers.py,sha256=iP9PIM1n_dfdwY8uFpxlbwe7oUNsch9Pg2AYI4SN8RY,1423
12
+ processcube_etw_library/health/models.py,sha256=mSDCaPvRjwddP41E05vbplk8abvemygj75FmmnAS65g,1529
13
+ processcube_etw_library/health/registry.py,sha256=h3ThPts9xTdnzuJeIpL_aG6xhI1DAHyaXXE3UzkiLWU,955
14
+ processcube_etw_library/health/routes.py,sha256=9zbi1TkPUP7t8hLu32IvS3tGBfSm7dkmEDxdwaM6JX4,754
15
+ processcube_etw_library-2026.1.22.120215b0.dist-info/METADATA,sha256=Mw78ZTWzizuYSAQmAQVzAPG0G-zIN9KbVYC-wRMPfEU,5836
16
+ processcube_etw_library-2026.1.22.120215b0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
17
+ processcube_etw_library-2026.1.22.120215b0.dist-info/top_level.txt,sha256=4PHR_mnrU9J-d4zMU4XHDSmB7BURAAryRmBgbuypSuI,24
18
+ processcube_etw_library-2026.1.22.120215b0.dist-info/RECORD,,
@@ -1,24 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: processcube-etw-library
3
- Version: 2026.1.22.73503b0
4
- Summary: A library to create ETW apps with the ProcessCube platform.
5
- Author-email: Jeremy Hill <jeremy.hill@profection.de>
6
- License: MIT
7
- Requires-Python: >=3.12
8
- Description-Content-Type: text/markdown
9
- Requires-Dist: fastapi[standard]>=0.128.0
10
- Requires-Dist: oauth2-client>=1.4.2
11
- Requires-Dist: processcube-client>=5.0.0
12
- Requires-Dist: tenacity>=9.1.2
13
-
14
- # ProcessCube ETW Library
15
-
16
- ## Installation
17
-
18
- ## Usage
19
-
20
- ### Start the ETW application
21
-
22
- ### Subscribe to External Task Topics
23
-
24
- ### Add a custom health check
@@ -1,18 +0,0 @@
1
- processcube_etw_library/__init__.py,sha256=B6b63RPPlkbf-X0nJVugzzCHehBwItWr3tmJ37J9WCo,681
2
- processcube_etw_library/create_external_task_client.py,sha256=aB0AgWNEipRJP8HXY92uJjEYuhJo_47g3VyU2mQtPgY,1110
3
- processcube_etw_library/etw_app.py,sha256=FWWhqMHqQex2pShYDi9FD2PTyiHkbR2yebWJxpQXKyU,3326
4
- processcube_etw_library/identity_provider.py,sha256=X33lOEPrB-HaZGc5DjTSPHynU7EdbTVFJ6vPg0K_boc,2785
5
- processcube_etw_library/server_config.py,sha256=z_x9NZX6Hz2KdN4cNu__2tn10sOSZ9xIAkpLnlnIy84,628
6
- processcube_etw_library/settings.py,sha256=sdangsMXIqpjEGRtlU-AVddFXzDTcg_rrIZxyO_IogM,3950
7
- processcube_etw_library/typed_handler.py,sha256=ipfKK09D4zP8exz9PnMRBj2hSVJwJFS85v7x7h9IGrs,1670
8
- processcube_etw_library/health/__init__.py,sha256=-x-XcvovAF-4CIGFY_SaxBGz60tPg3VoPMavxvOWxQ4,588
9
- processcube_etw_library/health/built_in.py,sha256=0PWJySskJ-h6dHIlH-IjYbR5jAQDXbLrBg7dhHW_H_4,1020
10
- processcube_etw_library/health/check.py,sha256=2NiyMXsHCZmB9KD5XB3PprpgJK1HFblM-E9c1Ermt2E,1335
11
- processcube_etw_library/health/handlers.py,sha256=iP9PIM1n_dfdwY8uFpxlbwe7oUNsch9Pg2AYI4SN8RY,1423
12
- processcube_etw_library/health/models.py,sha256=mSDCaPvRjwddP41E05vbplk8abvemygj75FmmnAS65g,1529
13
- processcube_etw_library/health/registry.py,sha256=h3ThPts9xTdnzuJeIpL_aG6xhI1DAHyaXXE3UzkiLWU,955
14
- processcube_etw_library/health/routes.py,sha256=9zbi1TkPUP7t8hLu32IvS3tGBfSm7dkmEDxdwaM6JX4,754
15
- processcube_etw_library-2026.1.22.73503b0.dist-info/METADATA,sha256=hN_KpjDDTHeWsYAhx4VBwX5LI98XRANezjbddno8x_4,584
16
- processcube_etw_library-2026.1.22.73503b0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
17
- processcube_etw_library-2026.1.22.73503b0.dist-info/top_level.txt,sha256=4PHR_mnrU9J-d4zMU4XHDSmB7BURAAryRmBgbuypSuI,24
18
- processcube_etw_library-2026.1.22.73503b0.dist-info/RECORD,,