azure-functions-kafka-extension
azure-functions-kafka-extension copied to clipboard
C# KafkaTriggerAttribute and KafkaAttribute should accept strings for Protocol and AuthenticationMode
C# requires that attribute arguments must be a constant expression, typeof expression, or array creation expression of an attribute parameter type, which makes putting the Protocol and AuthenticationMode arguments for both KafkaTriggerAttribute and KafkaAttribute in to *.settings.json files impossible.
In code you can do something like:
BrokerProtocol protocol = (BrokerProtocol)Enum.Parse(typeof(BrokerProtocol), @"%Sec_Protocol%");
but, that doesn't work for Attribute arguments.
It would be fantastic if KafkaTriggerAttribute and KafkaAttribute added string attribute versions of Protocol and AuthenticationMode that internally do the Enum.Parse() so that these values can be populated as:
[KafkaTrigger(@"%Broker%",
@"%TopicName%",
SslCaLocation = @"%CaFile%",
Protocol = @"%Protocol%", // <-----
AuthenticationMode = @"%AuthMode%", // <-----
Username = @"%Username%",
Password = @"%Password%",
ConsumerGroup = "%ConsumerGroup%" )] KafkaEventData<byte[]>[] events,
instead of hardcoded like:
[KafkaTrigger(@"%Broker%",
@"%TopicName%",
SslCaLocation = @"%CaFile%",
Protocol = BrokerProtocol.SaslSsl, // <-----
AuthenticationMode = BrokerAuthenticationMode.Plain, // <-----
Username = @"%Username%",
Password = @"%Password%",
ConsumerGroup = "%ConsumerGroup%" )] KafkaEventData<byte[]>[] events,
Hi, any update ? I would like to get rid of those #if DEBUG when testing with a local broker...
No this requirement doesn't make sense as we would like to bound customers to only use the supported protocols. If there is any protocol which is not supported feel free to raise the issue or PR we will work on that.
No this requirement doesn't make sense as we would like to bound customers to only use the supported protocols. If there is any protocol which is not supported feel free to raise the issue or PR we will work on that.
@shrohilla I don't understand your answer. The requirement is not about supporting other protocols, but to be able to parameterize the protocol more easily. For instance, we don't want to run a fully configured cluster locally to run functional tests. So those KafkaTrigger properties should be configurable as any other standard configuration setting.
Seconding what @arkiaconsulting said. This really should not have been closed - especially not as "completed".
Hi, any update about send configs AuthenticationMode and Protocol as expression instead of enums ?