Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Renamed internal async module
Browse files Browse the repository at this point in the history
  • Loading branch information
annatisch committed Aug 22, 2018
1 parent 5692cb0 commit c8db793
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 25 deletions.
12 changes: 12 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
Release History
===============

1.0.0 (2018-08-22)
++++++++++++++++++

- API stable.
- Renamed internal `_async` module to `async_ops` for docs generation.
- Added optional `auth_timeout` parameter to `EventHubClient` and `EventHubClientAsync` to configure how long to allow for token
negotiation to complete. Default is 60 seconds.
- Added optional `send_timeout` parameter to `EventHubClient.add_sender` and `EventHubClientAsync.add_async_sender` to determine the
timeout for Events to be successfully sent. Default value is 60 seconds.
- Reformatted logging for performance.


0.2.0 (2018-08-06)
++++++++++++++++++

Expand Down
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ Python 2.7 support
The uAMQP library currently only supports Python 3.4 and above. Python 2.7 support is planned for a future release.


Documentation
+++++++++++++
Reference documentation is available at `docs.microsoft.com/python/api/azure-eventhub <https://docs.microsoft.com/python/api/azure-eventhub>`__.


Examples
+++++++++

Expand Down
4 changes: 2 additions & 2 deletions azure/eventhub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

__version__ = "0.2.0"
__version__ = "1.0.0"

from azure.eventhub.common import EventData, EventHubError, Offset
from azure.eventhub.client import EventHubClient
from azure.eventhub.sender import Sender
from azure.eventhub.receiver import Receiver

try:
from azure.eventhub._async import (
from azure.eventhub.async_ops import (
EventHubClientAsync,
AsyncSender,
AsyncReceiver)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def add_async_receiver(
:operation: An optional operation to be appended to the hostname in the source URL.
The value must start with `/` character.
:type operation: str
:rtype: ~azure.eventhub._async.receiver_async.ReceiverAsync
:rtype: ~azure.eventhub.async_ops.receiver_async.ReceiverAsync
"""
path = self.address.path + operation if operation else self.address.path
source_url = "amqps://{}{}/ConsumerGroups/{}/Partitions/{}".format(
Expand Down Expand Up @@ -214,7 +214,7 @@ def add_async_epoch_receiver(
:operation: An optional operation to be appended to the hostname in the source URL.
The value must start with `/` character.
:type operation: str
:rtype: ~azure.eventhub._async.receiver_async.ReceiverAsync
:rtype: ~azure.eventhub.async_ops.receiver_async.ReceiverAsync
"""
path = self.address.path + operation if operation else self.address.path
source_url = "amqps://{}{}/ConsumerGroups/{}/Partitions/{}".format(
Expand Down Expand Up @@ -249,7 +249,7 @@ def add_async_sender(
:param auto_reconnect: Whether to automatically reconnect the sender if a retryable error occurs.
Default value is `True`.
:type auto_reconnect: bool
:rtype: ~azure.eventhub._async.sender_async.SenderAsync
:rtype: ~azure.eventhub.async_ops.sender_async.SenderAsync
"""
target = "amqps://{}{}".format(self.address.hostname, self.address.path)
if operation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__( # pylint: disable=super-init-not-called
Instantiate an async receiver.
:param client: The parent EventHubClientAsync.
:type client: ~azure.eventhub._async.EventHubClientAsync
:type client: ~azure.eventhub.async_ops.EventHubClientAsync
:param source: The source EventHub from which to receive events.
:type source: ~uamqp.address.Source
:param prefetch: The number of events to prefetch from the service
Expand Down Expand Up @@ -78,7 +78,7 @@ async def open_async(self):
context will be used to create a new handler before opening it.
:param connection: The underlying client shared connection.
:type: connection: ~uamqp._async.connection_async.ConnectionAsync
:type: connection: ~uamqp.async_ops.connection_async.ConnectionAsync
"""
# pylint: disable=protected-access
if self.redirected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__( # pylint: disable=super-init-not-called
Instantiate an EventHub event SenderAsync handler.
:param client: The parent EventHubClientAsync.
:type client: ~azure.eventhub._async.EventHubClientAsync
:type client: ~azure.eventhub.async_ops.EventHubClientAsync
:param target: The URI of the EventHub to send to.
:type target: str
:param partition: The specific partition ID to send to. Default is `None`, in which case the service
Expand Down Expand Up @@ -80,7 +80,7 @@ async def open_async(self):
context will be used to create a new handler before opening it.
:param connection: The underlying client shared connection.
:type: connection:~uamqp._async.connection_async.ConnectionAsync
:type: connection: ~uamqp.async_ops.connection_async.ConnectionAsync
"""
if self.redirected:
self.target = self.redirected.address
Expand Down
20 changes: 10 additions & 10 deletions azure/eventhub/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def __init__(self, address, username=None, password=None, debug=False, http_prox
Additionally the following keys may also be present: 'username', 'password'.
:type http_proxy: dict[str, Any]
:param auth_timeout: The time in seconds to wait for a token to be authorized by the service.
The default value is 60 seconds.
The default value is 60 seconds. If set to 0, no timeout will be enforced from the client.
:type auth_timeout: int
"""
self.container_id = "eventhub.pysdk-" + str(uuid.uuid4())[:8]
Expand Down Expand Up @@ -142,6 +142,7 @@ def from_connection_string(cls, conn_str, eventhub=None, **kwargs):
:type conn_str: str
:param eventhub: The name of the EventHub, if the EntityName is
not included in the connection string.
:type eventhub: str
:param debug: Whether to output network trace logs to the logger. Default
is `False`.
:type debug: bool
Expand All @@ -150,7 +151,7 @@ def from_connection_string(cls, conn_str, eventhub=None, **kwargs):
Additionally the following keys may also be present: 'username', 'password'.
:type http_proxy: dict[str, Any]
:param auth_timeout: The time in seconds to wait for a token to be authorized by the service.
The default value is 60 seconds.
The default value is 60 seconds. If set to 0, no timeout will be enforced from the client.
:type auth_timeout: int
"""
address, policy, key, entity = _parse_conn_str(conn_str)
Expand All @@ -173,7 +174,7 @@ def from_iothub_connection_string(cls, conn_str, **kwargs):
Additionally the following keys may also be present: 'username', 'password'.
:type http_proxy: dict[str, Any]
:param auth_timeout: The time in seconds to wait for a token to be authorized by the service.
The default value is 60 seconds.
The default value is 60 seconds. If set to 0, no timeout will be enforced from the client.
:type auth_timeout: int
"""
address, policy, key, _ = _parse_conn_str(conn_str)
Expand Down Expand Up @@ -297,11 +298,11 @@ def get_eventhub_info(self):
"""
Get details on the specified EventHub.
Keys in the details dictionary include:
-'name'
-'type'
-'created_at'
-'partition_count'
-'partition_ids'
-'name'
-'type'
-'created_at'
-'partition_count'
-'partition_ids'
:rtype: dict
"""
Expand Down Expand Up @@ -394,8 +395,7 @@ def add_epoch_receiver(

def add_sender(self, partition=None, operation=None, send_timeout=60, keep_alive=30, auto_reconnect=True):
"""
Add a sender to the client to send ~azure.eventhub.common.EventData object
to an EventHub.
Add a sender to the client to EventData object to an EventHub.
:param partition: Optionally specify a particular partition to send to.
If omitted, the events will be distributed to available partitions via
Expand Down
13 changes: 11 additions & 2 deletions azure/eventhub/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _error_handler(error):
class EventData(object):
"""
The EventData class is a holder of event content.
Acts as a wrapper to an ~uamqp.message.Message object.
Acts as a wrapper to an uamqp.message.Message object.
"""

PROP_SEQ_NUMBER = b"x-opt-sequence-number"
Expand Down Expand Up @@ -186,14 +186,15 @@ def body(self):
"""
The body of the event data object.
:rtype: bytes or generator[bytes]
:rtype: bytes or Generator[bytes]
"""
return self.message.get_data()


class Offset(object):
"""
The offset (position or timestamp) where a receiver starts. Examples:
Beginning of the event stream:
>>> offset = Offset("-1")
End of the event stream:
Expand Down Expand Up @@ -238,6 +239,14 @@ def selector(self):
class EventHubError(Exception):
"""
Represents an error happened in the client.
:ivar message: The error message.
:vartype message: str
:ivar error: The error condition, if available.
:vartype error: str
:ivar details: The error details, if included in the
service response.
:vartype details: dict[str, str]
"""

def __init__(self, message, details=None):
Expand Down
2 changes: 1 addition & 1 deletion azure/eventhub/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def transfer(self, event_data, callback=None):
:type event_data: ~azure.eventhub.common.EventData
:param callback: Callback to be run once the message has been send.
This must be a function that accepts two arguments.
:type callback: func[~uamqp.constants.MessageSendResult, ~azure.eventhub.common.EventHubError]
:type callback: callable[~uamqp.constants.MessageSendResult, ~azure.eventhub.common.EventHubError]
"""
if self.error:
raise self.error
Expand Down
4 changes: 2 additions & 2 deletions azure/eventprocessorhost/eh_partition_pump.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def on_open_async(self):
_opened_ok = True
except Exception as err: # pylint: disable=broad-except
_logger.warning(
"%r,%r PartitionPumpWarning: Failure creating client or receiver, "
"%r,%r PartitionPumpWarning: Failure creating client or receiver, " +
"retrying: %r", self.host.guid, self.partition_context.partition_id, err)
last_exception = err
_retry_count += 1
Expand Down Expand Up @@ -91,7 +91,7 @@ async def clean_up_clients_async(self):

async def on_closing_async(self, reason):
"""
Overides partition pump on cleasing.
Overides partition pump on closing.
:param reason: The reason for the shutdown.
:type reason: str
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
zip_safe=False,
packages=find_packages(exclude=["examples", "tests"]),
install_requires=[
'uamqp>=0.2.1,<0.3.0',
'uamqp>=1.0.0,<2.0.0',
'msrestazure~=0.4.11',
'azure-common~=1.1',
'azure-storage~=0.36.0'
Expand Down

0 comments on commit c8db793

Please sign in to comment.