watchmen-collector-kernel 17.0.2__tar.gz → 17.1.0__tar.gz

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.
Files changed (64) hide show
  1. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/PKG-INFO +9 -9
  2. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/pyproject.toml +9 -9
  3. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/cache/collector_cache_manger.py +0 -12
  4. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/cache/table_config_cache.py +1 -28
  5. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/common/settings.py +8 -14
  6. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/model/__init__.py +1 -1
  7. watchmen_collector_kernel-17.1.0/src/watchmen_collector_kernel/model/change_data_json.py +30 -0
  8. watchmen_collector_kernel-17.1.0/src/watchmen_collector_kernel/model/collector_model_config.py +14 -0
  9. watchmen_collector_kernel-17.1.0/src/watchmen_collector_kernel/model/collector_module_config.py +10 -0
  10. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/model/collector_table_config.py +30 -33
  11. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/model/condition.py +3 -5
  12. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/model/scheduled_task.py +20 -20
  13. watchmen_collector_kernel-17.1.0/src/watchmen_collector_kernel/model/trigger_event.py +60 -0
  14. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/service/table_config_service.py +10 -21
  15. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/service/trigger_collector.py +1 -1
  16. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/service/trigger_event_helper.py +3 -5
  17. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/scheduled_task_service.py +10 -8
  18. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/trigger_event_service.py +19 -3
  19. watchmen_collector_kernel-17.0.2/src/watchmen_collector_kernel/model/change_data_json.py +0 -30
  20. watchmen_collector_kernel-17.0.2/src/watchmen_collector_kernel/model/collector_model_config.py +0 -14
  21. watchmen_collector_kernel-17.0.2/src/watchmen_collector_kernel/model/collector_module_config.py +0 -10
  22. watchmen_collector_kernel-17.0.2/src/watchmen_collector_kernel/model/trigger_event.py +0 -26
  23. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/LICENSE +0 -0
  24. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/__init__.py +0 -0
  25. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/cache/__init__.py +0 -0
  26. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/cache/collector_cache_service.py +0 -0
  27. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/cache/collector_topic_cache.py +0 -0
  28. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/cache/model_config_cache.py +0 -0
  29. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/cache/module_config_cache.py +0 -0
  30. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/common/__init__.py +0 -0
  31. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/common/constants.py +0 -0
  32. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/common/exception.py +0 -0
  33. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/model/change_data_json_history.py +0 -0
  34. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/model/change_data_record.py +0 -0
  35. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/model/change_data_record_history.py +0 -0
  36. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/model/competitive_lock.py +0 -0
  37. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/model/scheduled_task_history.py +0 -0
  38. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/model/status.py +0 -0
  39. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/model/trigger_model.py +0 -0
  40. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/model/trigger_module.py +0 -0
  41. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/model/trigger_table.py +0 -0
  42. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/service/__init__.py +0 -0
  43. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/service/criteria_builder.py +0 -0
  44. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/service/data_capture.py +0 -0
  45. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/service/extract_source.py +0 -0
  46. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/service/extract_spi.py +0 -0
  47. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/service/extract_utils.py +0 -0
  48. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/service/lock_helper.py +0 -0
  49. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/service/model_config_service.py +0 -0
  50. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/service/module_config_service.py +0 -0
  51. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/service/task_service.py +0 -0
  52. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/__init__.py +0 -0
  53. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/change_data_json_history_service.py +0 -0
  54. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/change_data_json_service.py +0 -0
  55. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/change_data_record_history_service.py +0 -0
  56. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/change_data_record_service.py +0 -0
  57. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/collector_model_config_service.py +0 -0
  58. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/collector_module_config_service.py +0 -0
  59. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/collector_table_config_service.py +0 -0
  60. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/competitive_lock_service.py +0 -0
  61. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/scheduled_task_history_service.py +0 -0
  62. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/trigger_model_service.py +0 -0
  63. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/trigger_module_service.py +0 -0
  64. {watchmen_collector_kernel-17.0.2 → watchmen_collector_kernel-17.1.0}/src/watchmen_collector_kernel/storage/trigger_table_service.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: watchmen-collector-kernel
3
- Version: 17.0.2
3
+ Version: 17.1.0
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: botlikes
@@ -17,11 +17,11 @@ Provides-Extra: oss
17
17
  Provides-Extra: postgresql
18
18
  Provides-Extra: s3
19
19
  Requires-Dist: numpy (>=1.26.4,<2.0.0)
20
- Requires-Dist: watchmen-data-kernel (==17.0.2)
21
- Requires-Dist: watchmen-storage-mongodb (==17.0.2) ; extra == "mongodb"
22
- Requires-Dist: watchmen-storage-mssql (==17.0.2) ; extra == "mssql"
23
- Requires-Dist: watchmen-storage-mysql (==17.0.2) ; extra == "mysql"
24
- Requires-Dist: watchmen-storage-oracle (==17.0.2) ; extra == "oracle"
25
- Requires-Dist: watchmen-storage-oss (==17.0.2) ; extra == "oss"
26
- Requires-Dist: watchmen-storage-postgresql (==17.0.2) ; extra == "postgresql"
27
- Requires-Dist: watchmen-storage-s3 (==17.0.2) ; extra == "s3"
20
+ Requires-Dist: watchmen-data-kernel (==17.1.0)
21
+ Requires-Dist: watchmen-storage-mongodb (==17.1.0) ; extra == "mongodb"
22
+ Requires-Dist: watchmen-storage-mssql (==17.1.0) ; extra == "mssql"
23
+ Requires-Dist: watchmen-storage-mysql (==17.1.0) ; extra == "mysql"
24
+ Requires-Dist: watchmen-storage-oracle (==17.1.0) ; extra == "oracle"
25
+ Requires-Dist: watchmen-storage-oss (==17.1.0) ; extra == "oss"
26
+ Requires-Dist: watchmen-storage-postgresql (==17.1.0) ; extra == "postgresql"
27
+ Requires-Dist: watchmen-storage-s3 (==17.1.0) ; extra == "s3"
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "watchmen-collector-kernel"
3
- version = "17.0.2"
3
+ version = "17.1.0"
4
4
  description = ""
5
5
  authors = ["botlikes <75356972+botlikes456@users.noreply.github.com>"]
6
6
  license = "MIT"
@@ -11,14 +11,14 @@ packages = [
11
11
  [tool.poetry.dependencies]
12
12
  python = "~3.12"
13
13
  numpy = "^1.26.4"
14
- watchmen-data-kernel = "17.0.2"
15
- watchmen-storage-mysql = { version = "17.0.2", optional = true }
16
- watchmen-storage-oracle = { version = "17.0.2", optional = true }
17
- watchmen-storage-mongodb = { version = "17.0.2", optional = true }
18
- watchmen-storage-mssql = { version = "17.0.2", optional = true }
19
- watchmen-storage-postgresql = { version = "17.0.2", optional = true }
20
- watchmen-storage-oss = { version = "17.0.2", optional = true }
21
- watchmen-storage-s3 = { version = "17.0.2", optional = true }
14
+ watchmen-data-kernel = "17.1.0"
15
+ watchmen-storage-mysql = { version = "17.1.0", optional = true }
16
+ watchmen-storage-oracle = { version = "17.1.0", optional = true }
17
+ watchmen-storage-mongodb = { version = "17.1.0", optional = true }
18
+ watchmen-storage-mssql = { version = "17.1.0", optional = true }
19
+ watchmen-storage-postgresql = { version = "17.1.0", optional = true }
20
+ watchmen-storage-oss = { version = "17.1.0", optional = true }
21
+ watchmen-storage-s3 = { version = "17.1.0", optional = true }
22
22
 
23
23
  [tool.poetry.dev-dependencies]
24
24
 
@@ -28,10 +28,6 @@ class TableConfigsByTenantAndParentNameCache(Cache):
28
28
  pass
29
29
 
30
30
 
31
- class TableConfigByTenantAndTableNameCache(Cache):
32
- pass
33
-
34
-
35
31
  class CollectorTopicByIdCache(Cache):
36
32
  pass
37
33
 
@@ -60,10 +56,6 @@ configure_cache('TABLE_CONFIGS_BY_TENANT_AND_PARENT_NAME',
60
56
  {'cache_class': TableConfigsByTenantAndParentNameCache, 'maxsize': 512})
61
57
 
62
58
 
63
- configure_cache('TABLE_CONFIG_BY_TENANT_AND_TABLE_NAME',
64
- {'cache_class': TableConfigByTenantAndTableNameCache, 'maxsize': 512})
65
-
66
-
67
59
  configure_cache('COLLECTOR_TOPIC_BY_ID',
68
60
  {'cache_class': CollectorTopicByIdCache, 'maxsize': 512})
69
61
 
@@ -84,10 +76,6 @@ def get_table_configs_by_tenant_and_parent_name_cache() -> TableConfigsByTenantA
84
76
  return cache_set['TABLE_CONFIGS_BY_TENANT_AND_PARENT_NAME']
85
77
 
86
78
 
87
- def get_table_config_by_tenant_and_table_name_cache() -> TableConfigByTenantAndTableNameCache:
88
- return cache_set['TABLE_CONFIG_BY_TENANT_AND_TABLE_NAME']
89
-
90
-
91
79
  def get_collector_topic_by_id_cache() -> CollectorTopicByIdCache:
92
80
  return cache_set['COLLECTOR_TOPIC_BY_ID']
93
81
 
@@ -6,8 +6,7 @@ from watchmen_collector_kernel.model import CollectorTableConfig
6
6
 
7
7
  from watchmen_data_kernel.cache import InternalCache
8
8
 
9
- from .collector_cache_manger import get_table_config_by_tenant_and_name_cache, \
10
- get_table_config_by_tenant_and_table_name_cache, get_table_configs_by_tenant_and_parent_name_cache
9
+ from .collector_cache_manger import get_table_config_by_tenant_and_name_cache, get_table_configs_by_tenant_and_parent_name_cache
11
10
  from watchmen_collector_kernel.common import ask_collector_config_cache_enabled
12
11
 
13
12
 
@@ -16,7 +15,6 @@ class TableConfigCache:
16
15
  def __init__(self):
17
16
  self.ByTenantAndNameCache = InternalCache(cache=get_table_config_by_tenant_and_name_cache)
18
17
  self.ByTenantAndParentNameCache = InternalCache(cache=get_table_configs_by_tenant_and_parent_name_cache)
19
- self.ByTenantAndTableNameCache = InternalCache(cache=get_table_config_by_tenant_and_table_name_cache)
20
18
 
21
19
  # noinspection PyMethodMayBeStatic
22
20
  def to_tenant_and_name_key(self, name: str, tenant_id: TenantId) -> str:
@@ -44,30 +42,6 @@ class TableConfigCache:
44
42
  else:
45
43
  return None
46
44
 
47
- def put_config_by_table_name(self, table_config: CollectorTableConfig) -> Optional[CollectorTableConfig]:
48
- if ask_collector_config_cache_enabled():
49
- self.ByTenantAndTableNameCache.remove(table_config.tableName)
50
- existing_config = self.ByTenantAndTableNameCache.put(self.to_tenant_and_name_key(table_config.tableName, table_config.tenantId),
51
- table_config)
52
- return existing_config
53
- else:
54
- return None
55
-
56
- def get_config_by_table_name(self, table_name: str, tenant_id: str) -> Optional[CollectorTableConfig]:
57
- if ask_collector_config_cache_enabled():
58
- return self.ByTenantAndTableNameCache.get(self.to_tenant_and_name_key(table_name, tenant_id))
59
- else:
60
- return None
61
-
62
- def remove_config_by_table_name(self, table_name: str, tenant_id: str) -> Optional[CollectorTableConfig]:
63
- if ask_collector_config_cache_enabled():
64
- existing: Optional[CollectorTableConfig] = self.ByTenantAndTableNameCache.remove(
65
- self.to_tenant_and_name_key(table_name, tenant_id)
66
- )
67
- return existing
68
- else:
69
- return None
70
-
71
45
  def put_configs_by_parent_name(self, parent_name: str, tenant_id: str,
72
46
  configs: List[CollectorTableConfig]) -> Optional[List[CollectorTableConfig]]:
73
47
  if ask_collector_config_cache_enabled():
@@ -101,7 +75,6 @@ class TableConfigCache:
101
75
 
102
76
  def clear(self) -> None:
103
77
  self.ByTenantAndNameCache.clear()
104
- self.ByTenantAndTableNameCache.clear()
105
78
  self.ByTenantAndParentNameCache.clear()
106
79
 
107
80
 
@@ -1,30 +1,24 @@
1
- from pydantic import BaseSettings
1
+ from watchmen_utilities import ExtendedBaseSettings
2
2
  from logging import getLogger
3
3
 
4
4
  logger = getLogger(__name__)
5
5
 
6
6
 
7
- class CollectorSettings(BaseSettings):
7
+ class CollectorSettings(ExtendedBaseSettings):
8
8
  CLEAN_OF_TIMEOUT_INTERVAL: int = 300
9
9
  LOCK_TIMEOUT: int = 1800
10
- TRIGGER_EVENT_LOCK_TIMEOUT = 300
11
- EXTRACT_TABLE_LOCK_TIMEOUT = 7200
12
- CLEAN_UP_LOCK_TIMEOUT = 300
10
+ TRIGGER_EVENT_LOCK_TIMEOUT: int = 300
11
+ EXTRACT_TABLE_LOCK_TIMEOUT: int = 7200
12
+ CLEAN_UP_LOCK_TIMEOUT: int = 300
13
13
  COLLECTOR_TIMEOUT: int = 600
14
14
  COLLECTOR_TASK_TIMEOUT: int = 900
15
- S3_CONNECTOR_LOCK_TIMEOUT = 300
15
+ S3_CONNECTOR_LOCK_TIMEOUT: int = 300
16
16
  PARTIAL_SIZE: int = 100
17
17
  COLLECTOR_CONFIG_CACHE_ENABLED: bool = True
18
- EXCEPTION_MAX_LENGTH = 5000 # character
19
- GROUPED_TASK_DATA_SIZE_THRESHOLD = 100
18
+ EXCEPTION_MAX_LENGTH: int = 5000 # character
19
+ GROUPED_TASK_DATA_SIZE_THRESHOLD: int = 100
20
20
  TASK_PARTIAL_SIZE: int = 100
21
21
 
22
- class Config:
23
- # secrets_dir = '/var/run'
24
- env_file = '.env'
25
- env_file_encoding = 'utf-8'
26
- case_sensitive = True
27
-
28
22
 
29
23
  collector_settings = CollectorSettings()
30
24
  logger.info(f'Collector settings[{collector_settings.dict()}].')
@@ -5,7 +5,7 @@ from .collector_module_config import CollectorModuleConfig
5
5
  from .collector_model_config import CollectorModelConfig
6
6
  from .collector_table_config import CollectorTableConfig
7
7
 
8
- from .trigger_event import TriggerEvent, EventType
8
+ from .trigger_event import TriggerEvent, EventType, QueryParam
9
9
  from .trigger_module import TriggerModule
10
10
  from .trigger_model import TriggerModel
11
11
  from .trigger_table import TriggerTable
@@ -0,0 +1,30 @@
1
+ from typing import Dict, List, Optional
2
+
3
+ from watchmen_utilities import ExtendedBaseModel
4
+
5
+ from watchmen_model.common import TenantBasedTuple, Storable
6
+
7
+
8
+ class Dependence(Storable, ExtendedBaseModel):
9
+ modelName: Optional[str] = None
10
+ objectId: Optional[str] = None
11
+
12
+
13
+ class ChangeDataJson(TenantBasedTuple, ExtendedBaseModel):
14
+ changeJsonId: Optional[int] = None
15
+ resourceId: Optional[str] = None
16
+ modelName: Optional[str] = None
17
+ objectId: Optional[str] = None
18
+ sequence: Optional[int] = None
19
+ content: Optional[Dict] = None
20
+ dataId: Optional[Dict] = None
21
+ dependOn: Optional[List[Dependence]] = None
22
+ isPosted: Optional[bool] = None
23
+ status: Optional[int] = None
24
+ result: Optional[Dict] = None
25
+ taskId: Optional[int] = None
26
+ tableTriggerId: Optional[int] = None
27
+ modelTriggerId: Optional[int] = None
28
+ moduleTriggerId: Optional[int] = None
29
+ eventTriggerId: Optional[int] = None
30
+
@@ -0,0 +1,14 @@
1
+ from typing import List, Optional
2
+ from watchmen_model.common import TenantBasedTuple, OptimisticLock
3
+ from watchmen_utilities import ExtendedBaseModel
4
+
5
+
6
+ class CollectorModelConfig(TenantBasedTuple, OptimisticLock, ExtendedBaseModel):
7
+ modelId: Optional[str] = None
8
+ modelName: Optional[str] = None
9
+ moduleId: Optional[str] = None
10
+ dependOn: Optional[List[str]] = None
11
+ priority: int = 0
12
+ rawTopicCode: Optional[str] = None
13
+ isParalleled: Optional[bool] = None
14
+
@@ -0,0 +1,10 @@
1
+ from typing import List, Optional
2
+ from watchmen_model.common import TenantBasedTuple, OptimisticLock
3
+ from watchmen_utilities import ExtendedBaseModel
4
+
5
+
6
+ class CollectorModuleConfig(TenantBasedTuple, OptimisticLock, ExtendedBaseModel):
7
+ moduleId: Optional[str] = None
8
+ moduleName: Optional[str] = None
9
+ priority: int = 0
10
+
@@ -1,15 +1,12 @@
1
1
  from typing import Dict, List, Optional, Union
2
-
3
- from pydantic import BaseModel
4
-
5
2
  from .condition import Condition, construct_conditions, construct_condition
6
3
  from watchmen_model.common import TenantBasedTuple, Storable, OptimisticLock
7
- from watchmen_utilities import ArrayHelper
4
+ from watchmen_utilities import ArrayHelper, ExtendedBaseModel
8
5
 
9
6
 
10
- class JoinCondition(Storable, BaseModel):
11
- parentKey: Condition = None
12
- childKey: Condition = None
7
+ class JoinCondition(Storable, ExtendedBaseModel):
8
+ parentKey: Optional[Condition] = None
9
+ childKey: Optional[Condition] = None
13
10
 
14
11
  def __setattr__(self, name, value):
15
12
  if name == 'parentKey':
@@ -18,17 +15,17 @@ class JoinCondition(Storable, BaseModel):
18
15
  super().__setattr__(name, construct_condition(value))
19
16
 
20
17
 
21
- class Dependence(Storable, BaseModel):
22
- modelName: str
23
- objectKey: str # the dependent column
18
+ class Dependence(Storable, ExtendedBaseModel):
19
+ modelName: Optional[str] = None
20
+ objectKey: Optional[str] = None # the dependent column
24
21
 
25
22
 
26
- class JsonColumn(Storable, BaseModel):
27
- columnName: str = None
28
- ignoredPath: List[str] = None
29
- needFlatten: bool = None
30
- flattenPath: List[str] = None
31
- jsonPath: List[str] = None
23
+ class JsonColumn(Storable, ExtendedBaseModel):
24
+ columnName: Optional[str] = None
25
+ ignoredPath: Optional[List[str]] = None
26
+ needFlatten: Optional[bool] = None
27
+ flattenPath: Optional[List[str]] = None
28
+ jsonPath: Optional[List[str]] = None
32
29
 
33
30
 
34
31
  def construct_json_column(json_column: Union[JsonColumn, Dict]) -> Optional[JsonColumn]:
@@ -77,23 +74,23 @@ def construct_depend_on(depend_on: Optional[List[Union[Dependence, Dict]]]) -> O
77
74
  return ArrayHelper(depend_on).map(lambda x: construct_dependence(x)).to_list()
78
75
 
79
76
 
80
- class CollectorTableConfig(TenantBasedTuple, OptimisticLock, BaseModel):
81
- configId: str = None
82
- name: str = None
83
- tableName: str = None
84
- primaryKey: List[str] = None
85
- objectKey: str = None
86
- sequenceKey: str = None
87
- modelName: str = None
88
- parentName: str = None
89
- label: str = None
90
- joinKeys: List[JoinCondition] = None
91
- dependOn: List[Dependence] = []
92
- auditColumn: str = None
93
- ignoredColumns: List[str] = None
94
- jsonColumns: List[JsonColumn] = None
95
- conditions: List[Condition] = []
96
- dataSourceId: str = None
77
+ class CollectorTableConfig(TenantBasedTuple, OptimisticLock, ExtendedBaseModel):
78
+ configId: Optional[str] = None
79
+ name: Optional[str] = None
80
+ tableName: Optional[str] = None
81
+ primaryKey: Optional[List[str]] = None
82
+ objectKey: Optional[str] = None
83
+ sequenceKey: Optional[str] = None
84
+ modelName: Optional[str] = None
85
+ parentName: Optional[str] = None
86
+ label: Optional[str] = None
87
+ joinKeys: Optional[List[JoinCondition]] = None
88
+ dependOn: Optional[List[Dependence]] = []
89
+ auditColumn: Optional[str] = None
90
+ ignoredColumns: Optional[List[str]] = None
91
+ jsonColumns: Optional[List[JsonColumn]] = None
92
+ conditions: Optional[List[Condition]] = []
93
+ dataSourceId: Optional[str] = None
97
94
  isList: bool = False
98
95
  triggered: bool = False
99
96
 
@@ -4,14 +4,12 @@ from datetime import date, datetime
4
4
  from enum import Enum
5
5
  from typing import Optional, List, Union, Dict
6
6
 
7
- from pydantic import BaseModel
8
7
  from watchmen_storage import EntityCriteriaOperator
9
-
10
8
  from watchmen_model.common import DataModel
11
- from watchmen_utilities import ArrayHelper
9
+ from watchmen_utilities import ArrayHelper, ExtendedBaseModel
12
10
 
13
11
 
14
- class Condition(DataModel, BaseModel):
12
+ class Condition(DataModel, ExtendedBaseModel):
15
13
  pass
16
14
 
17
15
 
@@ -28,7 +26,7 @@ class ConditionJointConjunction(str, Enum):
28
26
 
29
27
  class ConditionJoint(Condition):
30
28
  conjunction: ConditionJointConjunction = ConditionJointConjunction.AND
31
- children: List[Condition]
29
+ children: Optional[List[Condition]] = None
32
30
 
33
31
  def __setattr__(self, name, value):
34
32
  if name == 'children':
@@ -1,9 +1,8 @@
1
1
  from typing import Dict, List, Optional, Union
2
2
 
3
- from watchmen_utilities import ArrayHelper
4
-
3
+ from watchmen_utilities import ArrayHelper, ExtendedBaseModel
5
4
  from watchmen_model.common import TenantBasedTuple, ScheduledTaskId, Storable
6
- from pydantic import BaseModel
5
+
7
6
  from enum import Enum
8
7
 
9
8
 
@@ -19,7 +18,7 @@ class Result(str, Enum):
19
18
  PROCESS_TASK_FAILED = "PROCESS_TASK_FAILED"
20
19
 
21
20
 
22
- class Dependence(Storable, BaseModel):
21
+ class Dependence(Storable, ExtendedBaseModel):
23
22
  modelName: str
24
23
  objectId: str
25
24
 
@@ -40,22 +39,23 @@ def construct_depend_on(depend_on: Optional[List[Union[Dependence, Dict]]]) -> O
40
39
  return ArrayHelper(depend_on).map(lambda x: construct_dependence(x)).to_list()
41
40
 
42
41
 
43
- class ScheduledTask(TenantBasedTuple, BaseModel):
44
- taskId: ScheduledTaskId
45
- resourceId: str # global unique, monotonous increase
46
- topicCode: str
47
- content: Dict
48
- changeJsonIds: List[int]
49
- modelName: str
50
- objectId: str
51
- dependOn: List[Dependence]
52
- parentTaskId: List[int]
53
- isFinished: bool
54
- status: int
55
- result: Dict
56
- eventId: str
57
- pipelineId: str
58
- type: int
42
+ class ScheduledTask(TenantBasedTuple, ExtendedBaseModel):
43
+ taskId: Optional[ScheduledTaskId] = None
44
+ resourceId: Optional[str] = None # global unique, monotonous increase
45
+ topicCode: Optional[str] = None
46
+ content: Optional[Dict] = None
47
+ changeJsonIds: Optional[List[int]] = None
48
+ modelName: Optional[str] = None
49
+ objectId: Optional[str] = None
50
+ dependOn: Optional[List[Dependence]] = None
51
+ parentTaskId: Optional[List[int]] = None
52
+ isFinished: Optional[bool] = None
53
+ status: Optional[int] = None
54
+ result: Optional[Dict] = None
55
+ eventId: Optional[str] = None # Deprecated
56
+ eventTriggerId: Optional[int] = None
57
+ pipelineId: Optional[str] = None
58
+ type: Optional[int] = None
59
59
 
60
60
  def __setattr__(self, name, value):
61
61
  if name == 'dependOn':
@@ -0,0 +1,60 @@
1
+ from datetime import datetime
2
+ from enum import Enum
3
+ from typing import List, Dict, Optional, Union
4
+
5
+ from .condition import Condition, construct_conditions
6
+ from watchmen_model.common import TenantBasedTuple, DataModel
7
+ from watchmen_utilities import ExtendedBaseModel, ArrayHelper
8
+
9
+
10
+ class EventType(int, Enum):
11
+ DEFAULT = 1,
12
+ BY_TABLE = 2,
13
+ BY_RECORD = 3,
14
+ BY_PIPELINE = 4
15
+
16
+
17
+ class QueryParam(DataModel, ExtendedBaseModel):
18
+ name: str
19
+ filter: List[Condition]
20
+
21
+ def __setattr__(self, name, value):
22
+ if name == 'filter':
23
+ super().__setattr__(name, construct_conditions(value))
24
+ else:
25
+ super().__setattr__(name, value)
26
+
27
+
28
+ class TriggerEvent(TenantBasedTuple, ExtendedBaseModel):
29
+ eventTriggerId: Optional[int] = None
30
+ startTime: Optional[datetime] = None
31
+ endTime: Optional[datetime] = None
32
+ isFinished: bool = False
33
+ status: Optional[int] = None
34
+ type: Optional[int] = None
35
+ tableName: Optional[str] = None
36
+ records: Optional[List[Dict]] = []
37
+ pipelineId: Optional[str] = None
38
+ params: Optional[List[QueryParam]] = None
39
+
40
+ def __setattr__(self, name, value):
41
+ if name == 'params':
42
+ super().__setattr__(name, construct_params(value))
43
+ else:
44
+ super().__setattr__(name, value)
45
+
46
+
47
+ def construct_params(params: Optional[List[Union[dict, QueryParam]]]) -> Optional[List[QueryParam]]:
48
+ if params is None:
49
+ return None
50
+ else:
51
+ return ArrayHelper(params).map(lambda x: construct_param(x)).to_list()
52
+
53
+
54
+ def construct_param(param: Optional[Union[dict, QueryParam]]) -> Optional[QueryParam]:
55
+ if param is None:
56
+ return None
57
+ elif isinstance(param, QueryParam):
58
+ return param
59
+ else:
60
+ return QueryParam(**param)
@@ -18,24 +18,6 @@ class TableConfigService:
18
18
  def __init__(self, principal_service: PrincipalService):
19
19
  self.principalService = principal_service
20
20
 
21
- def find_by_table_name(self, table_name: str, tenant_id: str) -> Optional[CollectorTableConfig]:
22
- config = CollectorCacheService.table_config().get_config_by_table_name(table_name, tenant_id)
23
- if config is not None:
24
- return config
25
-
26
- storage_service = get_collector_table_config_service(
27
- ask_meta_storage(), ask_snowflake_generator(), self.principalService
28
- )
29
- table_config: CollectorTableConfig = storage_service.find_by_table_name(table_name, tenant_id)
30
- if table_config is None:
31
- table_config = self.find_by_topic_name(table_name, tenant_id)
32
-
33
- if table_config is None:
34
- return None
35
-
36
- CollectorCacheService.table_config().put_config_by_table_name(table_config)
37
- return table_config
38
-
39
21
  def find_by_name(self, name: str, tenant_id: str) -> Optional[CollectorTableConfig]:
40
22
  config = CollectorCacheService.table_config().get_config_by_name(name, tenant_id)
41
23
  if config is not None:
@@ -45,6 +27,9 @@ class TableConfigService:
45
27
  ask_meta_storage(), ask_snowflake_generator(), self.principalService
46
28
  )
47
29
  table_config: CollectorTableConfig = storage_service.find_by_name(name, tenant_id)
30
+ if table_config is None:
31
+ table_config = self.find_by_topic_name(name, tenant_id)
32
+
48
33
  if table_config is None:
49
34
  return None
50
35
 
@@ -77,15 +62,19 @@ class TableConfigService:
77
62
  def get_topic_name_by_table_name(self, table_name: str) -> str:
78
63
  return table_name.removeprefix("topic_")
79
64
 
80
- def find_by_topic_name(self, table_name: str, tenant_id: str) -> Optional[CollectorTableConfig]:
81
- topic_name = self.get_topic_name_by_table_name(table_name)
65
+ # noinspection PyMethodMayBeStatic
66
+ def get_table_name_by_topic_name(self, topic_name: str) -> str:
67
+ return "topic_" + topic_name
68
+
69
+ def find_by_topic_name(self, name: str, tenant_id: str) -> Optional[CollectorTableConfig]:
70
+ topic_name = name
82
71
  schema = TopicService(self.principalService).find_schema_by_name(topic_name, tenant_id)
83
72
  now = get_current_time_in_seconds()
84
73
  if schema:
85
74
  return CollectorTableConfig(
86
75
  configId=self.fake_config_id(schema.topic.topicId),
87
76
  name=topic_name,
88
- tableName=table_name,
77
+ tableName=self.get_table_name_by_topic_name(name),
89
78
  primaryKey=["id_"],
90
79
  objectKey="id_",
91
80
  sequenceKey=None,
@@ -132,7 +132,7 @@ def new_trigger_table(table_name: str,
132
132
 
133
133
 
134
134
  def get_trigger_table(model_trigger: TriggerModel, table_config: CollectorTableConfig) -> TriggerTable:
135
- return new_trigger_table(table_config.tableName,
135
+ return new_trigger_table(table_config.name,
136
136
  table_config.modelName,
137
137
  model_trigger.modelTriggerId,
138
138
  model_trigger.moduleTriggerId,
@@ -86,8 +86,7 @@ def trigger_event_by_table(trigger_event: TriggerEvent):
86
86
  trigger_event_service.snowflakeGenerator,
87
87
  trigger_event_service.principalService)
88
88
 
89
- table_config = table_config_service.find_by_table_name_and_tenant_id(trigger_event.tableName,
90
- trigger_event.tenantId)
89
+ table_config = table_config_service.find_by_name(trigger_event.tableName, trigger_event.tenantId)
91
90
  model_config = model_config_service.find_by_name(table_config.modelName, table_config.tenantId)
92
91
 
93
92
  module_config = module_config_service.find_by_module_id(model_config.moduleId)
@@ -140,8 +139,7 @@ def trigger_event_by_records(trigger_event: TriggerEvent):
140
139
  trigger_event_service.snowflakeGenerator,
141
140
  trigger_event_service.principalService)
142
141
 
143
- table_config = table_config_service.find_by_table_name_and_tenant_id(trigger_event.tableName,
144
- trigger_event.tenantId)
142
+ table_config = table_config_service.find_by_name(trigger_event.tableName, trigger_event.tenantId)
145
143
  model_config = model_config_service.find_by_name(table_config.modelName, table_config.tenantId)
146
144
  module_config = module_config_service.find_by_module_id(model_config.moduleId)
147
145
 
@@ -276,7 +274,7 @@ def trigger_event_by_pipeline(trigger_event: TriggerEvent):
276
274
  model_config_service = get_model_config_service(principal_service)
277
275
  table_config_service = get_table_config_service(principal_service)
278
276
 
279
- table_config = table_config_service.find_by_table_name(trigger_event.tableName, trigger_event.tenantId)
277
+ table_config = table_config_service.find_by_name(trigger_event.tableName, trigger_event.tenantId)
280
278
  model_config = model_config_service.find_by_name(table_config.modelName, trigger_event.tenantId)
281
279
  module_config = module_config_service.find_by_module_id(model_config.moduleId, trigger_event.tenantId)
282
280
 
@@ -32,6 +32,7 @@ class ScheduledTaskShaper(EntityShaper):
32
32
  'status': entity.status,
33
33
  'result': entity.result,
34
34
  'event_id': entity.eventId,
35
+ 'event_trigger_id': entity.eventTriggerId,
35
36
  'pipeline_id': entity.pipelineId,
36
37
  'type': entity.type
37
38
  })
