This repository has been archived by the owner on Sep 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AP-813] & [AP-789] make some Log based params configurable (#10)
* Make await time and buffer size configurable in Log based * use pytest-cov plugin * fix makefile * fix datetime conversion * timezone fixes
- Loading branch information
Showing
11 changed files
with
148 additions
and
46 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
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
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,40 @@ | ||
from typing import Dict | ||
|
||
from tap_mongodb.errors import InvalidAwaitTimeError, InvalidUpdateBufferSizeError | ||
from tap_mongodb.sync_strategies import change_streams | ||
|
||
|
||
def validate_config(config: Dict) -> None: | ||
""" | ||
Goes through the config and validate it | ||
Currently, only few parameters are validated | ||
Args: | ||
config: Dictionary of config to validate | ||
Returns: None | ||
Raises: InvalidUpdateBufferSizeError or InvalidAwaitTimeError | ||
""" | ||
if 'update_buffer_size' in config: | ||
update_buffer_size = config['update_buffer_size'] | ||
|
||
if not isinstance(update_buffer_size, int): | ||
raise InvalidUpdateBufferSizeError(update_buffer_size, 'Not integer') | ||
|
||
if not (change_streams.MIN_UPDATE_BUFFER_LENGTH <= | ||
update_buffer_size <= change_streams.MAX_UPDATE_BUFFER_LENGTH): | ||
|
||
raise InvalidUpdateBufferSizeError( | ||
update_buffer_size, | ||
f'Not in the range [{change_streams.MIN_UPDATE_BUFFER_LENGTH}..' | ||
f'{change_streams.MAX_UPDATE_BUFFER_LENGTH}]') | ||
|
||
|
||
if 'await_time_ms' in config: | ||
await_time_ms = config['await_time_ms'] | ||
|
||
if not isinstance(await_time_ms, int): | ||
raise InvalidAwaitTimeError(await_time_ms, 'Not integer') | ||
|
||
if await_time_ms <= 0: | ||
raise InvalidAwaitTimeError( | ||
await_time_ms, 'time must be > 0') |
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
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.