-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add kafka source with additional variable with metadata. #1512
Conversation
997596f
to
444c8b4
Compare
...in/scala/pl/touk/nussknacker/engine/kafka/consumerrecord/ConsumerRecordToJsonFormatter.scala
Outdated
Show resolved
Hide resolved
TypedObjectTypingResult(fields(keyTypingResult), objType(keyTypingResult)) | ||
} | ||
|
||
private def fields(keyTypingResult: typing.TypingResult): Map[String, TypingResult] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could just introduce case class here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have InputMeta
case class. The problem here is that we mix type of key with primitive fields. IMO this way is ok, to resolve this problem. This companion object is in the same file as class so probability of desynchornization is minimal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed (and introduced case class SerializableConsumerRecord)
...l/src/main/scala/pl/touk/nussknacker/engine/kafka/source/KafkaGenericNodeSourceFactory.scala
Outdated
Show resolved
Hide resolved
...l/src/main/scala/pl/touk/nussknacker/engine/kafka/source/KafkaGenericNodeSourceFactory.scala
Outdated
Show resolved
Hide resolved
...k/kafka-util/src/main/scala/pl/touk/nussknacker/engine/kafka/source/KafkaSourceFactory.scala
Outdated
Show resolved
Hide resolved
...ouk/nussknacker/engine/kafka/consumerrecord/ConsumerRecordDeserializationSchemaFactory.scala
Outdated
Show resolved
Hide resolved
eca25b1
to
8a024a9
Compare
...k/kafka-util/src/main/scala/pl/touk/nussknacker/engine/kafka/source/KafkaSourceFactory.scala
Show resolved
Hide resolved
|
||
def from[K, V](topic: String, record: SerializableConsumerRecord[K, V]): ConsumerRecord[K, V] = { | ||
createConsumerRecord( | ||
record.topic.getOrElse(topic), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is counter-intuitive that topic specified in record has higher priority than record.topic
. WHy this method is needed? Why not to just serializableConsumerRecord.copy(topic = Some(otherTopic)).toConsumerRecord)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I see now that this method has cheated me - take a look for full invocation: looking on SerializableConsumerRecord from (....)
you will expect that the result will be SerializableConsumerRecord
, not kafka ConsumerRecord
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed according to our discussion.
...ouk/nussknacker/engine/kafka/consumerrecord/ConsumerRecordDeserializationSchemaFactory.scala
Show resolved
Hide resolved
|
||
object SerializableConsumerRecord { | ||
|
||
def createConsumerRecord[K, V](topic: String, partition: Int, offset: Long, timestamp: Long, key: K, value: V, headers: Headers): ConsumerRecord[K, V] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I right that it is only used on data extracted from SerializableConsumerRecord
? If it so, why not too have just a method toKafkaConsumerRecord
inside SerializableConsumerRecord
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, according to our discussion.
...in/scala/pl/touk/nussknacker/engine/kafka/consumerrecord/ConsumerRecordToJsonFormatter.scala
Outdated
Show resolved
Hide resolved
engine/flink/kafka-util/src/main/scala/pl/touk/nussknacker/engine/kafka/generic/sources.scala
Outdated
Show resolved
Hide resolved
4e830f2
to
787efed
Compare
docs/MigrationGuide.md
Outdated
- current `RecordFormater` should be sufficient for value-only serialization, or use `ConsumerRecordToJsonFormatter` for metadata serialization | ||
- provide timestampAssigner that is able to extract time from `ConsumerRecord[K, V]` | ||
Also: | ||
- removed `BaseKafkaSourceFactory` with multiple topics support: use `KafkaSourceFactory` instead, see test "source with two input topics" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you fix the order? should it be see "source with two input topics" test case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
a449a8e
to
f19eb86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, have some comments to type info detection because I didn't looked into it so far, maybe @mproch also take a look on it
/** | ||
* Trait that allows for providing more details TypeInformation when TypingResult is known. | ||
*/ | ||
trait TypeInformationDetectionForTypingResult extends TypeInformationDetection { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why not to merge it with TypeInformationDetection? 2. Maybe it could have better name because now it looks like it only detect type for typing result (fot context and so on - no)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 If it extends TypeInformationDetection I think it's better to move this method to forType?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Removed TypeInformationDetectionForTypingResult, method forType moved to TypeInformationDetection.
/** | ||
* Customisation for TypeInformationDetection that provides type information for BaseInputMeta. | ||
*/ | ||
class InputMetaAwareTypeInformationCustomisation extends TypingResultAwareTypeInformationCustomisation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be used in generic/demo/dev model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Currently it does not seem to be used anywhere? At least we should register it with ServiceLoader?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. See META-INF/services
in flinkKafkaUtil
and process
. Example test scenario is in InputMetaDeserializationSpec
.
* @tparam K - type of key of deserialized ConsumerRecord | ||
* @tparam V - type of value of deserialized ConsumerRecord | ||
*/ | ||
@silent("deprecated") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what deprecation warnings are here? Can we do sth to avoid them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. ConsumerRecord marks field checksum
as deprecated. We do not need to use this field, therefore here I replaced it with default NULL_CHECKSUM value.
/** | ||
* Trait that allows for providing more details TypeInformation when TypingResult is known. | ||
*/ | ||
trait TypeInformationDetectionForTypingResult extends TypeInformationDetection { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 If it extends TypeInformationDetection I think it's better to move this method to forType?
/** | ||
* Customisation for TypeInformationDetection that provides type information for BaseInputMeta. | ||
*/ | ||
class InputMetaAwareTypeInformationCustomisation extends TypingResultAwareTypeInformationCustomisation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Currently it does not seem to be used anywhere? At least we should register it with ServiceLoader?
…ypeInformationDetection
No description provided.