jerrypeng commented on issue #4093: [issue#4042] improve java functions API URL: https://github.com/apache/pulsar/pull/4093#issuecomment-485191485 @sijie adding another support for ```MessageBuilder<O> process(I input, Context context);``` will likely involve adding another function interface that user's can implement and adding support for it in the functions framework . This will be a bigger change and perhaps require broader discussion. I am not sure adding another function interface is the correct way to go about this. My concerns about this: 1. User's will have to implement another interface to take advantage of being able to set these message confs for returned output. If a user has already written a function using the function interface now, he or she will have to change it. This forces users to make a considerable amount of changes instead of just calling an additional method. 2. Additional interface we have to support in the function runtime. While this is not a deal breaker for me, but I rather not support any more interfaces than necessary. In my opinion, only when we absolutely cannot use the existing function interface to accomplish something should we consider this because this can additional complexity to the function runtime. 3. My vision for functions is that we keep a certain distance from a producer and consumer API to distinguish functions a way to do lightweight compute and not just some generic consume/produce application. So I would rather not have any more APIs that resemble consumer/producer semantics. Again this is just a preference. > It is very error-prone. If people didn’t pay attention or then implementation doesn’t handle correctly, the message conf is going to apply to every message I understand your concern for this ``` if (foo) { messageBuilder.setKey(foo) } if (bar) { messageBuilder.setProperties(bar) } mesageBuilder.setValue(val) return messageBuilder; ``` is that really less error prone than: ``` if (foo) { messageBuilderConf.setKey(foo) } if (bar) { messageBuilderConf.setProperties(bar) } context.setOutputMessageConf(messageBuilderConf); return val; ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