@@ -53,6 +54,7 @@ class ScheduledTaskShaper(EntityShaper):
53
54
  status=row.get('status'),
54
55
  result=row.get('result'),
55
56
  eventId=row.get('event_id'),
57
+ eventTriggerId=row.get('event_trigger_id'),
56
58
  pipelineId=row.get('pipeline_id'),
57
59
  type=row.get('type')
58
60
  ))
@@ -205,7 +207,7 @@ class ScheduledTaskService(TupleService):
205
207
  finally:
206
208
  self.close_transaction()
207
209
 
208
- def find_model_dependent_tasks(self, model_name: str, object_id: str, event_id: str, tenant_id: str) -> List[ScheduledTask]:
210
+ def find_model_dependent_tasks(self, model_name: str, object_id: str, event_trigger_id: int, tenant_id: str) -> List[ScheduledTask]:
209
211
  self.begin_transaction()
210
212
  try:
211
213
  # noinspection PyTypeChecker
@@ -215,8 +217,8 @@ class ScheduledTaskService(TupleService):
215
217
  right=model_name),
216
218
  EntityCriteriaExpression(left=ColumnNameLiteral(columnName='object_id'),
217
219
  right=object_id),
218
- EntityCriteriaExpression(left=ColumnNameLiteral(columnName='event_id'),
219
- right=event_id),
220
+ EntityCriteriaExpression(left=ColumnNameLiteral(columnName='event_trigger_id'),
221
+ right=event_trigger_id),
220
222
  EntityCriteriaExpression(left=ColumnNameLiteral(columnName='tenant_id'),
221
223
  right=tenant_id)
