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

WIP - Do not Merge: Added support for AWS Glue Schema registry #488

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nicklester
Copy link
Contributor

Added support to enable the AWS Glue Schema Registry

@davideicardi
Copy link
Collaborator

Thank you @nicklester !
It LGTM, maybe I would only prefer to have the AWS Glue implementation a little more "isolated" ... What do you think @Bert-R ?

Copy link
Collaborator

@Bert-R Bert-R left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a few small comments.
I agree with @davideicardi that a bit more isolation and genericity would be helpful.

What about this:

  • Add a property schemaregistry.type, with possible values generic and aws-glue. Default is generic.
  • Extend SchemaRegistryProperties with a check: if type != 'generic', then the properties connect and auth should not be set.
  • Enhance GlueSchemaRegistryProperties in a similar way and remove isConfigured. Als add a validation that the mandatory properties are set if this registry type is configured.
  • Extend AvroMessageDeserializer with a map of deserializer factories, keyed by the registry type.

With that, we're prepared for a future PR that adds support for Microsoft's SchemaRegistryApacheAvroSerializer

this.kafkaMonitor = kafkaMonitor;
this.messageInspector = messageInspector;
this.messageFormatProperties = messageFormatProperties;
this.schemaRegistryProperties = schemaRegistryProperties;
this.protobufProperties = protobufProperties;
this.glueSchemaRegistryProperties = glueSchemaRegistryProperties;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this one down, to maintain the same order as the parameter list

@@ -60,6 +60,12 @@ and if you also require basic auth for your schema registry connection you shoul
--schemaregistry.auth=username:password
```

or, if you are using the AWS Glue Schema Registry
```
--schemaregistry.glue.region=us-east-1 --schemaregistry.glue.registryName=demo-registry
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--schemaregistry.glue.region=us-east-1 --schemaregistry.glue.registryName=demo-registry
--schemaregistry.glue.region=us-east-1
--schemaregistry.glue.registryName=demo-registry

Besides this, also document the other (apparently optional) properties.

Comment on lines +50 to +51
if(StringUtils.isNotEmpty(awsEndpoint))
config.put(AWSSchemaRegistryConstants.AWS_ENDPOINT, awsEndpoint);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(StringUtils.isNotEmpty(awsEndpoint))
config.put(AWSSchemaRegistryConstants.AWS_ENDPOINT, awsEndpoint);
if (StringUtils.isNotEmpty(awsEndpoint)) {
config.put(AWSSchemaRegistryConstants.AWS_ENDPOINT, awsEndpoint);
}

We'll need to establish and publish a code style, but from what I see, curly braces are used around all blocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good suggestiosn - sorry slow response. Busy work wise. Will take a look shortly

@nicklester
Copy link
Contributor Author

I've added a few small comments. I agree with @davideicardi that a bit more isolation and genericity would be helpful.

What about this:

  • Add a property schemaregistry.type, with possible values generic and aws-glue. Default is generic.
  • Extend SchemaRegistryProperties with a check: if type != 'generic', then the properties connect and auth should not be set.
  • Enhance GlueSchemaRegistryProperties in a similar way and remove isConfigured. Als add a validation that the mandatory properties are set if this registry type is configured.
  • Extend AvroMessageDeserializer with a map of deserializer factories, keyed by the registry type.

With that, we're prepared for a future PR that adds support for Microsoft's SchemaRegistryApacheAvroSerializer

Was just a quick question - (as Java is not my 1st or even 2nd language!). Isn't using a factory going to mean we need to pass the same types as arguments, but the generic and glue configs are different, and in different hierarchies). Apologies if I've missed something obvious :)

@Bert-R
Copy link
Collaborator

Bert-R commented Mar 29, 2023

No problem! As always, there are multiple ways to approach it. I'd do a slightly bigger refactor as you find in
the attached patch. Note that I have not done any testing. The constants for the schema registry type would need to be moved from MessageDeserializerFactory to a SchemaRegistryConfiguration, to use them to test the possible values for type.

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

Successfully merging this pull request may close these issues.

None yet

3 participants