-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from guibacellar/48-keep-alive-and-other-signals
48 keep alive and other signals
- Loading branch information
Showing
24 changed files
with
872 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""Signal Entity Mapper.""" | ||
from __future__ import annotations | ||
|
||
from configparser import SectionProxy | ||
from typing import Optional | ||
|
||
from TEx.models.facade.signal_entity_model import SignalEntity | ||
|
||
|
||
class SignalEntityMapper: | ||
"""Signal Entity Mapper.""" | ||
|
||
@staticmethod | ||
def to_entity(section_proxy: Optional[SectionProxy]) -> SignalEntity: | ||
"""Map the Configuration KEEP_ALIVE to Entity.""" | ||
# Build Model | ||
if section_proxy: | ||
return SignalEntity( | ||
enabled=section_proxy.get('enabled', fallback='false') == 'true', | ||
keep_alive_interval=int(section_proxy.get('keep_alive_interval', fallback='0')), | ||
notifiers={ | ||
'KEEP-ALIVE': section_proxy.get('keep_alive_notifer', fallback='').split(','), | ||
'INITIALIZATION': section_proxy.get('initialization_notifer', fallback='').split(','), | ||
'SHUTDOWN': section_proxy.get('shutdown_notifer', fallback='').split(','), | ||
'NEW-GROUP': section_proxy.get('new_group_notifer', fallback='').split(','), | ||
}, | ||
) | ||
|
||
return SignalEntity( | ||
enabled=False, | ||
keep_alive_interval=300, | ||
notifiers={ | ||
'KEEP-ALIVE': [], | ||
'INITIALIZATION': [], | ||
'SHUTDOWN': [], | ||
'NEW-GROUP': [], | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"""Signal Entity.""" | ||
from __future__ import annotations | ||
|
||
from typing import Dict | ||
|
||
from pydantic import BaseModel, ConfigDict | ||
|
||
|
||
class SignalEntity(BaseModel): | ||
"""Signal Entity.""" | ||
|
||
model_config = ConfigDict(extra='forbid') | ||
|
||
enabled: bool | ||
keep_alive_interval: int | ||
notifiers: Dict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"""Facade Entities for Signal based Notifications.""" | ||
from __future__ import annotations | ||
|
||
from datetime import datetime | ||
|
||
from pydantic import BaseModel, ConfigDict | ||
|
||
|
||
class SignalNotificationEntityModel(BaseModel): | ||
"""Facade Entities for Signal based Notifications.""" | ||
|
||
model_config = ConfigDict(extra='forbid') | ||
|
||
signal: str | ||
date_time: datetime | ||
content: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.