watchmen-collector-kernel 17.0.3__py3-none-any.whl → 17.1.0__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.
@@ -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
@@ -1,30 +1,30 @@
1
- from typing import Dict, List
1
+ from typing import Dict, List, Optional
2
2
 
3
- from pydantic import BaseModel
3
+ from watchmen_utilities import ExtendedBaseModel
4
4
 
5
5
  from watchmen_model.common import TenantBasedTuple, Storable
6
6
 
7
7
 
8
- class Dependence(Storable, BaseModel):
9
- modelName: str
10
- objectId: str
8
+ class Dependence(Storable, ExtendedBaseModel):
9
+ modelName: Optional[str] = None
10
+ objectId: Optional[str] = None
11
11
 
12
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
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
30
 
@@ -1,14 +1,14 @@
1
- from typing import List
1
+ from typing import List, Optional
2
2
  from watchmen_model.common import TenantBasedTuple, OptimisticLock
3
- from pydantic import BaseModel
3
+ from watchmen_utilities import ExtendedBaseModel
4
4
 
5
5
 
6
- class CollectorModelConfig(TenantBasedTuple, OptimisticLock, BaseModel):
7
- modelId: str
8
- modelName: str
9
- moduleId: str
10
- dependOn: List[str]
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
11
  priority: int = 0
12
- rawTopicCode: str
13
- isParalleled: bool
12
+ rawTopicCode: Optional[str] = None
13
+ isParalleled: Optional[bool] = None
14
14
 
@@ -1,10 +1,10 @@
1
- from typing import List
1
+ from typing import List, Optional
2
2
  from watchmen_model.common import TenantBasedTuple, OptimisticLock
3
- from pydantic import BaseModel
3
+ from watchmen_utilities import ExtendedBaseModel
4
4
 
5
5
 
6
- class CollectorModuleConfig(TenantBasedTuple, OptimisticLock, BaseModel):
7
- moduleId: str
8
- moduleName: str
6
+ class CollectorModuleConfig(TenantBasedTuple, OptimisticLock, ExtendedBaseModel):
7
+ moduleId: Optional[str] = None
8
+ moduleName: Optional[str] = None
9
9
  priority: int = 0
10
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,23 +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 # Deprecated
57
- eventTriggerId: int
58
- pipelineId: str
59
- 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
60
59
 
61
60
  def __setattr__(self, name, value):
62
61
  if name == 'dependOn':
@@ -1,9 +1,10 @@
1
1
  from datetime import datetime
2
2
  from enum import Enum
3
- from typing import List, Dict
3
+ from typing import List, Dict, Optional, Union
4
4
 
5
- from watchmen_model.common import TenantBasedTuple
6
- from pydantic import BaseModel
5
+ from .condition import Condition, construct_conditions
6
+ from watchmen_model.common import TenantBasedTuple, DataModel
7
+ from watchmen_utilities import ExtendedBaseModel, ArrayHelper
7
8
 
8
9
 
9
10
  class EventType(int, Enum):
@@ -13,14 +14,47 @@ class EventType(int, Enum):
13
14
  BY_PIPELINE = 4
14
15
 
15
16
 
16
- class TriggerEvent(TenantBasedTuple, BaseModel):
17
- eventTriggerId: int
18
- startTime: datetime
19
- endTime: datetime
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
20
32
  isFinished: bool = False
21
- status: int
22
- type: int
23
- tableName: str
24
- records: List[Dict] = []
25
- pipelineId: str
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
+
26
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
 
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: watchmen-collector-kernel
3
- Version: 17.0.3
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.3)
21
- Requires-Dist: watchmen-storage-mongodb (==17.0.3) ; extra == "mongodb"
22
- Requires-Dist: watchmen-storage-mssql (==17.0.3) ; extra == "mssql"
23
- Requires-Dist: watchmen-storage-mysql (==17.0.3) ; extra == "mysql"
24
- Requires-Dist: watchmen-storage-oracle (==17.0.3) ; extra == "oracle"
25
- Requires-Dist: watchmen-storage-oss (==17.0.3) ; extra == "oss"
26
- Requires-Dist: watchmen-storage-postgresql (==17.0.3) ; extra == "postgresql"
27
- Requires-Dist: watchmen-storage-s3 (==17.0.3) ; 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,29 +1,29 @@
1
1
  watchmen_collector_kernel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  watchmen_collector_kernel/cache/__init__.py,sha256=ypQLQQtAanUybsWuwBpBjdD2yMC-c2Zub4g8zxj2CrY,59
3
- watchmen_collector_kernel/cache/collector_cache_manger.py,sha256=VtJnDkEDnCxvsQbZ0Wpkmqss5bCRuV_wmPBwaYEjbO8,2381
3
+ watchmen_collector_kernel/cache/collector_cache_manger.py,sha256=FjK2hpN8g5kA4GQFzcRCt1msIYiTgNwFsRvIdVnrURM,2020
4
4
  watchmen_collector_kernel/cache/collector_cache_service.py,sha256=Zktnbkj5KtGzYiQo3_tNldYr24Ir6vyhGm4Cgc_Gz9k,905
5
5
  watchmen_collector_kernel/cache/collector_topic_cache.py,sha256=jpr6-T4ETH5Oi7RIrGm9jWdfaNbSCYdz8bgG6Sap4Lw,1191
6
6
  watchmen_collector_kernel/cache/model_config_cache.py,sha256=WW2PmILHm0WbC9gr73uIq1B-poGx78Xpf1w9WEZLbJ8,1906
7
7
  watchmen_collector_kernel/cache/module_config_cache.py,sha256=lGx-eIZLcLTa1RiH_kGU8soU1ilcfbE6KrYixim4Uhw,1393
8
- watchmen_collector_kernel/cache/table_config_cache.py,sha256=oOjyatujD-J6hFcj42hxdmMhZylRdj8v5UXypTcqJQE,4390
8
+ watchmen_collector_kernel/cache/table_config_cache.py,sha256=dM0dU7_3NpqmShiILiaU3EYaBBfDDoWFwfr3OR7Tpzo,3120
9
9
  watchmen_collector_kernel/common/__init__.py,sha256=KCifKsnn6NPHkUMSq2q__fL9aWg52eK35a_mIfLKYRM,627
10
10
  watchmen_collector_kernel/common/constants.py,sha256=mBc0dVjMXKp2pluN2HMNcArcOWvycNzLNu7zcZO0Eao,320
11
11
  watchmen_collector_kernel/common/exception.py,sha256=AY4JAL0fBP6fAkgT7bfMTABp3x3oYtvV5vdPO5jI6S4,49
12
- watchmen_collector_kernel/common/settings.py,sha256=h5k9PDhd5QG-iDTTXLPFmVXNeaV9-eFZdiIZyfqCr_A,2012
13
- watchmen_collector_kernel/model/__init__.py,sha256=7FUgGxozQ3TMHBllZmds7g6nQbN2H6fID8cCLED7u04,845
14
- watchmen_collector_kernel/model/change_data_json.py,sha256=ckCj2vvDoZCWryYE8lGjJnZ_WEfynsVrL2RvmKA2IUk,530
12
+ watchmen_collector_kernel/common/settings.py,sha256=ckkes4rBObImsWaUaJak6msowSsrAAtGXa8EupQtNHk,1949
13
+ watchmen_collector_kernel/model/__init__.py,sha256=nyF4heHswdII2Gw4Kp70AhbknxjmNHRk4wyCcVcYrVU,857
14
+ watchmen_collector_kernel/model/change_data_json.py,sha256=8i-69zBdjaEa3OAtzOpy40g-mCer2stDV_mN5I2t6Mc,880
15
15
  watchmen_collector_kernel/model/change_data_json_history.py,sha256=L9ACRe5tCP5Pc5MrpAVkLHe-6EfgZsUBfnQ2BXIYu4M,99
16
16
  watchmen_collector_kernel/model/change_data_record.py,sha256=zZe_QaYGg6JQRhjtX5dLZ5TIb6vok0G7fdtmWZvTDpo,355
17
17
  watchmen_collector_kernel/model/change_data_record_history.py,sha256=87XLw51oT8TXDRbQLWKy4U1Tyn3KtM22G5wPlMSYCv8,106
18
- watchmen_collector_kernel/model/collector_model_config.py,sha256=t31ZWoe_ITeemrzEaXtHVPiuK_n-jiHG9UlpqjxPS4s,322
19
- watchmen_collector_kernel/model/collector_module_config.py,sha256=0knkFhBdx4gpRXMfrnNWJlmuKMxqC643TJ8-fYDr1nA,250
20
- watchmen_collector_kernel/model/collector_table_config.py,sha256=apxZRQmLEMsVK3Z8KnAUy61LRSITDhTEs1EVNTvC-M0,3266
18
+ watchmen_collector_kernel/model/collector_model_config.py,sha256=MtbfugwwB_In04Wgi1ndSuj9udGgdtfASaS-0lxOpaM,460
19
+ watchmen_collector_kernel/model/collector_module_config.py,sha256=l_6OcMheFycz1o51-qdxzySCmQ_wgJRAv788EcriOew,320
20
+ watchmen_collector_kernel/model/collector_table_config.py,sha256=eMvF_g4obnQqNh9_AUfcP9RYTxmf1dzXasDC3GdrzBg,3548
21
21
  watchmen_collector_kernel/model/competitive_lock.py,sha256=fxDRuzZpsgrZjGeuADS3zRYqQioqWhg72Pr592U_Yvw,264
22
- watchmen_collector_kernel/model/condition.py,sha256=I0QSsz1pP2DRKsgfjw_M7Z_seaPFfzOCvlg6Ud2Te0s,1603
23
- watchmen_collector_kernel/model/scheduled_task.py,sha256=xJCSzo95mXItOsoLJ0Uglh-FmWR4MFeouTLtlxDdLtw,1552
22
+ watchmen_collector_kernel/model/condition.py,sha256=DN7AxbaOPNJ4peiMQpsBeLR_waD9cAl_FJtfzHGJ_G4,1615
23
+ watchmen_collector_kernel/model/scheduled_task.py,sha256=mMgCmPbUZOE2YDQ1gC0dsOx6-6KFJx58LZ2L71NSEe0,1843
24
24
  watchmen_collector_kernel/model/scheduled_task_history.py,sha256=0lgWIQWN2r_HcMoLGwKxzLmaxGNtr0NZF7NaT_DeOyE,93
25
25
  watchmen_collector_kernel/model/status.py,sha256=7JgTF8SZJIKH0acwzJdFCAaW3O2g_dpH0wcnN6DNVjU,210
26
- watchmen_collector_kernel/model/trigger_event.py,sha256=vERU5ebEAy_2d7Au6WAEkpszou9Svb9tnk4rjMMKEOk,479
26
+ watchmen_collector_kernel/model/trigger_event.py,sha256=zlJp3_eisMftMTE1qX9Y40aDiTpVryokGZHWsP5EO54,1607
27
27
  watchmen_collector_kernel/model/trigger_model.py,sha256=LGhtT8xmeDGB1UivAiaQ9FaHYYkaIjKztRUIuyHGBes,213
28
28
  watchmen_collector_kernel/model/trigger_module.py,sha256=LVhhS-tD5Gl7GLxKDmadSYJxkSJYwlKrlnl93h4-yZQ,193
29
29
  watchmen_collector_kernel/model/trigger_table.py,sha256=5ARZAJ9W5qTnvlH0Zsx4NZ8bYUqWauiZxY63M9-JTYk,251
@@ -36,10 +36,10 @@ watchmen_collector_kernel/service/extract_utils.py,sha256=pmeUKc9dret_mfjqbaBDJt
36
36
  watchmen_collector_kernel/service/lock_helper.py,sha256=rr37IFj80OAPdP7TBhGLdmG8hSOkm_L6r6RTmJxNNbw,925
37
37
  watchmen_collector_kernel/service/model_config_service.py,sha256=1tFd_MUldwl37JyRJF4FX6ywmFQ2caFYfslAlqnv2Jk,2235
38
38
  watchmen_collector_kernel/service/module_config_service.py,sha256=M4Mn45WEV9rllpX4A9LhtVE7VjBo-Q9LrHnR4_U2UYA,2027
39
- watchmen_collector_kernel/service/table_config_service.py,sha256=1jmaaOEM0ETRrTDGgGK7S9SCX85bPIP_jJ2zqsHH4DU,3962
39
+ watchmen_collector_kernel/service/table_config_service.py,sha256=oqMKWQj2Fskp9AvLSqbOAmXOB-PfQMi4WmC48BCnsXY,3461
40
40
  watchmen_collector_kernel/service/task_service.py,sha256=7bKbRmHwyWRV6cff8V9rfVlf8EXa2DidVlocuVaHGpc,4705
41
- watchmen_collector_kernel/service/trigger_collector.py,sha256=p07SEQsfrBYIT02Ea5w9R70Yh7NAMC1TlFnn7hn79-o,10852
42
- watchmen_collector_kernel/service/trigger_event_helper.py,sha256=l01bMQrHM-bij4_S0vdzHDuERaTZ4PFo7jQQMRw7dTc,17784
41
+ watchmen_collector_kernel/service/trigger_collector.py,sha256=bb_SIW8FMcj_zUId5zApnHIEH6fQy9vK1bNdwJE6_qA,10847
42
+ watchmen_collector_kernel/service/trigger_event_helper.py,sha256=7HYYIDrG10plDvhYVG1YDDl33GjKkSVrwawlE0pr0aE,17598
43
43
  watchmen_collector_kernel/storage/__init__.py,sha256=064rAoXd3IkhPL6aVisW4BGYImKItD6h3btXsHkrBZo,1369
44
44
  watchmen_collector_kernel/storage/change_data_json_history_service.py,sha256=8WPdazvG6EPTOtmiAXtb1yAMRwUaBmD-C6S0ZwsCMrw,1774
45
45
  watchmen_collector_kernel/storage/change_data_json_service.py,sha256=ILEqtAs2vQzfzEtMd7w6lMkmHbf-hQa9f0GpWhcbXTo,12611
@@ -51,11 +51,11 @@ watchmen_collector_kernel/storage/collector_table_config_service.py,sha256=PcXEg
51
51
  watchmen_collector_kernel/storage/competitive_lock_service.py,sha256=SIXpoeRP1S88ZQJy_-iZgGV9HTJwwM5r3vJn7J9WJbU,3154
52
52
  watchmen_collector_kernel/storage/scheduled_task_history_service.py,sha256=f-JXZ5G87oy7FdYPkbbfTKhI_oRm4wauWNvTw9hxGjM,1586
53
53
  watchmen_collector_kernel/storage/scheduled_task_service.py,sha256=PGH8Qz8nDtUEBIqrKkItjQWSM7cFh13_fkdptdztE14,10906
54
- watchmen_collector_kernel/storage/trigger_event_service.py,sha256=pQwfrwt6-6qkJvorO28dTR7cGuvcmvFQUMPUfTujjWg,6836
54
+ watchmen_collector_kernel/storage/trigger_event_service.py,sha256=8fnz2T2FB2QFa24YJYITcoSsG4AkCnl7H3u7rDC7Wcs,7361
55
55
  watchmen_collector_kernel/storage/trigger_model_service.py,sha256=FE_88sYzh9ibUS1bOyDmGvryfPQraqkMbZc3BKtzfpI,3760
56
56
  watchmen_collector_kernel/storage/trigger_module_service.py,sha256=Ca4J8vnBzS90qP3ljwDJ7lt6MzaOushGjoFRwsSKfHI,3377
57
57
  watchmen_collector_kernel/storage/trigger_table_service.py,sha256=TRAFknaX6IW8lX7dMCR4y_3yjA2bYFFH1HdwW21--Kc,3915
58
- watchmen_collector_kernel-17.0.3.dist-info/LICENSE,sha256=iuuG7ErblOdcEZi5u89VXS0VIUiTb4flerGp_PAS9E4,1061
59
- watchmen_collector_kernel-17.0.3.dist-info/METADATA,sha256=W_ARkRSuSjWkdFMXnoQX_l2J3CsSMr_sv57k-UF_ehc,1075
60
- watchmen_collector_kernel-17.0.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
61
- watchmen_collector_kernel-17.0.3.dist-info/RECORD,,
58
+ watchmen_collector_kernel-17.1.0.dist-info/LICENSE,sha256=iuuG7ErblOdcEZi5u89VXS0VIUiTb4flerGp_PAS9E4,1061
59
+ watchmen_collector_kernel-17.1.0.dist-info/METADATA,sha256=A8eL6jRJ6yInrt8ppeYSBIEVH4oJ_aVVrORdibNXC68,1075
60
+ watchmen_collector_kernel-17.1.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
61
+ watchmen_collector_kernel-17.1.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: poetry-core 1.9.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any