-
Notifications
You must be signed in to change notification settings - Fork 14
refactor: replace OrgResolver with LdxSyncService and cache-based approach #1129
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
base: main
Are you sure you want to change the base?
Conversation
…roach - Introduced LdxSyncService interface for LDX-Sync configuration management - Added in-memory caching of LDX-Sync results at Config level - Implemented parallel fetching of LDX-Sync config for workspace folders - Cache refreshes on login and workspace folder changes - Replaced OrgResolver interface with direct cache-based lookups - Removed deprecated GetBestOrgFromLdxSync function - Updated all tests to use GetOrgFromCachedLdxSync directly - Changed successful fetch logging from Info to Debug level - Added ABOUTME comments to new ldx_sync_service.go file - Documented 4 skipped integration tests in SKIPPED_TESTS_IDE-1636.md This refactor improves performance by avoiding repeated API calls and provides a cleaner architecture with better separation of concerns.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Summary of ChangesHello @nick-y-snyk, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on enhancing the developer experience by re-enabling a local module replacement for the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
b81c5f1 to
611e9f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new LdxSyncService to manage and cache LDX-Sync configuration results for workspace folders. This refactoring improves how organization-related settings are handled, moving from a direct OrgResolver to a caching mechanism. The changes involve updating dependency injection, modifying relevant handlers to utilize the new service, and updating tests to reflect these architectural shifts. A new markdown file has also been added to document skipped integration tests, which is a good practice for future development.
- Remove unnecessary network mocking in tests (mock at service level instead) - Use generated MockLdxSyncService instead of manual mocks - Add ResolveOrg method to LdxSyncService interface - Fix fallback tests by properly initializing engine mock - Delete SKIPPED_TESTS file as all tests now pass
| func (c *Config) InitLdxSyncCache() { | ||
| c.ldxSyncCacheMutex.Lock() | ||
| defer c.ldxSyncCacheMutex.Unlock() | ||
| c.ldxSyncCache = make(map[types.FilePath]*ldx_sync_config.LdxSyncConfigResult) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why build a cache here and not use GAF config cache ? or maybe I'm missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we want to hold ldxsync configs inmemory in ls, later it will be structured better; it's just the initial approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GAF caches config values in mem already
domain/ide/command/folder_handler.go
Outdated
| gafConfig := engine.GetConfiguration() | ||
| // GetOrgFromCachedLdxSync retrieves the organization from the cached LDX-Sync result | ||
| // Falls back to global organization if no cache entry exists | ||
| func GetOrgFromCachedLdxSync(c *config.Config, folderPath types.FilePath, ldxSyncService LdxSyncService) (ldx_sync_config.Organization, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to a service
Refactoring Summary: LdxSyncService as Complete FacadeChanges Made
Why Remove These Tests?These tests were testing GAF's Our
We should test our responsibilities (cache lookup, fallback logic), not re-test GAF's resolver logic. Tests That RemainThe remaining tests cover our actual facade responsibilities:
Benefits
|
0e5c677 to
0f72491
Compare
a7f0657 to
b432a7f
Compare
Refactored LdxSyncService to use dependency injection, enabling full mocking of external LDX-Sync API calls in tests. Added 16 test cases covering RefreshConfigFromLdxSync and ResolveOrg including success paths, error handling, caching, parallel execution, and boundary conditions.
b432a7f to
c669687
Compare
LdxSyncService.ResolveOrg previously fell back to the global organization when no cache entry existed for a folder. This could lead to unexpected behavior where folders would use a different org than intended by LDX-Sync. Changes ResolveOrg to return an error instead of falling back, ensuring that callers explicitly handle the case where organization cannot be determined from the LDX-Sync cache. This makes the behavior more predictable and easier to reason about. Also fixes Test_loginCommand_StartsAuthentication timeout by adding missing mock expectation for ResolveOrg method call during initialized handler execution.
Replace cache pre-population with mock LdxSyncService for better test isolation and control. Tests that specifically verify cache logic still use real service with cache, but general behavior tests now use mocks to avoid implicit dependencies on cache state.
Summary
Test plan