Skip to content

Commit 6640da2

Browse files
authored
[EventHubs] prep release (Azure#24089)
1 parent be22436 commit 6640da2

File tree

4 files changed

+85
-47
lines changed

4 files changed

+85
-47
lines changed

sdk/eventhub/azure-eventhub/CHANGELOG.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Release History
22

3-
## 5.9.0b3 (Unreleased)
3+
## 5.9.0b3 (2022-04-20)
44

55
### Features Added
66

77
- Introduced new method `send_event` to `EventHubProducerClient` which allows sending single `EventData` or `AmqpAnnotatedMessage`.
8-
- Introduced buffered mode sending to `EventHubProducerClient` which is intended to allow for efficient publishing of events
8+
- Introduced buffered mode sending to `EventHubProducerClient` which is intended to allow for efficient publishing of events
99
without having to explicitly manage batches in the application.
10-
- The constructor of `EventHubProducerClient` and `from_connection_string` method now takes the following new keyword arguments
10+
- The constructor of `EventHubProducerClient` and `from_connection_string` method now takes the following new keyword arguments
1111
for configuration:
1212
- `buffered_mode`: The flag to enable/disable buffered mode sending.
1313
- `on_success`: The callback to be called once events have been successfully published.
@@ -541,13 +541,4 @@ Version 5.0.0b1 is a preview of our efforts to create a client library that is u
541541
- Further testing and minor bug fixes.
542542

543543

544-
## 0.2.0a2 (2018-04-02)
545-
546-
- Updated uAQMP dependency.
547-
548-
549-
## 0.2.0a1 (unreleased)
550-
551-
- Swapped out Proton dependency for uAMQP.
552-
553544
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python/sdk/eventhub/azure-eventhub/HISTORY.png)

sdk/eventhub/azure-eventhub/azure/eventhub/_producer_client.py

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,18 @@ class EventHubProducerClient(ClientBase): # pylint: disable=client-accepts-api
6161
It is required when `buffered_mode` is True while optional if `buffered_mode` is False.
6262
:paramtype on_success: Optional[Callable[[SendEventTypes, Optional[str]], None]]
6363
:keyword on_error: The callback to be called once a batch has failed to be published.
64-
The callback takes three parameters:
64+
The callback function should be defined like: `on_error(events, partition_id, error)`, where:
6565
- `events`: The list of events that failed to be published,
6666
- `partition_id`: The partition id that the events in the list have been tried to be published to and
6767
- `error`: The exception related to the sending failure.
68-
The callback function should be defined like: `on_error(events, partition_id, error)`.
69-
It is required when `buffered_mode` is True while optional if `buffered_mode` is False.
70-
If `on_error` is passed when in non-buffered mode, instead of error being raised from the send methods,
71-
the `on_error` callback will be called with the error information related to sending.
68+
If `buffered_mode` is False, `on_error` callback is optional and errors will be handled as follows:
69+
- If an `on_error` callback is passed during the producer client instantiation,
70+
then error information will be passed to the `on_error` callback, which will then be called.
71+
- If an `on_error` callback is not passed in during client instantiation,
72+
then the error will be raised by default.
73+
If `buffered_mode` is True, `on_error` callback is required and errors will be handled as follows:
74+
- If events fail to enqueue within the given timeout, then an error will be directly raised.
75+
- If events fail to send after enqueuing successfully, the `on_error` callback will be called.
7276
:paramtype on_error: Optional[Callable[[SendEventTypes, Optional[str], Exception], None]]
7377
:keyword int max_buffer_length: Buffered mode only.
7478
The total number of events per partition that can be buffered before a flush will be triggered.
@@ -398,17 +402,22 @@ def from_connection_string(
398402
- `events`: The list of events that have been successfully published
399403
- `partition_id`: The partition id that the events in the list have been published to.
400404
The callback function should be defined like: `on_success(events, partition_id)`.
401-
It is required when `buffered_mode` is True while optional if `buffered_mode` is False.
405+
Required when `buffered_mode` is True while optional if `buffered_mode` is False.
402406
:paramtype on_success: Optional[Callable[[SendEventTypes, Optional[str]], None]]
403407
:keyword on_error: The callback to be called once a batch has failed to be published.
404-
The callback takes three parameters:
408+
Required when in `buffered_mode` is True while optional if `buffered_mode` is False.
409+
The callback function should be defined like: `on_error(events, partition_id, error)`, where:
405410
- `events`: The list of events that failed to be published,
406411
- `partition_id`: The partition id that the events in the list have been tried to be published to and
407412
- `error`: The exception related to the sending failure.
408-
The callback function should be defined like: `on_error(events, partition_id, error)`.
409-
It is required when in `buffered_mode` is True while optional if `buffered_mode` is False.
410-
If `on_error` is passed in non-buffered mode, instead of error being raised from the send methods,
411-
the `on_error` callback will be called with the error information related to sending.
413+
If `buffered_mode` is False, `on_error` callback is optional and errors will be handled as follows:
414+
- If an `on_error` callback is passed during the producer client instantiation,
415+
then error information will be passed to the `on_error` callback, which will then be called.
416+
- If an `on_error` callback is not passed in during client instantiation,
417+
then the error will be raised by default.
418+
If `buffered_mode` is True, `on_error` callback is required and errors will be handled as follows:
419+
- If events fail to enqueue within the given timeout, then an error will be directly raised.
420+
- If events fail to send after enqueuing successfully, the `on_error` callback will be called.
412421
:paramtype on_error: Optional[Callable[[SendEventTypes, Optional[str], Exception], None]]
413422
:keyword int max_buffer_length: Buffered mode only.
414423
The total number of events per partition that can be buffered before a flush will be triggered.
@@ -483,9 +492,15 @@ def send_event(self, event_data, **kwargs):
483492
the events into buffer within the given time if specified and return.
484493
The producer will do automatic sending in the background in buffered mode.
485494
486-
If `on_error` is passed while `buffered_mode` is False when instantiating the producer client,
487-
instead of error being raised from the send methods,
488-
the `on_error` callback will be called with the error information related to sending.
495+
If `buffered_mode` is False, `on_error` callback is optional and errors will be handled as follows:
496+
- If an `on_error` callback is passed during the producer client instantiation,
497+
then error information will be passed to the `on_error` callback, which will then be called.
498+
- If an `on_error` callback is not passed in during client instantiation,
499+
then the error will be raised by default.
500+
501+
If `buffered_mode` is True, `on_error` callback is required and errors will be handled as follows:
502+
- If events fail to enqueue within the given timeout, then an error will be directly raised.
503+
- If events fail to send after enqueuing successfully, the `on_error` callback will be called.
489504
490505
:param event_data: The `EventData` object to be sent.
491506
:type event_data: Union[~azure.eventhub.EventData, ~azure.eventhub.amqp.AmqpAnnotatedMessage]
@@ -548,9 +563,15 @@ def send_batch(self, event_data_batch, **kwargs):
548563
the events into buffer within the given time if specified and return.
549564
The producer will do automatic sending in the background in buffered mode.
550565
551-
In non-buffered mode, if `on_error` is passed in when instantiating the producer client,
552-
instead of error being raised from the send methods in error scenarios,
553-
the `on_error` callback will be called with the error related to sending failure.
566+
If `buffered_mode` is False, `on_error` callback is optional and errors will be handled as follows:
567+
- If an `on_error` callback is passed during the producer client instantiation,
568+
then error information will be passed to the `on_error` callback, which will then be called.
569+
- If an `on_error` callback is not passed in during client instantiation,
570+
then the error will be raised by default.
571+
572+
If `buffered_mode` is True, `on_error` callback is required and errors will be handled as follows:
573+
- If events fail to enqueue within the given timeout, then an error will be directly raised.
574+
- If events fail to send after enqueuing successfully, the `on_error` callback will be called.
554575
555576
In buffered mode, sending a batch will remain intact and sent as a single unit.
556577
The batch will not be rearranged. This may result in inefficiency of sending events.

sdk/eventhub/azure-eventhub/azure/eventhub/aio/_producer_client_async.py

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,22 @@ class EventHubProducerClient(ClientBaseAsync): # pylint: disable=client-accepts
6363
- `events`: The list of events that have been successfully published
6464
- `partition_id`: The partition id that the events in the list have been published to.
6565
The callback function should be defined like: `on_success(events, partition_id)`.
66-
It is required when `buffered_mode` is True while optional if `buffered_mode` is False.
66+
Required when `buffered_mode` is True while optional if `buffered_mode` is False.
6767
:paramtype on_success: Optional[Callable[[SendEventTypes, Optional[str]], Awaitable[None]]]
6868
:keyword on_error: The callback to be called once a batch has failed to be published.
69-
The callback takes three parameters:
69+
Required when in `buffered_mode` is True while optional if `buffered_mode` is False.
70+
The callback function should be defined like: `on_error(events, partition_id, error)`, where:
7071
- `events`: The list of events that failed to be published,
7172
- `partition_id`: The partition id that the events in the list have been tried to be published to and
7273
- `error`: The exception related to the sending failure.
73-
The callback function should be defined like: `on_error(events, partition_id, error)`.
74-
It is required when in `buffered_mode` is True while optional if `buffered_mode` is False.
75-
If `on_error` is passed when in non-buffered mode, instead of error being raised from the send methods,
76-
the `on_error` callback will be called with the error information related to sending.
74+
If `buffered_mode` is False, `on_error` callback is optional and errors will be handled as follows:
75+
- If an `on_error` callback is passed during the producer client instantiation,
76+
then error information will be passed to the `on_error` callback, which will then be called.
77+
- If an `on_error` callback is not passed in during client instantiation,
78+
then the error will be raised by default.
79+
If `buffered_mode` is True, `on_error` callback is required and errors will be handled as follows:
80+
- If events fail to enqueue within the given timeout, then an error will be directly raised.
81+
- If events fail to send after enqueuing successfully, the `on_error` callback will be called.
7782
:paramtype on_error: Optional[Callable[[SendEventTypes, Optional[str], Exception], Awaitable[None]]]
7883
:keyword int max_buffer_length: Buffered mode only.
7984
The total number of events per partition that can be buffered before a flush will be triggered.
@@ -409,14 +414,18 @@ def from_connection_string(
409414
It is required when `buffered_mode` is True while optional if `buffered_mode` is False.
410415
:paramtype on_success: Optional[Callable[[SendEventTypes, Optional[str]], Awaitable[None]]]
411416
:keyword on_error: The callback to be called once a batch has failed to be published.
412-
The callback takes three parameters:
417+
The callback function should be defined like: `on_error(events, partition_id, error)`, where:
413418
- `events`: The list of events that failed to be published,
414419
- `partition_id`: The partition id that the events in the list have been tried to be published to and
415420
- `error`: The exception related to the sending failure.
416-
The callback function should be defined like: `on_error(events, partition_id, error)`.
417-
It is required when `buffered mode` is True while optional if `buffered_mode` is False.
418-
If `on_error` is passed in non-buffered mode, instead of error being raised from the send methods,
419-
the `on_error` callback will be called with the error information related to sending.
421+
If `buffered_mode` is False, `on_error` callback is optional and errors will be handled as follows:
422+
- If an `on_error` callback is passed during the producer client instantiation,
423+
then error information will be passed to the `on_error` callback, which will then be called.
424+
- If an `on_error` callback is not passed in during client instantiation,
425+
then the error will be raised by default.
426+
If `buffered_mode` is True, `on_error` callback is required and errors will be handled as follows:
427+
- If events fail to enqueue within the given timeout, then an error will be directly raised.
428+
- If events fail to send after enqueuing successfully, the `on_error` callback will be called.
420429
:paramtype on_error: Optional[Callable[[SendEventTypes, Optional[str], Exception], Awaitable[None]]]
421430
:keyword int max_buffer_length: Buffered mode only.
422431
The total number of events per partition that can be buffered before a flush will be triggered.
@@ -499,9 +508,15 @@ async def send_event(
499508
If the `EventHubProducerClient` is configured to run in buffered mode, the method will enqueue the event
500509
into local buffer and return. The producer will do automatic batching and sending in the background.
501510
502-
If `on_error` is passed while `buffered_mode` is False when instantiating the producer client,
503-
instead of error being raised from the send methods,
504-
the `on_error` callback will be called with the error information related to sending.
511+
If `buffered_mode` is False, `on_error` callback is optional and errors will be handled as follows:
512+
- If an `on_error` callback is passed during the producer client instantiation,
513+
then error information will be passed to the `on_error` callback, which will then be called.
514+
- If an `on_error` callback is not passed in during client instantiation,
515+
then the error will be raised by default.
516+
517+
If `buffered_mode` is True, `on_error` callback is required and errors will be handled as follows:
518+
- If events fail to enqueue within the given timeout, then an error will be directly raised.
519+
- If events fail to send after enqueuing successfully, the `on_error` callback will be called.
505520
506521
:param event_data: The `EventData` object to be sent.
507522
:type event_data: Union[~azure.eventhub.EventData, ~azure.eventhub.amqp.AmqpAnnotatedMessage]
@@ -566,9 +581,15 @@ async def send_batch(
566581
If the `EventHubProducerClient` is configured to run in buffered mode, the method will enqueue the events
567582
into local buffer and return. The producer will do automatic sending in the background.
568583
569-
In non-buffered mode, if `on_error` is passed in when instantiating the producer client,
570-
instead of error being raised from the send methods in error scenarios,
571-
the `on_error` callback will be called with the error related to sending failure.
584+
If `buffered_mode` is False, `on_error` callback is optional and errors will be handled as follows:
585+
- If an `on_error` callback is passed during the producer client instantiation,
586+
then error information will be passed to the `on_error` callback, which will then be called.
587+
- If an `on_error` callback is not passed in during client instantiation,
588+
then the error will be raised by default.
589+
590+
If `buffered_mode` is True, `on_error` callback is required and errors will be handled as follows:
591+
- If events fail to enqueue within the given timeout, then an error will be directly raised.
592+
- If events fail to send after enqueuing successfully, the `on_error` callback will be called.
572593
573594
In buffered mode, sending a batch will remain intact and sent as a single unit.
574595
The batch will not be rearranged. This may result in inefficiency of sending events.

sdk/eventhub/azure-eventhub/samples/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,17 @@ Both [sync version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/
7474
- Utilize `azure.core.credentials.AzureNamedKeyCredential` to authenticate when creating an Event Hub client.
7575

7676
- [connection_to_custom_endpoint_address.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/eventhub/azure-eventhub/samples/sync_samples/connection_to_custom_endpoint_address.py) ([async version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/eventhub/azure-eventhub/samples/async_samples/connection_to_custom_endpoint_address_async.py)) - Examples:
77-
to create EventHubProducerClient and EventHubConsumerClient that connect to a custom endpoint with a custom certificate.
77+
- Create EventHubProducerClient and EventHubConsumerClient that connect to a custom endpoint with a custom certificate.
7878

7979
- [send_and_receive_amqp_annotated_message.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/eventhub/azure-eventhub/samples/sync_samples/send_and_receive_amqp_annotated_message.py) ([async_version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/eventhub/azure-eventhub/samples/async_samples/send_and_receive_amqp_annotated_message_async.py)) - Examples to send AMQPAnnotatedMessage to and receive events from an event hub and parse the body:
8080
- Send AMQPAnnotatedMessage of different body types.
8181
- Receive messages and parse the body according to the body type.
8282

83+
- [send_buffered_mode.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/eventhub/azure-eventhub/samples/sync_samples/send_buffered_mode.py) ([async_version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/eventhub/azure-eventhub/samples/async_samples/send_buffered_mode_async.py)) - Examples to send events in buffered mode:
84+
- Send single events, which will be automatically batched.
85+
- Send a batch of events by enqueuing an EventDataBatch object to the buffer.
86+
- Send events in buffer immediately by calling `flush`.
87+
8388
## Prerequisites
8489
- Python 3.6 or later.
8590
- **Microsoft Azure Subscription:** To use Azure services, including Azure Event Hubs, you'll need a subscription.

0 commit comments

Comments
 (0)