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

NSFS | NC | Use avj compile and Reuse validate Function #7887

Merged
merged 1 commit into from
Mar 17, 2024

Conversation

shirady
Copy link
Contributor

@shirady shirady commented Mar 12, 2024

Explain the changes

  1. In NSFS schemas separate the compile (which is done once) from the validate (which is reuse).

Issues:

  1. Currently we use ajv.validate(schema_name, object_to_validate) and it doesn’t align with the avj documentation (here), please notice the comment “Best performance: compile and getSchema methods”:

Best performance: compile and getSchema methods
The best performance is achieved when using compiled functions returned by compile or getSchema methods.
While execution of the compiled validation function is very fast, its compilation is relatively slow, so you need to make sure that you compile schemas only once and re-use compiled validation functions

Note: it is a partial fix to #7874

Testing Instructions:

  1. Run the schema unit tests:
    npx jest test_nc_nsfs_account_schema_validation.test.js
    npx jest test_nc_nsfs_bucket_schema_validation.test.js
    npx jest test_nc_nsfs_config_schema_validation.test.js
  • Doc added/updated
  • Tests added

@shirady shirady changed the title NSFS | NC | Use avj compile and reuse validate function NSFS | NC | Use avj compile and Reuse validate Function Mar 12, 2024
@shirady shirady self-assigned this Mar 12, 2024
@shirady shirady force-pushed the nsfs-nc-avj-compile branch from 5dd5ccf to 4db2b31 Compare March 14, 2024 07:25
@shirady shirady requested a review from dannyzaken March 14, 2024 09:06
@shirady shirady force-pushed the nsfs-nc-avj-compile branch from 4db2b31 to b91247e Compare March 14, 2024 16:42
Copy link
Contributor

@naveenpaul1 naveenpaul1 left a comment

Choose a reason for hiding this comment

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

LGTM

@shirady shirady force-pushed the nsfs-nc-avj-compile branch 3 times, most recently from de71650 to 6cea0f5 Compare March 17, 2024 09:46
Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
@shirady shirady force-pushed the nsfs-nc-avj-compile branch from 6cea0f5 to 93e53ff Compare March 17, 2024 11:27
@shirady shirady merged commit 4cc33da into noobaa:master Mar 17, 2024
10 checks passed
@shirady shirady deleted the nsfs-nc-avj-compile branch March 17, 2024 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants