Skip to content
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

KafkaConsumer.rxCommit(Map<TopicPartition, OffsetAndMetadata>) missing #87

Open
MartinNowak opened this issue Jan 12, 2018 · 7 comments

Comments

@MartinNowak
Copy link

Looks like sth. went wrong during codegen, both

void commit(Map<TopicPartition, OffsetAndMetadata>, Handler<AsyncResult<Map<TopicPartition, OffsetAndMetadata>>>);

and

Single<Map<TopicPartition, OffsetAndMetadata>> rxCommit(Map<TopicPartition, OffsetAndMetadata>);

are missing from io.vertx.reactivex.kafka.client.consumer.KafkaConsumer and io.vertx.rxjava.kafka.client.consumer.KafkaConsumer.

javap -classpath vertx-kafka-client-3.5.0.jar io.vertx.reactivex.kafka.client.consumer.KafkaConsumer | grep -Fi commit\(

http://vertx.io/docs/apidocs/io/vertx/kafka/client/consumer/KafkaConsumer.html#commit-java.util.Map-io.vertx.core.Handler-
http://vertx.io/docs/apidocs/io/vertx/reactivex/kafka/client/consumer/KafkaConsumer.html#commit-io.vertx.core.Handler-
http://vertx.io/docs/apidocs/io/vertx/rxjava/kafka/client/consumer/KafkaConsumer.html#commit-io.vertx.core.Handler-

Maybe the Handler<AsyncResult<Map<TopicPartition, OffsetAndMetadata>>> type is too complex for the codegen parser?

@MartinNowak
Copy link
Author

Workaround from https://github.com/vert-x3/vertx-rx/blob/65bcf1c87c0c74646d6bcc7354ae8d0d86b9efa8/rx-java2/src/main/resources/vertx-rxjava2/template/rxjava2.templ#L121-L125

new AsyncResultSingle(handler -> {
  kafkaConsumer.delegate.commit(topicOffsetMap, handler);
});

@vietj
Copy link
Contributor

vietj commented Jan 12, 2018

is the method annotated with @GenIgnore ?

@ppatierno
Copy link
Member

@vietj yes it is. I guess it's because this kind of Map with more complex types isn't supported by vertx-codgen. I read the following from the documentation :

type java.util.Map<String, C> where C contains
the set Basic
the set Json
the set Api

@MartinNowak
Copy link
Author

MartinNowak commented Jan 17, 2018

Handler<AsyncResult<Map<TopicPartition,OffsetAndMetadata>>> completionHandler
What's the trouble with template arguments? Shouldn't they just be the same as in the original code?

Not such a big deal if you know the undocumented workaround, but still quite confusing.

@MartinNowak
Copy link
Author

Ah, you're using reflection for this.
https://github.com/vert-x3/vertx-codegen/blob/7f8b20bc18ca585f43bdd9c1b7d412dd739eedc9/src/main/java/io/vertx/codegen/type/TypeReflectionFactory.java#L86-L94
Looks like it doesn't recurse for the arguments.

So this https://github.com/vert-x3/vertx-rx/blob/65bcf1c87c0c74646d6bcc7354ae8d0d86b9efa8/rx-java2/src/main/resources/vertx-rxjava2/template/rxjava2.templ#L18-L28 code would only lead to

Single<Map> rxCommit(Map<TopicPartition, OffsetAndMetadata>>)

instead of

Single<Map<TopicPartition, OffsetAndMetadata>> rxCommit(Map<TopicPartition, OffsetAndMetadata>>)
, right?

@vietj
Copy link
Contributor

vietj commented Jan 17, 2018

it does not recurse argument because it would lead to a too complex implementation, the actual rx wrappers need to maintain the type arguments as reified types

if you need to access them, you should use getDelegate() to obtain the real java type and rewrap it using SingleHelper or RxHelper.

@MartinNowak
Copy link
Author

Unfortunately SingleHelper doesn't work here (it's vice versa) and RxHelper in rx-java2 has no observableFuture. So I'll stick with using the interal AsyncResultSingle for now.

Let me finally suggest that you create some dummy documentation entries (e.g. void rxCommit()) for @GenIgnore methods that state the fact that the method is missing and show the suggested workaround instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants