-
Notifications
You must be signed in to change notification settings - Fork 90
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
Using Request.Sessions for faster and less open connections #923
Changes from 3 commits
64e580f
b5d658c
892f2b7
b74c26b
db51072
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -130,6 +130,7 @@ def get_indexes(self, parameters: Optional[Mapping[str, Any]] = None) -> Dict[st | |||||
index["primaryKey"], | ||||||
index["createdAt"], | ||||||
index["updatedAt"], | ||||||
self.http, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
) | ||||||
for index in response["results"] | ||||||
] | ||||||
|
@@ -178,7 +179,7 @@ def get_index(self, uid: str) -> Index: | |||||
MeilisearchApiError | ||||||
An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://www.meilisearch.com/docs/reference/errors/error_codes#meilisearch-errors | ||||||
""" | ||||||
return Index(self.config, uid).fetch_info() | ||||||
return Index(self.config, uid, http=self.http).fetch_info() | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
def get_raw_index(self, uid: str) -> Dict[str, Any]: | ||||||
"""Get the index as a dictionary. | ||||||
|
@@ -216,7 +217,7 @@ def index(self, uid: str) -> Index: | |||||
An Index instance. | ||||||
""" | ||||||
if uid is not None: | ||||||
return Index(self.config, uid=uid) | ||||||
return Index(self.config, uid=uid, http=self.http) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
raise ValueError("The index UID should not be None") | ||||||
|
||||||
def multi_search(self, queries: Sequence[Mapping[str, Any]]) -> Dict[str, List[Dict[str, Any]]]: | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -31,6 +31,7 @@ def __init__( | |||||
primary_key: Optional[str] = None, | ||||||
created_at: Optional[Union[datetime, str]] = None, | ||||||
updated_at: Optional[Union[datetime, str]] = None, | ||||||
http: Optional[HttpRequests] = None, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since session also needs to be added to the docstring
Suggested change
|
||||||
) -> None: | ||||||
""" | ||||||
Parameters | ||||||
|
@@ -43,7 +44,7 @@ def __init__( | |||||
Primary-key of the index. | ||||||
""" | ||||||
self.config = config | ||||||
self.http = HttpRequests(config) | ||||||
self.http = http if http is not None else HttpRequests(config) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
self.task_handler = TaskHandler(config) | ||||||
self.uid = uid | ||||||
self.primary_key = primary_key | ||||||
|
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.
And add
session: Session
to the__init__
parameters.