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

[Event Hubs] Allow partition key use in Functions async collector #33858

Merged
merged 8 commits into from
Feb 6, 2023

Conversation

jsquire
Copy link
Member

@jsquire jsquire commented Feb 2, 2023

Summary

The focus of these changes is to allow for partition keys to be used when binding to the async collector to publish events. In the original v1.x version of Functions, which used the track-zero Event Hubs library, the implementation relied on a broker-owned property of EventData to be set, which was possible only due to the approach used for enabling unit testing. Since the bindings moved to the track-one Event Hubs library which disallowed setting the broker-owned property, it is not been possible to use the collector with a partition key.

In addition to fixing a bug with batch creation, these changes expose the EventHubAsyncCollector and allow binding to it, exposing an AddAsync overload specific to Event Hubs which accepts a partition key. This enables events to be logically grouped together, ensuring they are assigned to the same partition. Previously, binding was restricted to the IAsyncCollector<T> interface, which only accepted an EventData instance leaving no way to specify a partition key. As a result, all events were assigned partitions via round-robin.

References and Related

@jsquire jsquire added Event Hubs Client This issue points to a problem in the data-plane of the library. Functions labels Feb 2, 2023
@jsquire jsquire added this to the 2023-03 milestone Feb 2, 2023
@jsquire jsquire self-assigned this Feb 2, 2023
@jsquire jsquire requested a review from tg-msft as a code owner February 2, 2023 17:47
@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

Microsoft.Azure.WebJobs.Extensions.EventHubs

The focus of these changes is to allow for partition keys to be used when
binding to the async collector to publish events.  Previously, use was
restricted to the `IAsyncCollector<T>` interface, which only accepted an
`EventData` instance leaving no way to specify a partition key.  As a result,
all events were assigned partitions via round-robin.

These changes expose the `EventHubAsyncCollector` and allow binding to it,
exposing an `AddAsync` overload specific to Event Hubs which accepts a
partition key.  This allows events to be logically grouped together, ensuring
they are assigned to the same partition.
…llector<EventData> to avoid the need to introduce a new type.
…ling often lately in pipeline runs, including failing ths PR.
@jsquire jsquire merged commit 441e0b7 into Azure:main Feb 6, 2023
@jsquire jsquire deleted the func/partkey branch February 6, 2023 20:22
richardcho-msft pushed a commit to richardcho-msft/azure-sdk-for-net that referenced this pull request Feb 6, 2023
…ure#33858)

* [Event Hubs] Allow partition key use in async collector

The focus of these changes is to allow for partition keys to be used when
binding to the async collector to publish events.  Previously, use was
restricted to the `IAsyncCollector<T>` interface, which only accepted an
`EventData` instance leaving no way to specify a partition key.  As a result,
all events were assigned partitions via round-robin.

These changes expose the `EventHubAsyncCollector` and allow binding to it,
exposing an `AddAsync` overload specific to Event Hubs which accepts a
partition key.  This allows events to be logically grouped together, ensuring
they are assigned to the same partition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Event Hubs Functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants