-
Notifications
You must be signed in to change notification settings - Fork 99
[NU-2217] JSON parameter template instead of dynamic form for Kafka Sink #8213
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
base: staging
Are you sure you want to change the base?
[NU-2217] JSON parameter template instead of dynamic form for Kafka Sink #8213
Conversation
created: #8268 |
2043baa
to
6b33bf5
Compare
components-api/src/main/scala/pl/touk/nussknacker/engine/ModelConfig.scala
Outdated
Show resolved
Hide resolved
...-api/src/main/scala/pl/touk/nussknacker/engine/api/json/decoders/FromJsonSimpleDecoder.scala
Outdated
Show resolved
Hide resolved
...t/scala/pl/touk/nussknacker/defaultmodel/kafkaschemaless/BaseKafkaJsonSchemalessItSpec.scala
Show resolved
Hide resolved
...ls/src/main/scala/pl/touk/nussknacker/engine/json/JsonTemplateFromJsonSchemaDeterminer.scala
Outdated
Show resolved
Hide resolved
...ls/src/main/scala/pl/touk/nussknacker/engine/json/JsonTemplateFromJsonSchemaDeterminer.scala
Show resolved
Hide resolved
...src/main/scala/pl/touk/nussknacker/engine/schemedkafka/schema/AvroSchemaBasedParameter.scala
Show resolved
Hide resolved
new RegistryItem(topic, AvroUtils.parseSchema(schema), version, isKey, AutoIncId) | ||
new RegistryItem(topic, toParsedSchema(AvroUtils.parseSchema(schema), version), version, isKey, AutoIncId) | ||
|
||
def apply(topic: String, schema: Schema, version: Int, isKey: Boolean): RegistryItem = { |
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 looks like, RegistryItem.apply
is used only once. I think that someone, before you, overengineered this API, preparing it for many usages in many different cases. Let's simplify this class by removing all apply methods and discuss the API which is more commolny used (MockConfluentSchemaRegistryClientBuilder.register
)
...er/engine/schemedkafka/schemaregistry/confluent/client/MockSchemaRegistryClientBuilder.scala
Outdated
Show resolved
Hide resolved
...a/pl/touk/nussknacker/engine/schemedkafka/schemaregistry/universal/ParsedSchemaSupport.scala
Outdated
Show resolved
Hide resolved
) | ||
} | ||
|
||
protected def handleTopicWithSchemaWithJsonTemplateEditor( |
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.
Are you still getting what's going on in this class? Because I'm not :) What does WithJsonTemplateEditor
mean in this context? Does this method handle configuration option when there is a single parameter for value? I see that this pattern matching is enabled even if this option is not turned on. WDYT about having two PartialFunction
for both options and using one of them depending on configuration option? Will it decompose the problem? Or maybe at least, we could extract some parts of this pattern matching to dedicated classes that would name the scope of this pattern patching that they solve?
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.
I simplified it a little bit. Please take a look
@@ -33,6 +33,7 @@ class AvroSchemaTypeDefinitionExtractor(recordUnderlyingType: TypedClass) { | |||
case Schema.Type.RECORD => { | |||
val fields = schema.getFields.asScala | |||
.map(field => field.name() -> typeDefinition(field.schema())) | |||
.sortBy(_._1) |
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.
As we discussed, for Avro, we should keep the original order of fields
|
||
trait TestSchema { | ||
lazy val schema: Schema = AvroUtils.parseSchema(stringSchema) | ||
lazy val schema: Schema = AvroUtils.parseSchema(stringSchema) | ||
lazy val confluentSchema: AvroSchema = ConfluentUtils.convertToAvroSchema(schema) |
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.
Having two schemas next to each other is confusing. I thought about an approach, that we keep in samples this most commonly know type for schemas, which is easiest to build using DSL and to parse - org.apache.avro.Schema
, and we pass it to MockConfluentSchemaRegistryClientBuilder.register
where we convert it to ParsedSchema
just for MockSchemaRegistryClient.register
purpose.
case Some(validationModeString) => extractValidationMode(validationModeString) | ||
case None => ValidationMode.strict | ||
val validationMode = { | ||
if (params.isPresent(sinkRawEditorParamName)) { |
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 looks like we can use just extract
without Unsafe
and avoid direct isPresent
calling
} else if (params.isPresent(sinkValidationModeParamName)) { | ||
validationModeParamDeclaration.extractValue(params) match { | ||
case Some(validationModeString) => extractValidationMode(validationModeString) | ||
case None => ValidationMode.strict |
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.
This is a dead code. If you checked isPresent
, extractValue
will always return true.
if (params.extractUnsafe[Boolean](sinkRawEditorParamName)) { | ||
validationModeParamDeclaration.extractValue(params) match { | ||
case Some(validationModeString) => extractValidationMode(validationModeString) | ||
case None => ValidationMode.strict |
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.
I thought that for raw editor, validation mode is alywas avialable. Isn't it? It is for schemaless case? If so, lets' write a comment that this value is not important
c211ba4
to
c35d62f
Compare
Describe your changes
Checklist before merge