atlan-application-sdk 0.1.1rc61__py3-none-any.whl → 0.1.1rc62__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.
@@ -1,4 +1,5 @@
1
1
  import asyncio
2
+ import time
2
3
  import uuid
3
4
  from concurrent.futures import ThreadPoolExecutor
4
5
  from typing import Any, Dict, Optional, Sequence, Type
@@ -26,10 +27,17 @@ from application_sdk.constants import (
26
27
  WORKFLOW_PORT,
27
28
  WORKFLOW_TLS_ENABLED_KEY,
28
29
  )
30
+ from application_sdk.events.models import (
31
+ ApplicationEventNames,
32
+ Event,
33
+ EventTypes,
34
+ WorkerTokenRefreshEventData,
35
+ )
29
36
  from application_sdk.interceptors.cleanup import CleanupInterceptor, cleanup
30
37
  from application_sdk.interceptors.events import EventInterceptor, publish_event
31
38
  from application_sdk.interceptors.lock import RedisLockInterceptor
32
39
  from application_sdk.observability.logger_adaptor import get_logger
40
+ from application_sdk.services.eventstore import EventStore
33
41
  from application_sdk.services.secretstore import SecretStore
34
42
  from application_sdk.services.statestore import StateStore, StateType
35
43
  from application_sdk.workflows import WorkflowInterface
@@ -142,6 +150,39 @@ class TemporalWorkflowClient(WorkflowClient):
142
150
  """
143
151
  return self.namespace
144
152
 
153
+ async def _publish_token_refresh_event(self) -> None:
154
+ """Publish a token refresh event to the event store.
155
+
156
+ This method creates and publishes an event containing token refresh information,
157
+ including application name, deployment name, token expiry times, and refresh timestamp.
158
+ If event publishing fails, it logs a warning but does not raise an exception to avoid
159
+ disrupting the token refresh loop.
160
+
161
+ Note:
162
+ This method handles exceptions internally and will not propagate errors,
163
+ ensuring the token refresh loop continues even if event publishing fails.
164
+ """
165
+ try:
166
+ current_time = time.time()
167
+ worker_token_refresh_data = WorkerTokenRefreshEventData(
168
+ application_name=self.application_name,
169
+ deployment_name=DEPLOYMENT_NAME,
170
+ force_refresh=True,
171
+ token_expiry_time=self.auth_manager.get_token_expiry_time() or 0,
172
+ time_until_expiry=self.auth_manager.get_time_until_expiry() or 0,
173
+ refresh_timestamp=current_time,
174
+ )
175
+
176
+ event = Event(
177
+ event_type=EventTypes.APPLICATION_EVENT.value,
178
+ event_name=ApplicationEventNames.TOKEN_REFRESH.value,
179
+ data=worker_token_refresh_data.model_dump(),
180
+ )
181
+ await EventStore.publish_event(event)
182
+ logger.info("Published token refresh event")
183
+ except Exception as e:
184
+ logger.warning(f"Failed to publish token refresh event: {e}")
185
+
145
186
  async def _token_refresh_loop(self) -> None:
146
187
  """Background loop that refreshes the authentication token dynamically."""
147
188
  while True:
@@ -161,6 +202,9 @@ class TemporalWorkflowClient(WorkflowClient):
161
202
  self._token_refresh_interval = (
162
203
  self.auth_manager.calculate_refresh_interval()
163
204
  )
205
+ # Publish token refresh event
206
+ await self._publish_token_refresh_event()
207
+
164
208
  except asyncio.CancelledError:
165
209
  logger.info("Token refresh loop cancelled")
166
210
  break
@@ -29,6 +29,7 @@ class ApplicationEventNames(Enum):
29
29
  WORKER_END = "worker_end"
30
30
  APPLICATION_START = "application_start"
31
31
  APPLICATION_END = "application_end"
32
+ TOKEN_REFRESH = "token_refresh"
32
33
 
33
34
 
34
35
  class WorkflowStates(Enum):
@@ -174,3 +175,26 @@ class WorkerStartEventData(BaseModel):
174
175
  max_concurrent_activities: Optional[int]
175
176
  workflow_count: int
176
177
  activity_count: int
178
+
179
+
180
+ class WorkerTokenRefreshEventData(BaseModel):
181
+ """Model for token refresh event data.
182
+
183
+ This model represents the data structure used when publishing token refresh events.
184
+ It contains information about the token refresh operation and agent status.
185
+
186
+ Attributes:
187
+ application_name: Name of the application the token belongs to.
188
+ deployment_name: Name of the deployment (e.g., dev, staging, prod).
189
+ force_refresh: Whether this was a forced refresh or automatic.
190
+ token_expiry_time: Unix timestamp when the new token expires.
191
+ time_until_expiry: Seconds until token expires.
192
+ refresh_timestamp: Unix timestamp when the refresh occurred.
193
+ """
194
+
195
+ application_name: str
196
+ deployment_name: str
197
+ force_refresh: bool
198
+ token_expiry_time: float
199
+ time_until_expiry: float
200
+ refresh_timestamp: float
@@ -2,4 +2,4 @@
2
2
  Version information for the application_sdk package.
3
3
  """
