Skip to content

Fix: Add lazy loading of Twig #71

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

Merged
merged 2 commits into from
Jun 3, 2024
Merged

Fix: Add lazy loading of Twig #71

merged 2 commits into from
Jun 3, 2024

Conversation

RikudouSage
Copy link
Collaborator

@RikudouSage RikudouSage commented May 29, 2024

Description

Makes Twig extension lazy loadable.

Fixes #70

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Manual Tests

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link

@dkarlovi dkarlovi left a comment

Choose a reason for hiding this comment

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

Works for me without issues with these changes. 👍

@RikudouSage RikudouSage requested a review from sighphyre May 30, 2024 09:16
@dkarlovi
Copy link

dkarlovi commented May 30, 2024

Let me check if it works without this.

Edit: it does. 👍

@RikudouSage
Copy link
Collaborator Author

@sighphyre Basically, what this does is it moves the instantiation logic into a separate runtime.

The Twig extension has to be instantiated to read the metadata (like functions and filters the extension provides), but it was also used to provide the implementation, which means that it had a dependency on a working Unleash object just to read the metadata to construct the template cache.

Now that implementation and metadata are separate, the cache can be dumped without actually needing a working Unleash instance, which is needed only at runtime.

This effectively makes it possible to dump the cache on a build system that does not have information about the Unleash server.

Copy link
Member

@sighphyre sighphyre left a comment

Choose a reason for hiding this comment

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

Sure, makes sense!

@RikudouSage RikudouSage merged commit 8d2ce92 into main Jun 3, 2024
2 checks passed
@RikudouSage RikudouSage deleted the fix/lazy-loading branch June 3, 2024 14:46
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.

[Bug]: client is not marked lazy, tries to connect to the Unleash server when building Twig cache
3 participants