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

Ability to save generated validator code #21

Open
NathanRSmith opened this issue Aug 1, 2015 · 2 comments
Open

Ability to save generated validator code #21

NathanRSmith opened this issue Aug 1, 2015 · 2 comments

Comments

@NathanRSmith
Copy link

Hi, I really like how performant Themis is after is generates the validators but, as we know, it can be quite slow in doing the actual generation. Would it be possible to get access to the generated code to save it separately as a pre-prepared validator? This would be very useful when schemas are all known ahead of time and change very slowly.

My immediate use case is for using Themis in the browser. It was simple to use Browserify to bundle it up, but it takes 6 seconds to generate all my validators EVERY TIME the page loads. This would be tolerable when starting a long running service, but is somewhat of a deal-breaker for the front-end. Caching generated validators in separate scripts would be a nice compromise for the cases when all schemas are known beforehand and the generation step could be put into an assert build pipeline.

Thoughts?

@NathanRSmith NathanRSmith changed the title Ability to save validator functions Ability to save generated validator code Aug 1, 2015
@NathanRSmith
Copy link
Author

Wow, talk about a quick response time, it appears that this feature already exists since last November! The methods are currently undocumented, but for future visitors, see writeToFile at line 2149 and loadFromFile at line 2403 (commit at time of writing is f4bc33c).

Documentation for these features would probably be good to add at some point. Thanks!

@kumarharsh
Copy link
Member

Hi @NathanRSmith! Yup, this feature of pre-compiling the schemas exists, and as you've rightly deduced, it is in those functions. We're using themis for the backend in our project, where the compiled schemas are cached in-memory, so I presume we didn't give much thought to those functions.
You're more than welcome to add to the documentation. @atrniv would certainly love that! 😄

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

No branches or pull requests

2 participants