-
Notifications
You must be signed in to change notification settings - Fork 212
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 support for generating protobuf3 definition #166 #1085
Draft
kapilreddy
wants to merge
7
commits into
metosin:master
Choose a base branch
from
kapilreddy:feature/issue-166-protobuf3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The commit introduces Protocol Buffer 3 (protobuf3) support for Malli schemas: - Implement transform function to convert Malli schemas to protobuf3 - Add transform-schema function for handling nested structures - Add support for enum types in Malli schemas - Add comprehensive test suite for transform and transform-schema functions - Include tests for deeply nested structures and complex schemas - Ensure generated protobuf3 definitions are syntactically correct
- Maintain same input/output interface for compatibility - Eliminate mutable state from the collect-definitions function, making it a pure function
malli.perf.core/serve! uses clj-async-profiler/serve-files which is a depcrecated function Updated the code to use clj-async-profiler/serve-ui clojure-goes-fast/clj-async-profiler@733ae1e clj-async-profiler version was updated here, metosin@9d705eb
User cherry-none fn instead of cherry in * case
Hi, and thanks for the PR! Quick comments:
I think the solution could look much like the JSON Schema transformation:
what do you think? |
Makes sense. I'll address these comments. |
for perf testing, most of the time goes in constructing the schema. It can be cached to check the actual transformation code perf. So: (def schema
(m/schema
[:map
[:id string?]
[:metadata [:map
[:created_at inst?]
[:tags [:vector string?]]]]
[:data [:vector [:map
[:name string?]
[:details [:map
[:type [:enum :type-a :type-b :type-c]]
[:properties [:vector [:map
[:key string?]
[:value [:or string? int? boolean?]]
[:nested [:vector [:map
[:sub_key string?]
[:sub_value any?]]]]]]]]]]]]]))
(defn transform-perf []
;; 28.656211 µs -> 640ns
(p/bench (protobuf/transform schema))) |
That's a good catch! I'll fix the perf namespace as well. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #166
Contribution checklist
./bin/kaocha and ./bin/node
malli.perf.core/quick-bench
onmalli.protobuf3-schema/transform
with a fairly complex schema takes 28.656211 µsOverview of change