chia7712 edited a comment on pull request #9433:
URL: https://github.com/apache/kafka/pull/9433#issuecomment-724592314


   @tombentley Thanks for your sharing. It inspires me to think about the 
possible solution. The following comment is not related to this PR. just 
discussion 😃
   
   > That's a good idea in theory, but in practice the code generator doesn't 
know which fields are error codes, apart from the convention that they're 
called ErrorCode and are an int16. 
   
   How about using ```EntityType``` (called ```ErrorCode```). for example:
   ```json
   
         { "name": "ErrorCode", "type": "int16", "versions": "0+", 
"entityType": "errorCode",
           "about": "The error code, or 0 if there was no error." },
   ```
   
   > If we ever needed to call an error code field something else errorCounts() 
would break. I think there is some value in having a richer way of expressing 
types (that is, separately from the "serialization type") in the RPC JSON (see 
https://issues.apache.org/jira/browse/KAFKA-7787 for example), but any effort 
to do that would require a KIP and potentially impose a burden on other client 
implementer who are consuming that JSON.
   
   following above new entityType ```errorCode```
   1. We can add a new method ```Map<Errors, Integer> errorCounts()``` to 
```Message``` interface.
   1. By default, it returns empty map (or None -> 1)
   1. code generator gives custom implementation only if the message has either 
message field or error code field (i.e entity type is ErrorCode).
   1. the composite message class should merge all error count from all fields
   


----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to