Skip to content
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

Avoid duplicate URL parsing for async connections #958

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions esrally/async_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import aiohttp
from aiohttp.client_exceptions import ServerFingerprintMismatch
import async_timeout
import yarl

from elasticsearch.exceptions import ConnectionError, ConnectionTimeout, ImproperlyConfigured, SSLError
from elasticsearch.connection import Connection
Expand Down Expand Up @@ -97,11 +98,7 @@ def __init__(self, host='localhost', port=9200, http_auth=None,
trace_configs=trace_configs,
response_class=RawClientResponse
)

self.base_url = 'http%s://%s:%d%s' % (
's' if use_ssl else '',
host, port, self.url_prefix
)
self.scheme = "https" if use_ssl else "http"

@asyncio.coroutine
def close(self):
Expand All @@ -111,8 +108,16 @@ def close(self):
def perform_request(self, method, url, params=None, body=None, timeout=None, ignore=(), headers=None):
url_path = url
if params:
url_path = '%s?%s' % (url, urlencode(params or {}))
url = self.base_url + url_path
query_string = urlencode(params)
else:
query_string = ""
# Provide correct URL object to avoid string parsing in low-level code
url = yarl.URL.build(scheme=self.scheme,
host=self.hostname,
port=self.port,
path=url,
query_string=query_string,
encoded=True)

start = self.loop.time()
response = None
Expand Down