Skip to content

Added LagAwareHealthCheck for MultiDBClient #3737

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

Open
wants to merge 8 commits into
base: feat/active-active
Choose a base branch
from

Conversation

vladvildanov
Copy link
Collaborator

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

Please provide a description of the change here.

self,
path: str,
*,
params: Optional[Mapping[str, Union[str, int, float, bool, None, list, tuple]]] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Union should be Optional.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But within Union we already define None, value could be anything including None

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional makes sense if it's either one value or None. But we have a Union of multiple values including None

auth_basic: Optional[Tuple[str, str]] = None, # (username, password)
user_agent: str = DEFAULT_USER_AGENT,
) -> None:
self.base_url = base_url.rstrip("/") + "/" if base_url and not base_url.endswith("/") else base_url
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you call rstrip to remove the slash - in this case, you have already checked that the url doesn't end with a slash? Maybe here the rstrip + adding a single slash should be used when the url end with a slash - to ensure that it is only one slash..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. It doesn't makes sense to me to check for double-backslash, but I removed rstrip for backslash

self,
path: str,
*,
params: Optional[Mapping[str, Union[str, int, float, bool, None, list, tuple]]] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

*,
json_body: Any = None,
data: Optional[Union[bytes, str]] = None,
params: Optional[Mapping[str, Union[str, int, float, bool, None, list, tuple]]] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Union --> Optional[Union[...]]

return resp.json()
return resp

def _prepare_body(self, *, json_body: Any = None, data: Optional[Union[bytes, str]] = None) -> Optional[Union[bytes, str]]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a json type defined in redis/commands/json/_util.py. Can't it be reused for more detailed information about the acceptable input format?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's different. JsonType defined there allows to provide values like int, list, float because some commands allows you to append specific values to already existing Json object. In this case we expect a full Json object.

def _build_url(
self,
path: str,
params: Optional[Mapping[str, Union[str, int, float, bool, None, list, tuple]]] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional[Union[...]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants