[PIP-43] Support producer to send msg with different schema - #5165
Conversation
081945f to
1e5d71d
Compare
|
/cc @congbobo184 for review as well. |
87b1eec to
e7165ef
Compare
e7165ef to
24aedfa
Compare
sijie
left a comment
There was a problem hiding this comment.
overall looks good. left two comments, PTAL
There was a problem hiding this comment.
it seems to me that this method is a bit confusing. T is the original type, no? shouldn't it be a different type?
<V> TypedMessageBuilder<V> newMessage(Schema<V> schema);
There was a problem hiding this comment.
@sijie yeah, you are right. I would change the signature in the following PR to make this one easier to review. It would break some more inner method of implementation class.
There was a problem hiding this comment.
I'll leave a TODO, or just hide this interface for still not complete
There was a problem hiding this comment.
I have hidden this interface and left a TODO.
b61d097 to
814ded0
Compare
814ded0 to
d595c0c
Compare
|
ping @sijie @congbobo184 @jiazhai @codelipenghui, Any more comments? |
codelipenghui
left a comment
There was a problem hiding this comment.
Looks good to me, just left a few comments
d3913f4 to
2bf3eef
Compare
codelipenghui
left a comment
There was a problem hiding this comment.
Overall looks good to me, nice work! @yittg
|
run cpp tests |
|
run cpp tests |
There was a problem hiding this comment.
@yittg I think this should be improved. We should avoid calling sync methods.
A better implementation here is:
- if a new schema is needed, flush out all the existing pending requests to the broker. because all the existing pending requests use old schemas that are already registered in broker.
- introduce a state for the client (e.g. REGISTERING_SCHEMA). Turn the client into REGISTERING_SCHEMA state. All the requests should be added in the pending queue and wait until the schema is registered in the broker.
- after a schema is successfully registered in the broker, flush all the pending requests to the broker.
There was a problem hiding this comment.
Yeah, agree with you on executing command asynchronously. It's a better implementation, I will get it out.
There was a problem hiding this comment.
First try pushed, PTAL.
2bf3eef to
a7d89d8
Compare
a7d89d8 to
8d5e8c8
Compare
|
@sijie Does the new implementation make sense? |
|
run Integration Tests |
|
@sijie @codelipenghui @congbobo184 May I take up some more of your time to PUSH this PR on. |
|
run Integration Tests |
2 similar comments
|
run Integration Tests |
|
run Integration Tests |
|
@yittg sorry for late review. I am looking into it today. |
| if (opSendMsg != null) { | ||
| processOpSendMsg(opSendMsg); | ||
| } | ||
| opSendMsgs = Collections.singletonList(batchMessageContainer.createOpSendMsg()); |
There was a problem hiding this comment.
The original code was there to avoid creating collections for non-batching case. I would prefer not rewriting this logic.
There was a problem hiding this comment.
It's ok to leave it as it is.
| private void processOpSendMsg(OpSendMsg op) { | ||
| try { | ||
| batchMessageContainer.clear(); | ||
| if (op.msg != null && isBatchMessagingEnabled()) { |
There was a problem hiding this comment.
any reason why you are adding this logic here?
There was a problem hiding this comment.
op.msg means a single non-batch message. we should flush the current batch if needed.
batchMessageContainer.clear(); was moved into batchMessageAndSend.
Then processOpSendMsg not only for batch message.
Don't we need to do the flush, to keep the order or something else?
| return topic.addSchema(schema); | ||
| } else { | ||
| return topic.hasSchema().thenCompose((hasSchema) -> { | ||
| log.info("[{}] {} configured with schema {}", |
There was a problem hiding this comment.
Can we keep the origin log statement when refactoring the code?
There was a problem hiding this comment.
producer_id not carried in CommandGetOrCreateSchema, actually need it?
Or a -1 as placeholder?
| return new TypedMessageBuilderImpl<>(this, schema); | ||
| } | ||
|
|
||
| // TODO: same parameterized type `T` with producer for the moment, |
There was a problem hiding this comment.
Create a github issue for this change and add the github issue in this TODO comment? It is a good practice to always track TODO items in github issues.
There was a problem hiding this comment.
Should I just edit the master issue, with a checklist, or new a issue for each TODO?
There was a problem hiding this comment.
a master issue with a checklist will be good enough.
|
@yittg sorry for late response. |
Master Issue: #5141
Motivation
Implement part-1 of PIP-43.
Modifications
Verifying this change
This change added tests and can be verified as follows in
SimpleSchemaTest:Does this pull request potentially affect one of the following parts:
Documentation