-
Notifications
You must be signed in to change notification settings - Fork 138
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
Error types should be modeled more strongly #241
Comments
I like this idea a lot, at the very least as an experiment to see how feasible this is and what would be a good approach. I've been considering doing the same for zio-kinesis. Taking
For Most of the exceptions can come from /**
* @throws org.apache.kafka.clients.consumer.InvalidOffsetException if the offset for a partition or set of
* partitions is undefined or out of range and no offset reset policy has been configured
* @throws org.apache.kafka.common.errors.WakeupException if {@link #wakeup()} is called before or while this
* function is called
* @throws org.apache.kafka.common.errors.InterruptException if the calling thread is interrupted before or while
* this function is called
* @throws org.apache.kafka.common.errors.AuthenticationException if authentication fails. See the exception for more details
* @throws org.apache.kafka.common.errors.AuthorizationException if caller lacks Read access to any of the subscribed
* topics or to the configured groupId. See the exception for more details
* @throws org.apache.kafka.common.KafkaException for any other unrecoverable errors (e.g. invalid groupId or
* session timeout, errors deserializing key/value pairs, your rebalance callback thrown exceptions,
* or any new error cases in future versions)
* @throws java.lang.IllegalArgumentException if the timeout value is negative
* @throws java.lang.IllegalStateException if the consumer is not subscribed to any topics or manually assigned any
* partitions to consume from
* @throws java.lang.ArithmeticException if the timeout is greater than {@link Long#MAX_VALUE} milliseconds.
* @throws org.apache.kafka.common.errors.InvalidTopicException if the current subscription contains any invalid
* topic (per {@link org.apache.kafka.common.internals.Topic#validate(String)})
* @throws org.apache.kafka.common.errors.UnsupportedVersionException if the consumer attempts to fetch stable offsets
* when the broker doesn't support this feature
* @throws org.apache.kafka.common.errors.FencedInstanceIdException if this consumer instance gets fenced by broker.
*/ Some of these we should (hopefully) be able to get rid of as zio-kafka programming errors using
You would get a fiber failure in such a case. But that still leaves like 20 of them which would need to be modeled into a custom error type or otherwise eliminated, including I see three options:
Besides poll, commit errors are not passed to the error channel of |
I like the approach of gradually building an ADT, including a catch-all-like type like That way, we can start with a few known error-cases, and incrementally extend the error types with actual real-life cases that do occur. Subjectivity should be less of a factor that way, since the ADT hierarchy should be able to mirror the exception hierarchy. We could model the We'd only have to push the |
Big 👍 on this! |
Implements #241 Build still fails because test and bench projects have not been migrated yet, first want to gather some feedback on this change.
Right now, all zio-kafka effect types have
Throwable
as their error type, requiring users to look into the kafka API itself to find out what exceptions to expect.An argument could be made to introduce concrete error types for the expected error scenarios, and use those instead of
Throwable
. This can have some clear advantages:We can show the difference between a stream that silently reconnects, vs. a (not implemented yet) stream that fails when kafka's connection goes down (as requested in Close consumer when it cannot connect to the broker #175 ).
We can model deserialization errors into this type, if desired, as an alternative to the current
.asTry
construct.In fact, in its current state, which exceptions can be expected in that
Throwable
?The text was updated successfully, but these errors were encountered: