-
Notifications
You must be signed in to change notification settings - Fork 15
feat: srw #1048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
aws_advanced_python_wrapper/simple_read_write_splitting_plugin.py
Outdated
Show resolved
Hide resolved
| ... | ||
|
|
||
| def is_reader_host(self, current_host: HostInfo) -> bool: | ||
| """Return true if the current host fits the criteria of a writer host.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| """Return true if the current host fits the criteria of a writer host.""" | |
| """Return true if the current host fits the criteria of a reader host.""" |
| def old_reader_can_be_used(self, reader_host_info: HostInfo) -> bool: | ||
| """Return true if the current host can be used to switch connection to.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we only pass a reader host into this method but there's no logic specific to readers. I don't think this method needs to know whether the host info is new or old, writer or reader.
| def old_reader_can_be_used(self, reader_host_info: HostInfo) -> bool: | |
| """Return true if the current host can be used to switch connection to.""" | |
| def can_host_be_used(self, host_info: HostInfo) -> bool: | |
| """Returns true if connections can be switched to the given host""" |
| def need_connect_to_writer(self) -> bool: | ||
| """Return true if switching to reader should instead connect to writer.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would make things a bit clearer
| def need_connect_to_writer(self) -> bool: | |
| """Return true if switching to reader should instead connect to writer.""" | |
| def has_no_readers(self) -> bool: | |
| """Return true if there are no readers in the host list""" |
| WrapperProperties.SRW_CONNECT_RETRY_INTERVAL_MS, props, int, lambda x: x > 0 | ||
| ) | ||
|
|
||
| self._verify_opened_connection_type: Optional[HostRole] = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will make it clearer that this is for initial connections, not subsequent connection switches
| self._verify_opened_connection_type: Optional[HostRole] = ( | |
| self._verify_initial_connection_type: Optional[HostRole] = ( |
| try: | ||
| if connect_func is not None: | ||
| candidate_conn = connect_func() | ||
| elif host_info is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this check necessary if host_info is not Optional? Or should host_info be of type Optional[HostInfo]?
| sleep(self._connect_retry_interval_ms / 1000) | ||
|
|
||
| @staticmethod | ||
| def _parse_connection_type(phase_str: Optional[str]) -> HostRole: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use the word "phase"? would "expected_role" work?
| def _parse_connection_type(phase_str: Optional[str]) -> HostRole: | |
| def _parse_role(role_str: Optional[str]) -> HostRole: |
| if not phase_str: | ||
| return HostRole.UNKNOWN | ||
|
|
||
| phase_upper = phase_str.lower() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| phase_upper = phase_str.lower() | |
| phase_lower = phase_str.lower() |
Description
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.