4
4
 
5
- __version__ = "0.1.1rc61"
5
+ __version__ = "0.1.1rc62"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atlan-application-sdk
3
- Version: 0.1.1rc61
3
+ Version: 0.1.1rc62
4
4
  Summary: Atlan Application SDK is a Python library for developing applications on the Atlan Platform
5
5
  Project-URL: Repository, https://github.com/atlanhq/application-sdk
6
6
  Project-URL: Documentation, https://github.com/atlanhq/application-sdk/README.md
@@ -1,6 +1,6 @@
1
1
  application_sdk/__init__.py,sha256=2e2mvmLJ5dxmJGPELtb33xwP-j6JMdoIuqKycEn7hjg,151
2
2
  application_sdk/constants.py,sha256=XCRJRiug2GXgeeVZu3Mp1QavRw54bWtzxIZ2l1bIkkA,11028
3
- application_sdk/version.py,sha256=CEakpB1d62-VZEzrOEEq4LSV4f0w3c23I9GOWtTnui8,88
3
+ application_sdk/version.py,sha256=MFOV2tNUAo7go0hrgOky6QW0SxSDPfPaY9aTrIZC3wg,88
4
4
  application_sdk/worker.py,sha256=i5f0AeKI39IfsLO05QkwC6uMz0zDPSJqP7B2byri1VI,7489
5
5
  application_sdk/activities/__init__.py,sha256=L5WXkTwOwGtjWAlXrUJRCKGwyIyp3z8fBv8BZVCRFQI,11175
6
6
  application_sdk/activities/lock_management.py,sha256=6Wdf3jMKitoarHQP91PIJOoGFz4aaOLS_40c7n1yAOA,3902
@@ -23,7 +23,7 @@ application_sdk/clients/base.py,sha256=TIn3pG89eXUc1XSYf4jk66m1vajWp0WxcCQOOltda
23
23
  application_sdk/clients/models.py,sha256=iZOTyH6LO64kozdiUPCFCN0NgLhd_Gtv0lH7ZIPdo8w,1800
24
24
  application_sdk/clients/redis.py,sha256=IfAD32vLp88BCvsDTaQtxFHxzHlEx4V7TK7h1HwDDBg,15917
25
25
  application_sdk/clients/sql.py,sha256=lXeVu_dute30IaWWK5gHBhjEs2dXp_e0XkOMsbOsq64,19589
26
- application_sdk/clients/temporal.py,sha256=jC3U8LmW8G6gg-Qmxk0rcAifIGF0KekwP1UkMGXN7RA,18314
26
+ application_sdk/clients/temporal.py,sha256=eSbBOmbRmYU-MLiQ1D8hHTU3-VIJssTYAzC2twLwf38,20200
27
27
  application_sdk/clients/utils.py,sha256=zLFOJbTr_6TOqnjfVFGY85OtIXZ4FQy_rquzjaydkbY,779
