Fix: typos. (#526)
* Fix: typo. Signed-off-by: dblock <dblock@amazon.com> * Fix: typo. Signed-off-by: dblock <dblock@amazon.com> * Fixed its. Signed-off-by: dblock <dblock@amazon.com> * Added Visual Code settings to .gitignore. Signed-off-by: dblock <dblock@amazon.com> * Added loop type for async client. Signed-off-by: dblock <dblock@amazon.com> --------- Signed-off-by: dblock <dblock@amazon.com>
This commit is contained in:
committed by
GitHub
parent
49c2f6e87d
commit
2bfc409177
+4
-1
@@ -148,6 +148,9 @@ test_opensearch/cover
|
|||||||
test_opensearch/local.py
|
test_opensearch/local.py
|
||||||
.ci/output
|
.ci/output
|
||||||
|
|
||||||
#Vi text editor
|
# vi text editor
|
||||||
.*.swp
|
.*.swp
|
||||||
*~
|
*~
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
|
.vscode
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from asyncio import AbstractEventLoop
|
||||||
from typing import Any, Collection, Mapping, Optional, Tuple, Union
|
from typing import Any, Collection, Mapping, Optional, Tuple, Union
|
||||||
|
|
||||||
from ..connection import Connection
|
from ..connection import Connection
|
||||||
@@ -65,7 +66,7 @@ class AIOHttpConnection(AsyncConnection):
|
|||||||
ssl_context: Optional[Any] = ...,
|
ssl_context: Optional[Any] = ...,
|
||||||
http_compress: Optional[bool] = ...,
|
http_compress: Optional[bool] = ...,
|
||||||
opaque_id: Optional[str] = ...,
|
opaque_id: Optional[str] = ...,
|
||||||
loop: Any = ...,
|
loop: Optional[AbstractEventLoop] = ...,
|
||||||
trust_env: bool = ...,
|
trust_env: bool = ...,
|
||||||
**kwargs: Any
|
**kwargs: Any
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
|||||||
@@ -343,14 +343,14 @@ class AsyncTransport(Transport):
|
|||||||
async def perform_request(self, method, url, headers=None, params=None, body=None):
|
async def perform_request(self, method, url, headers=None, params=None, body=None):
|
||||||
"""
|
"""
|
||||||
Perform the actual request. Retrieve a connection from the connection
|
Perform the actual request. Retrieve a connection from the connection
|
||||||
pool, pass all the information to it's perform_request method and
|
pool, pass all the information to its perform_request method and
|
||||||
return the data.
|
return the data.
|
||||||
|
|
||||||
If an exception was raised, mark the connection as failed and retry (up
|
If an exception was raised, mark the connection as failed and retry (up
|
||||||
to `max_retries` times).
|
to `max_retries` times).
|
||||||
|
|
||||||
If the operation was successful and the connection used was previously
|
If the operation was successful and the connection used was previously
|
||||||
marked as dead, mark it as live, resetting it's failure count.
|
marked as dead, mark it as live, resetting its failure count.
|
||||||
|
|
||||||
:arg method: HTTP method to use
|
:arg method: HTTP method to use
|
||||||
:arg url: absolute url (without host) to target
|
:arg url: absolute url (without host) to target
|
||||||
@@ -412,7 +412,7 @@ class AsyncTransport(Transport):
|
|||||||
raise e
|
raise e
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# connection didn't fail, confirm it's live status
|
# connection didn't fail, confirm its live status
|
||||||
self.connection_pool.mark_live(connection)
|
self.connection_pool.mark_live(connection)
|
||||||
|
|
||||||
if method == "HEAD":
|
if method == "HEAD":
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ _WARNING_RE = re.compile(r"\"([^\"]*)\"")
|
|||||||
class Connection(object):
|
class Connection(object):
|
||||||
"""
|
"""
|
||||||
Class responsible for maintaining a connection to an OpenSearch node. It
|
Class responsible for maintaining a connection to an OpenSearch node. It
|
||||||
holds persistent connection pool to it and it's main interface
|
holds persistent connection pool to it and its main interface
|
||||||
(`perform_request`) is thread-safe.
|
(`perform_request`) is thread-safe.
|
||||||
|
|
||||||
Also responsible for logging.
|
Also responsible for logging.
|
||||||
@@ -158,7 +158,7 @@ class Connection(object):
|
|||||||
# Format is: '(number) OpenSearch-(version)-(instance) "(message)"'
|
# Format is: '(number) OpenSearch-(version)-(instance) "(message)"'
|
||||||
warning_messages = []
|
warning_messages = []
|
||||||
for header in warning_headers:
|
for header in warning_headers:
|
||||||
# Because 'Requests' does it's own folding of multiple HTTP headers
|
# Because 'Requests' does its own folding of multiple HTTP headers
|
||||||
# into one header delimited by commas (totally standard compliant, just
|
# into one header delimited by commas (totally standard compliant, just
|
||||||
# annoying for cases like this) we need to expect there may be
|
# annoying for cases like this) we need to expect there may be
|
||||||
# more than one message per 'Warning' header.
|
# more than one message per 'Warning' header.
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ class ConnectionSelector(object):
|
|||||||
process it will be the dictionary returned by the `host_info_callback`.
|
process it will be the dictionary returned by the `host_info_callback`.
|
||||||
|
|
||||||
Example of where this would be useful is a zone-aware selector that would
|
Example of where this would be useful is a zone-aware selector that would
|
||||||
only select connections from it's own zones and only fall back to other
|
only select connections from its own zones and only fall back to other
|
||||||
connections where there would be none in it's zones.
|
connections where there would be none in its zones.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, opts):
|
def __init__(self, opts):
|
||||||
@@ -112,7 +112,7 @@ class ConnectionPool(object):
|
|||||||
future reference.
|
future reference.
|
||||||
|
|
||||||
Upon each request the `Transport` will ask for a `Connection` via the
|
Upon each request the `Transport` will ask for a `Connection` via the
|
||||||
`get_connection` method. If the connection fails (it's `perform_request`
|
`get_connection` method. If the connection fails (its `perform_request`
|
||||||
raises a `ConnectionError`) it will be marked as dead (via `mark_dead`) and
|
raises a `ConnectionError`) it will be marked as dead (via `mark_dead`) and
|
||||||
put on a timeout (if it fails N times in a row the timeout is exponentially
|
put on a timeout (if it fails N times in a row the timeout is exponentially
|
||||||
longer - the formula is `default_timeout * 2 ** (fail_count - 1)`). When
|
longer - the formula is `default_timeout * 2 ** (fail_count - 1)`). When
|
||||||
@@ -132,7 +132,7 @@ class ConnectionPool(object):
|
|||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
:arg connections: list of tuples containing the
|
:arg connections: list of tuples containing the
|
||||||
:class:`~opensearchpy.Connection` instance and it's options
|
:class:`~opensearchpy.Connection` instance and its options
|
||||||
:arg dead_timeout: number of seconds a connection should be retired for
|
:arg dead_timeout: number of seconds a connection should be retired for
|
||||||
after a failure, increases on consecutive failures
|
after a failure, increases on consecutive failures
|
||||||
:arg timeout_cutoff: number of consecutive failures after which the
|
:arg timeout_cutoff: number of consecutive failures after which the
|
||||||
@@ -211,7 +211,7 @@ class ConnectionPool(object):
|
|||||||
def resurrect(self, force=False):
|
def resurrect(self, force=False):
|
||||||
"""
|
"""
|
||||||
Attempt to resurrect a connection from the dead pool. It will try to
|
Attempt to resurrect a connection from the dead pool. It will try to
|
||||||
locate one (not all) eligible (it's timeout is over) connection to
|
locate one (not all) eligible (its timeout is over) connection to
|
||||||
return to the live pool. Any resurrected connection is also returned.
|
return to the live pool. Any resurrected connection is also returned.
|
||||||
|
|
||||||
:arg force: resurrect a connection even if there is none eligible (used
|
:arg force: resurrect a connection even if there is none eligible (used
|
||||||
@@ -245,7 +245,7 @@ class ConnectionPool(object):
|
|||||||
self.dead.put((timeout, connection))
|
self.dead.put((timeout, connection))
|
||||||
return
|
return
|
||||||
|
|
||||||
# either we were forced or the connection is elligible to be retried
|
# either we were forced or the connection is eligible to be retried
|
||||||
self.connections.append(connection)
|
self.connections.append(connection)
|
||||||
logger.info("Resurrecting connection %r (force=%s).", connection, force)
|
logger.info("Resurrecting connection %r (force=%s).", connection, force)
|
||||||
return connection
|
return connection
|
||||||
@@ -259,7 +259,7 @@ class ConnectionPool(object):
|
|||||||
no connections are available and passes the list of live connections to
|
no connections are available and passes the list of live connections to
|
||||||
the selector instance to choose from.
|
the selector instance to choose from.
|
||||||
|
|
||||||
Returns a connection instance and it's current fail count.
|
Returns a connection instance and its current fail count.
|
||||||
"""
|
"""
|
||||||
self.resurrect()
|
self.resurrect()
|
||||||
connections = self.connections[:]
|
connections = self.connections[:]
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ class DslMeta(type):
|
|||||||
|
|
||||||
It then uses the information from that registry (as well as `name` and
|
It then uses the information from that registry (as well as `name` and
|
||||||
`shortcut` attributes from the base class) to construct any subclass based
|
`shortcut` attributes from the base class) to construct any subclass based
|
||||||
on it's name.
|
on its name.
|
||||||
|
|
||||||
For typical use see `QueryMeta` and `Query` in `opensearchpy.query`.
|
For typical use see `QueryMeta` and `Query` in `opensearchpy.query`.
|
||||||
"""
|
"""
|
||||||
@@ -235,7 +235,7 @@ class DslMeta(type):
|
|||||||
if not hasattr(cls, "_type_shortcut"):
|
if not hasattr(cls, "_type_shortcut"):
|
||||||
return
|
return
|
||||||
if cls.name is None:
|
if cls.name is None:
|
||||||
# abstract base class, register it's shortcut
|
# abstract base class, register its shortcut
|
||||||
cls._types[cls._type_name] = cls._type_shortcut
|
cls._types[cls._type_name] = cls._type_shortcut
|
||||||
# and create a registry for subclasses
|
# and create a registry for subclasses
|
||||||
if not hasattr(cls, "_classes"):
|
if not hasattr(cls, "_classes"):
|
||||||
@@ -264,7 +264,7 @@ class DslBase(object):
|
|||||||
- to_dict method to serialize into dict (to be sent via opensearch-py)
|
- to_dict method to serialize into dict (to be sent via opensearch-py)
|
||||||
- basic logical operators (&, | and ~) using a Bool(Filter|Query) TODO:
|
- basic logical operators (&, | and ~) using a Bool(Filter|Query) TODO:
|
||||||
move into a class specific for Query/Filter
|
move into a class specific for Query/Filter
|
||||||
- respects the definition of the class and (de)serializes it's
|
- respects the definition of the class and (de)serializes its
|
||||||
attributes based on the `_param_defs` definition (for example turning
|
attributes based on the `_param_defs` definition (for example turning
|
||||||
all values in the `must` attribute into Query objects)
|
all values in the `must` attribute into Query objects)
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -341,14 +341,14 @@ class Transport(object):
|
|||||||
def perform_request(self, method, url, headers=None, params=None, body=None):
|
def perform_request(self, method, url, headers=None, params=None, body=None):
|
||||||
"""
|
"""
|
||||||
Perform the actual request. Retrieve a connection from the connection
|
Perform the actual request. Retrieve a connection from the connection
|
||||||
pool, pass all the information to it's perform_request method and
|
pool, pass all the information to its perform_request method and
|
||||||
return the data.
|
return the data.
|
||||||
|
|
||||||
If an exception was raised, mark the connection as failed and retry (up
|
If an exception was raised, mark the connection as failed and retry (up
|
||||||
to `max_retries` times).
|
to `max_retries` times).
|
||||||
|
|
||||||
If the operation was successful and the connection used was previously
|
If the operation was successful and the connection used was previously
|
||||||
marked as dead, mark it as live, resetting it's failure count.
|
marked as dead, mark it as live, resetting its failure count.
|
||||||
|
|
||||||
:arg method: HTTP method to use
|
:arg method: HTTP method to use
|
||||||
:arg url: absolute url (without host) to target
|
:arg url: absolute url (without host) to target
|
||||||
@@ -409,7 +409,7 @@ class Transport(object):
|
|||||||
raise e
|
raise e
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# connection didn't fail, confirm it's live status
|
# connection didn't fail, confirm its live status
|
||||||
self.connection_pool.mark_live(connection)
|
self.connection_pool.mark_live(connection)
|
||||||
|
|
||||||
if method == "HEAD":
|
if method == "HEAD":
|
||||||
|
|||||||
@@ -947,7 +947,7 @@ DATA = [
|
|||||||
],
|
],
|
||||||
"committer": {"name": "Honza Kr\xe1l", "email": "honza.kral@gmail.com"},
|
"committer": {"name": "Honza Kr\xe1l", "email": "honza.kral@gmail.com"},
|
||||||
"stats": {"deletions": 0, "insertions": 53, "lines": 53, "files": 2},
|
"stats": {"deletions": 0, "insertions": 53, "lines": 53, "files": 2},
|
||||||
"description": "From_dict, Q(dict) and bool query parses it's subqueries",
|
"description": "From_dict, Q(dict) and bool query parses its subqueries",
|
||||||
"author": {"name": "Honza Kr\xe1l", "email": "honza.kral@gmail.com"},
|
"author": {"name": "Honza Kr\xe1l", "email": "honza.kral@gmail.com"},
|
||||||
"parent_shas": ["d407f99d1959b7b862a541c066d9fd737ce913f3"],
|
"parent_shas": ["d407f99d1959b7b862a541c066d9fd737ce913f3"],
|
||||||
"committed_date": "2014-03-06T20:24:30",
|
"committed_date": "2014-03-06T20:24:30",
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class TestAlertingPlugin(AsyncOpenSearchTestCase):
|
|||||||
# Create a dummy monitor
|
# Create a dummy monitor
|
||||||
await self.test_create_monitor()
|
await self.test_create_monitor()
|
||||||
|
|
||||||
# Create a monitor search query by it's name
|
# Create a monitor search query by its name
|
||||||
query = {"query": {"match": {"monitor.name": "test-monitor"}}}
|
query = {"query": {"match": {"monitor.name": "test-monitor"}}}
|
||||||
|
|
||||||
# Perform the search with the above query
|
# Perform the search with the above query
|
||||||
@@ -145,7 +145,7 @@ class TestAlertingPlugin(AsyncOpenSearchTestCase):
|
|||||||
# Create a dummy monitor
|
# Create a dummy monitor
|
||||||
await self.test_create_monitor()
|
await self.test_create_monitor()
|
||||||
|
|
||||||
# Create a monitor search query by it's name
|
# Create a monitor search query by its name
|
||||||
query = {"query": {"match": {"monitor.name": "test-monitor"}}}
|
query = {"query": {"match": {"monitor.name": "test-monitor"}}}
|
||||||
|
|
||||||
# Perform the search with the above query
|
# Perform the search with the above query
|
||||||
@@ -169,7 +169,7 @@ class TestAlertingPlugin(AsyncOpenSearchTestCase):
|
|||||||
# Create a dummy monitor
|
# Create a dummy monitor
|
||||||
await self.test_create_monitor()
|
await self.test_create_monitor()
|
||||||
|
|
||||||
# Create a monitor search query by it's name
|
# Create a monitor search query by its name
|
||||||
query = {"query": {"match": {"monitor.name": "test-monitor"}}}
|
query = {"query": {"match": {"monitor.name": "test-monitor"}}}
|
||||||
|
|
||||||
# Perform the search with the above query
|
# Perform the search with the above query
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Dynamically generated set of TestCases based on set of yaml files decribing
|
Dynamically generated set of TestCases based on set of yaml files describing
|
||||||
some integration tests. These files are shared among all official OpenSearch
|
some integration tests. These files are shared among all official OpenSearch
|
||||||
clients.
|
clients.
|
||||||
"""
|
"""
|
||||||
@@ -106,7 +106,7 @@ class AsyncYamlRunner(YamlRunner):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
async def run_code(self, test):
|
async def run_code(self, test):
|
||||||
"""Execute an instruction based on it's type."""
|
"""Execute an instruction based on its type."""
|
||||||
for action in test:
|
for action in test:
|
||||||
assert len(action) == 1
|
assert len(action) == 1
|
||||||
action_type, action = list(action.items())[0]
|
action_type, action = list(action.items())[0]
|
||||||
@@ -126,7 +126,7 @@ class AsyncYamlRunner(YamlRunner):
|
|||||||
assert len(action) == 1
|
assert len(action) == 1
|
||||||
|
|
||||||
# Remove the x_pack_rest_user authentication
|
# Remove the x_pack_rest_user authentication
|
||||||
# if it's given via headers. We're already authenticated
|
# if its given via headers. We're already authenticated
|
||||||
# via the 'elastic' user.
|
# via the 'elastic' user.
|
||||||
if (
|
if (
|
||||||
headers
|
headers
|
||||||
|
|||||||
@@ -964,7 +964,7 @@ DATA = [
|
|||||||
],
|
],
|
||||||
"committer": {"name": "Honza Kr\xe1l", "email": "honza.kral@gmail.com"},
|
"committer": {"name": "Honza Kr\xe1l", "email": "honza.kral@gmail.com"},
|
||||||
"stats": {"deletions": 0, "insertions": 53, "lines": 53, "files": 2},
|
"stats": {"deletions": 0, "insertions": 53, "lines": 53, "files": 2},
|
||||||
"description": "From_dict, Q(dict) and bool query parses it's subqueries",
|
"description": "From_dict, Q(dict) and bool query parses its subqueries",
|
||||||
"author": {"name": "Honza Kr\xe1l", "email": "honza.kral@gmail.com"},
|
"author": {"name": "Honza Kr\xe1l", "email": "honza.kral@gmail.com"},
|
||||||
"parent_shas": ["d407f99d1959b7b862a541c066d9fd737ce913f3"],
|
"parent_shas": ["d407f99d1959b7b862a541c066d9fd737ce913f3"],
|
||||||
"committed_date": "2014-03-06T20:24:30",
|
"committed_date": "2014-03-06T20:24:30",
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class TestAlertingPlugin(OpenSearchTestCase):
|
|||||||
# Create a dummy monitor
|
# Create a dummy monitor
|
||||||
self.test_create_monitor()
|
self.test_create_monitor()
|
||||||
|
|
||||||
# Create a monitor search query by it's name
|
# Create a monitor search query by its name
|
||||||
query = {"query": {"match": {"monitor.name": "test-monitor"}}}
|
query = {"query": {"match": {"monitor.name": "test-monitor"}}}
|
||||||
|
|
||||||
# Perform the search with the above query
|
# Perform the search with the above query
|
||||||
@@ -141,7 +141,7 @@ class TestAlertingPlugin(OpenSearchTestCase):
|
|||||||
# Create a dummy monitor
|
# Create a dummy monitor
|
||||||
self.test_create_monitor()
|
self.test_create_monitor()
|
||||||
|
|
||||||
# Create a monitor search query by it's name
|
# Create a monitor search query by its name
|
||||||
query = {"query": {"match": {"monitor.name": "test-monitor"}}}
|
query = {"query": {"match": {"monitor.name": "test-monitor"}}}
|
||||||
|
|
||||||
# Perform the search with the above query
|
# Perform the search with the above query
|
||||||
@@ -165,7 +165,7 @@ class TestAlertingPlugin(OpenSearchTestCase):
|
|||||||
# Create a dummy monitor
|
# Create a dummy monitor
|
||||||
self.test_create_monitor()
|
self.test_create_monitor()
|
||||||
|
|
||||||
# Create a monitor search query by it's name
|
# Create a monitor search query by its name
|
||||||
query = {"query": {"match": {"monitor.name": "test-monitor"}}}
|
query = {"query": {"match": {"monitor.name": "test-monitor"}}}
|
||||||
|
|
||||||
# Perform the search with the above query
|
# Perform the search with the above query
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ class YamlRunner:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def run_code(self, test):
|
def run_code(self, test):
|
||||||
"""Execute an instruction based on it's type."""
|
"""Execute an instruction based on its type."""
|
||||||
for action in test:
|
for action in test:
|
||||||
assert len(action) == 1
|
assert len(action) == 1
|
||||||
action_type, action = list(action.items())[0]
|
action_type, action = list(action.items())[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user