-
Notifications
You must be signed in to change notification settings - Fork 4
/
generic.py
37 lines (30 loc) · 1.12 KB
/
generic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from streams_explorer.core.extractor.extractor import ConnectorExtractor
from streams_explorer.models.kafka_connector import (
KafkaConnector,
KafkaConnectorTypesEnum,
)
class GenericSink(ConnectorExtractor):
def on_connector_info_parsing(
self, info: dict, connector_name: str
) -> KafkaConnector | None:
if info["type"] == KafkaConnectorTypesEnum.SINK:
config = info["config"]
return KafkaConnector(
name=connector_name,
config=config,
type=KafkaConnectorTypesEnum.SINK,
)
class GenericSourceConnector(KafkaConnector):
def __init__(self, **kwargs) -> None:
super().__init__(
**kwargs,
type=KafkaConnectorTypesEnum.SOURCE,
)
def get_topics(self) -> list[str]:
return []
class GenericSource(ConnectorExtractor):
def on_connector_info_parsing(
self, info: dict, connector_name: str
) -> KafkaConnector | None:
if info["type"] == KafkaConnectorTypesEnum.SOURCE:
return GenericSourceConnector(name=connector_name, config=info["config"])