222
224
  ],
@@ -247,7 +249,7 @@ class ScheduledTaskService(TupleService):
247
249
  def count_scheduled_task(self, event_trigger_id: int) -> int:
248
250
  return self.storage.count(self.get_entity_finder(
249
251
  criteria=[
250
- EntityCriteriaExpression(left=ColumnNameLiteral(columnName='event_id'),
252
+ EntityCriteriaExpression(left=ColumnNameLiteral(columnName='event_trigger_id'),
251
253
  right=event_trigger_id)
252
254
  ]
253
255
  ))
@@ -264,7 +266,7 @@ class ScheduledTaskService(TupleService):
264
266
  finally:
265
267
  self.storage.close()
266
268
 
267
- def is_model_finished(self, model_name: str, event_id: str) -> bool:
269
+ def is_model_finished(self, model_name: str, event_trigger_id: int) -> bool:
268
270
  try:
269
271
  self.begin_transaction()
270
272
  results = self.storage.find_limited(
@@ -273,7 +275,7 @@ class ScheduledTaskService(TupleService):
273
275
  shaper=self.get_entity_shaper(),
274
276
  criteria=[
275
277
  EntityCriteriaExpression(left=ColumnNameLiteral(columnName='model_name'), right=model_name),
276
- EntityCriteriaExpression(left=ColumnNameLiteral(columnName='event_id'), right=event_id)
278
+ EntityCriteriaExpression(left=ColumnNameLiteral(columnName='event_trigger_id'), right=event_trigger_id)
277
279
  ],
278
280
  limit=1
279
281
  )
@@ -289,7 +291,7 @@ class ScheduledTaskService(TupleService):
289
291
  finally:
290
292
  self.close_transaction()
291
293
 
292
- def is_event_finished(self, event_id: str) -> bool:
294
+ def is_event_finished(self, event_trigger_id: int) -> bool:
293
295
  try:
294
296
  self.begin_transaction()
295
297
  results = self.storage.find_limited(
@@ -297,7 +299,7 @@ class ScheduledTaskService(TupleService):
297
299
  name=self.get_entity_name(),
298
300
  shaper=self.get_entity_shaper(),
299
301
  criteria=[
300
- EntityCriteriaExpression(left=ColumnNameLiteral(columnName='event_id'), right=event_id)
302
+ EntityCriteriaExpression(left=ColumnNameLiteral(columnName='event_trigger_id'), right=event_trigger_id)
301
303
  ],
302
304
  limit=1
303
305
  )
@@ -1,17 +1,31 @@
1
1
  from typing import List, Dict, Any, Optional
2
2
 
3
3
  from watchmen_auth import PrincipalService
4
- from watchmen_collector_kernel.model import TriggerEvent
4
+ from watchmen_collector_kernel.model import TriggerEvent, QueryParam
5
5
  from watchmen_meta.common import TupleShaper, TupleService
6
6
  from watchmen_meta.common.storage_service import StorableId
7
7
  from watchmen_model.common import Storable, EventTriggerId
8
8
  from watchmen_storage import EntityName, EntityRow, EntityShaper, TransactionalStorageSPI, SnowflakeGenerator, \
9
9
  EntityStraightValuesFinder, EntityCriteriaExpression, ColumnNameLiteral, \
10
10
  EntityStraightColumn, EntitySortColumn, EntitySortMethod
11
+ from watchmen_utilities import ArrayHelper
11
12
 
12
13
 
13
14
  class TriggerEventShaper(EntityShaper):
14
15
 
16
+ @staticmethod
17
+ def serialize_param(param: Optional[QueryParam]) -> dict:
18
+ if isinstance(param, dict):
19
+ return param
20
+ else:
21
+ return param.to_dict()
22
+
23
+ @staticmethod
24
+ def serialize_params(params: Optional[List[QueryParam]]) -> Optional[list]:
25
+ if params is None:
26
+ return None
27
+ return ArrayHelper(params).map(lambda x: TriggerEventShaper.serialize_param(x)).to_list()
28
+
15
29
  def serialize(self, entity: TriggerEvent) -> EntityRow:
16
30
  return TupleShaper.serialize_tenant_based(entity, {
17
31
  'event_trigger_id': entity.eventTriggerId,
@@ -22,7 +36,8 @@ class TriggerEventShaper(EntityShaper):
22
36
  'type': entity.type,
23
37
  'table_name': entity.tableName,
24
38
  'records': entity.records,
25
- 'pipeline_id': entity.pipelineId
39
+ 'pipeline_id': entity.pipelineId,
40
+ 'params': TriggerEventShaper.serialize_params(entity.params)
26
41
  })
27
42
 
28
43
  def deserialize(self, row: EntityRow) -> TriggerEvent:
@@ -36,7 +51,8 @@ class TriggerEventShaper(EntityShaper):
36
51
  type=row.get('type'),
37
52
  tableName=row.get('table_name'),
38
53
  records=row.get('records'),
39
- pipelineId=row.get('pipeline_id')
54
+ pipelineId=row.get('pipeline_id'),
55
+ params=row.get('params')
40
56
  ))
41
57
 
42
58
 
@@ -1,30 +0,0 @@
1
- from typing import Dict, List
2
-
3
- from pydantic import BaseModel
4
-
5
- from watchmen_model.common import TenantBasedTuple, Storable
6
-
7
-
8
- class Dependence(Storable, BaseModel):
9
- modelName: str
10
- objectId: str
11
-
12
-
13
- class ChangeDataJson(TenantBasedTuple, BaseModel):
14
- changeJsonId: int
15
- resourceId: str
16
- modelName: str
17
- objectId: str
18
- sequence: int
19
- content: Dict
20
- dataId: Dict
21
- dependOn: List[Dependence]
22
- isPosted: bool
23
- status: int
24
- result: Dict
25
- taskId: int
26
- tableTriggerId: int
27
- modelTriggerId: int
28
- moduleTriggerId: int
29
- eventTriggerId: int
30
-
@@ -1,14 +0,0 @@
1
- from typing import List
2
- from watchmen_model.common import TenantBasedTuple, OptimisticLock
3
- from pydantic import BaseModel
4
-
5
-
6
- class CollectorModelConfig(TenantBasedTuple, OptimisticLock, BaseModel):
7
- modelId: str
8
- modelName: str
9
- moduleId: str
10
- dependOn: List[str]
11
- priority: int = 0
12
- rawTopicCode: str
13
- isParalleled: bool
14
-
@@ -1,10 +0,0 @@
1
- from typing import List
2
- from watchmen_model.common import TenantBasedTuple, OptimisticLock
3
- from pydantic import BaseModel
4
-
5
-
6
- class CollectorModuleConfig(TenantBasedTuple, OptimisticLock, BaseModel):
7
- moduleId: str
8
- moduleName: str
9
- priority: int = 0
10
-
@@ -1,26 +0,0 @@
1
- from datetime import datetime
2
- from enum import Enum
3
- from typing import List, Dict
4
-
5
- from watchmen_model.common import TenantBasedTuple
6
- from pydantic import BaseModel
7
-
8
-
9
- class EventType(int, Enum):
10
- DEFAULT = 1,
11
- BY_TABLE = 2,
12
- BY_RECORD = 3,
13
- BY_PIPELINE = 4
14
-
15
-
16
- class TriggerEvent(TenantBasedTuple, BaseModel):
17
- eventTriggerId: int
18
- startTime: datetime
19
- endTime: datetime
20
- isFinished: bool = False
21
- status: int
22
- type: int
23
- tableName: str
24
- records: List[Dict] = []
25
- pipelineId: str
26
-