Skip to content

refactor: replace global mutable state in cache.zig with injected CacheState struct (#127)#437

Open
justrach wants to merge 1 commit intomainfrom
fix/127-refactor-replace-global-mutable-state-in-cache-run
Open

refactor: replace global mutable state in cache.zig with injected CacheState struct (#127)#437
justrach wants to merge 1 commit intomainfrom
fix/127-refactor-replace-global-mutable-state-in-cache-run

Conversation

@justrach
Copy link
Copy Markdown
Owner

Summary

  • Extract all cache globals (g_mu, g_ready, g_has_data, g_labels, g_milestones, g_alloc) into a CacheState struct with explicit init/deinit/invalidate lifecycle
  • CacheState methods are instance-based, making them testable without globals
  • Thin wrapper functions delegate to a module-level CacheState for backward compatibility
  • getState() returns pointer for callers needing direct access
  • Tests now use local CacheState instances instead of modifying module globals
  • appendLabel/appendMilestone now return errors instead of silently swallowing them
  • Closes refactor: replace global mutable state in cache/runtime with injected AppState #127

…heState struct (#127)

- Extract all cache globals (g_mu, g_ready, g_has_data, g_labels, g_milestones, g_alloc)
  into a CacheState struct with explicit init/deinit/invalidate lifecycle
- CacheState methods are instance-based, making them testable without globals
- Thin wrapper functions (prefetch, getLabel, getMilestone, isReady, invalidate)
  delegate to a module-level CacheState for backward compatibility
- getState() returns pointer for callers that need direct access
- Tests now use local CacheState instances instead of modifying module globals
- appendLabel/appendMilestone now return errors instead of silently swallowing them
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.

refactor: replace global mutable state in cache/runtime with injected AppState

1 participant