dapr / components-contrib

Community driven, reusable components for distributed apps
Apache License 2.0
548 stars 480 forks source link

Event Hub binding should allow transforming ALL custom properties as headers, not just iot-hub systemproperties #3570

Open oising opened 1 month ago

oising commented 1 month ago

Describe the feature

Currently only a fixed set of system properties from Azure IoT Hub are forwarded as headers when delivered to a subscriber. The Azure Event Hubs binding should expose a getAllProperties property (false by default) to forward all user/app/custom properties from the Event Hub message as headers to the subscriber.

It seems that is 90% supported already in the DAPR codebase, but it stops short at exposing the setting in the manifest. i.e.

// GetBindingsHandlerFunc returns the handler function for bindings messages
func (aeh *AzureEventHubs) GetBindingsHandlerFunc(topic string, getAllProperties bool, handler bindings.Handler) HandlerFn {
    return func(ctx context.Context, messages []*azeventhubs.ReceivedEventData) ([]HandlerResponseItem, error) {
        if len(messages) != 1 {
            return nil, fmt.Errorf("expected 1 message, got %d", len(messages))
        }

        bindingsMsg, err := NewBindingsReadResponseFromEventData(messages[0], topic, getAllProperties)
        if err != nil {
            return nil, fmt.Errorf("failed to get bindings read response from azure eventhubs message: %w", err)
        }

        aeh.logger.Debugf("Calling app's handler for message %s on topic %s", messages[0].SequenceNumber, topic)
        _, err = handler(ctx, bindingsMsg)
        return nil, err
    }
}

Release Note

RELEASE NOTE:

github-actions[bot] commented 1 week ago

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

georgestevens99 commented 1 day ago

FYI After a deep dive into the Azure IoT realm last fall and winter consisting of lots of reading, I'd like to remind you that a very, very common use for the Azure Event Hub is the Azure IoT Hub which comes with an Event Hub attached! Therefore, by fixing Event Hub bugs and adding new features (such as this) you also improve the positioning of Dapr to service the IoT community, which has had consistent strong growth for a number of years now and is expected to continue. This fix will help!