28
28
  application_sdk/clients/workflow.py,sha256=6bSqmA3sNCk9oY68dOjBUDZ9DhNKQxPD75qqE0cfldc,6104
29
29
  application_sdk/clients/.cursor/BUGBOT.md,sha256=7nEDUqWBEMI_uU6eK1jCSZGeXoQtLQcKwOrDn8AIDWo,10595
@@ -55,7 +55,7 @@ application_sdk/docgen/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
55
55
  application_sdk/docgen/parsers/directory.py,sha256=8Kk2sjb-0l2wLO_njdlcuHjv5akoNgmf-FmaDSaE4WM,7751
56
56
  application_sdk/docgen/parsers/manifest.py,sha256=3NP-dBTpHAUQa477usMIDaKSb_9xfLE8G3RX0T1Bq2s,3318
57
57
  application_sdk/events/__init__.py,sha256=OcbVWDF4ZKRTJXK9UaFVtYEwu-3DHE77S-Sn6jNafUs,204
58
- application_sdk/events/models.py,sha256=7Esqp3WlbriT2EqT4kNiY_sHtRXRPLj27b8SbeC5Sb0,5121
58
+ application_sdk/events/models.py,sha256=Q8qt1lW0XimtNI2GFd9o6kO3xOuPt9c8yFqzZJVKCv8,6019
59
59
  application_sdk/handlers/__init__.py,sha256=3Wf7jCVFR2nYOyHZEc9jj8BQUnHCylFqoezp70J2Df0,1329
60
60
  application_sdk/handlers/base.py,sha256=ieWFbv8Gm7vfrrpS-mdMSm-mHGuQY02qiAVX2qPdj3w,2467
61
61
  application_sdk/handlers/sql.py,sha256=6A_9xCtkXyNY5gPhImbftzrdPIEWIeTTqjyIewVESHA,17815
@@ -157,8 +157,8 @@ application_sdk/workflows/metadata_extraction/__init__.py,sha256=jHUe_ZBQ66jx8bg
157
157
  application_sdk/workflows/metadata_extraction/sql.py,sha256=6ZaVt84n-8U2ZvR9GR7uIJKv5v8CuyQjhlnoRJvDszc,12435
158
158
  application_sdk/workflows/query_extraction/__init__.py,sha256=n066_CX5RpJz6DIxGMkKS3eGSRg03ilaCtsqfJWQb7Q,117
159
159
  application_sdk/workflows/query_extraction/sql.py,sha256=kT_JQkLCRZ44ZpaC4QvPL6DxnRIIVh8gYHLqRbMI-hA,4826
160
- atlan_application_sdk-0.1.1rc61.dist-info/METADATA,sha256=sRo4wQ9dNcScMKLwS0nqbceTkr-pbE5rr8voxSMRoqo,5730
161
- atlan_application_sdk-0.1.1rc61.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
162
- atlan_application_sdk-0.1.1rc61.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
163
- atlan_application_sdk-0.1.1rc61.dist-info/licenses/NOTICE,sha256=A-XVVGt3KOYuuMmvSMIFkg534F1vHiCggEBp4Ez3wGk,1041
164
- atlan_application_sdk-0.1.1rc61.dist-info/RECORD,,
160
+ atlan_application_sdk-0.1.1rc62.dist-info/METADATA,sha256=8ApEAfPm6ZpGgjwZtDJ2F_rqLkNCM5L-3ZKTKkdkwJg,5730
161
+ atlan_application_sdk-0.1.1rc62.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
162
+ atlan_application_sdk-0.1.1rc62.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
163
+ atlan_application_sdk-0.1.1rc62.dist-info/licenses/NOTICE,sha256=A-XVVGt3KOYuuMmvSMIFkg534F1vHiCggEBp4Ez3wGk,1041
164
+ atlan_application_sdk-0.1.1rc62.dist-info/RECORD,,