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

AVRO-3900: [Rust] Make it possible to use custom names validators #2643

Merged
merged 10 commits into from
Jan 25, 2024

Conversation

martin-g
Copy link
Member

@martin-g martin-g commented Dec 20, 2023

AVRO-3900

What is the purpose of the change

  • Make it possible the applications to configure custom validators for the schema name, namespace, enum symbols and record field names

Verifying this change

  • All new and old tests should pass!

Documentation

  • Does this pull request introduce a new feature? yes
  • If yes, how is the feature documented? RustDoc

@github-actions github-actions bot added the Rust label Dec 20, 2023
WIP

TODO:
- Extract validators for enum symbols and record field names
- Polish the APIs

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
@martin-g martin-g force-pushed the avro-3900-custom-name-validators branch from 5b9df53 to 75232b8 Compare December 21, 2023 08:24
Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
This way they use the public APIs of the crate, as a real user application.

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
@martin-g martin-g marked this pull request as ready for review December 21, 2023 10:06
@martin-g martin-g force-pushed the avro-3900-custom-name-validators branch from 899bf7d to c03e506 Compare December 21, 2023 10:27
@martin-g martin-g closed this Dec 21, 2023
@martin-g martin-g reopened this Dec 21, 2023
@martin-g martin-g force-pushed the avro-3900-custom-name-validators branch 4 times, most recently from d62395d to 7a018de Compare December 21, 2023 12:03
Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
@martin-g martin-g force-pushed the avro-3900-custom-name-validators branch from 7a018de to c277f41 Compare December 21, 2023 14:08
Otherwise there are timing issues with the initializations of the
OnceLock's for the different validators.
Parsing a Schema leads to initialization of the default validator and
later it is impossible to set a custom one

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
…test_helper crate

For some reason clearing the log messages in the tests destructor
(#[dtor]) was failing for this example.

Simplify the TestLogger to use the std thread_local!() instead of the
third party ref_thread_local!()

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
@martin-g martin-g force-pushed the avro-3900-custom-name-validators branch 3 times, most recently from eeb2b47 to 1dfe9f5 Compare December 22, 2023 08:50
Just make sure the setup of the custom validators is done before the
parsing of any schema to prevent registering the default validator
(SpecificationValidator)

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
@martin-g martin-g force-pushed the avro-3900-custom-name-validators branch from 1dfe9f5 to 86c70b3 Compare December 22, 2023 09:13
Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
@martin-g martin-g changed the title AVRO-3900: [Rust] Make it possible to use custom validators AVRO-3900: [Rust] Make it possible to use custom names validators Dec 22, 2023
@rodneykeeling
Copy link

This worked on my machine (both SchemaNameValidator and SchemaNamespaceValidator traits). Thanks for the work here! Is there anything else needed to get this merged (aside from merge conflict fixes)?

@martin-g
Copy link
Member Author

I was waiting for a feedback from the reporter (@jslusher).

@jslusher
Copy link

@martin-g Hi! @rodneykeeling is a colleague of mine who was kind enough to test this branch in a new Rust consumer he's making. If he says it works, then we're good to go. Thanks for putting this together!

@martin-g martin-g merged commit 61df187 into main Jan 25, 2024
16 checks passed
@martin-g martin-g deleted the avro-3900-custom-name-validators branch January 25, 2024 07:21
martin-g added a commit that referenced this pull request Jan 25, 2024
)

* AVRO-3900: [Rust] Make it possible to use custom validators

* AVRO-3900: Add validator trait for enum symbol names

* AVRO-3900: Introduce validator for RecordField's name

* AVRO-3900: Extract the custom validators tests as IT tests

This way they use the public APIs of the crate, as a real user application.

* AVRO-3900: Polish APIs

* AVRO-3900: Split the validator integration tests

Otherwise there are timing issues with the initializations of the
OnceLock's for the different validators.
Parsing a Schema leads to initialization of the default validator and
later it is impossible to set a custom one

* AVRO-3900: Simplify generate_interop_data.rs example to not use avro_test_helper crate

For some reason clearing the log messages in the tests destructor
(#[dtor]) was failing for this example.

Simplify the TestLogger to use the std thread_local!() instead of the
third party ref_thread_local!()

* AVRO-3900: Merge the validators integration tests in one test

Just make sure the setup of the custom validators is done before the
parsing of any schema to prevent registering the default validator
(SpecificationValidator)

* AVRO-3900: Improve the documentation

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
(cherry picked from commit 61df187)
RanbirK pushed a commit to RanbirK/avro that referenced this pull request May 13, 2024
…ache#2643)

* AVRO-3900: [Rust] Make it possible to use custom validators

* AVRO-3900: Add validator trait for enum symbol names

* AVRO-3900: Introduce validator for RecordField's name

* AVRO-3900: Extract the custom validators tests as IT tests

This way they use the public APIs of the crate, as a real user application.

* AVRO-3900: Polish APIs

* AVRO-3900: Split the validator integration tests

Otherwise there are timing issues with the initializations of the
OnceLock's for the different validators.
Parsing a Schema leads to initialization of the default validator and
later it is impossible to set a custom one

* AVRO-3900: Simplify generate_interop_data.rs example to not use avro_test_helper crate

For some reason clearing the log messages in the tests destructor
(#[dtor]) was failing for this example.

Simplify the TestLogger to use the std thread_local!() instead of the
third party ref_thread_local!()

* AVRO-3900: Merge the validators integration tests in one test

Just make sure the setup of the custom validators is done before the
parsing of any schema to prevent registering the default validator
(SpecificationValidator)

* AVRO-3900: Improve the documentation

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants