Refactor: Make Store Optional - Node trait accepts any store type#2
Merged
Refactor: Make Store Optional - Node trait accepts any store type#2
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors Cano's Node trait to remove the Store trait requirement, making data stores optional and enabling any type to be used as a store. This improves flexibility by allowing direct struct field access instead of requiring key-value store patterns.
- Node trait now accepts any store type instead of requiring Store trait implementation
- Store trait renamed to KeyValueStore and repositioned as optional helper utility
- New custom store example demonstrates using RequestCtx struct for direct field access
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/workflow.rs | Updates Workflow to support generic store types with new type parameter naming |
| src/store/mod.rs | Renames Store trait to KeyValueStore and rewrites documentation |
| src/store/memory.rs | Updates MemoryStore to implement KeyValueStore instead of Store |
| src/store/error.rs | Updates error messages to use TState instead of T generic naming |
| src/scheduler.rs | Updates Scheduler to handle generic store types with new bounds |
| src/node.rs | Removes Store trait requirement from Node trait, allowing any store type |
| src/lib.rs | Updates exports to use KeyValueStore instead of Store |
| src/error.rs | Updates type alias naming for consistency |
| examples/workflow_stack_store.rs | New example demonstrating custom store types with RequestCtx |
| examples/*.rs | Updates all examples to use new API patterns |
| benches/*.rs | Updates benchmarks for new KeyValueStore trait |
| README.md | Comprehensive rewrite of Store section with custom store examples |
| Cargo.toml | Adds new workflow_stack_store example |
Comments suppressed due to low confidence (2)
src/workflow.rs:301
- The parameter name
_storeindicates it's unused, but the next line accesses_store.get(). The underscore prefix should be removed since the parameter is actually used.
async fn prep(&self, _store: &MemoryStore) -> Result<Self::PrepResult, CanoError> {
src/workflow.rs:303
- Using
_storewhen the variable is actually being used is misleading. Should bestoreinstead of_store.
let data = _store
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or 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
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.
This PR fundamentally refactors Cano's Node trait to remove the Store trait requirement, making data stores optional and enabling any type to be used as a store. This change significantly improves flexibility, performance, and usability.
🎯 Key Changes
1. Node Trait Refactoring
Node<TState, TParams, TStore>now accepts any store typeT→TState,Params→TParams,S→TStorefor clarity2. Store Trait Renamed to KeyValueStore
Storetrait →KeyValueStoretrait for clarity3. New Custom Store Example
RequestCtxstruct as store type4. API Improvements
🔧 Technical Details
Before (Store trait required)
After (Any store type)
📊 Performance Benefits
📚 Updated Documentation
🧪 Testing & Compatibility
📁 Files Changed (22 files, +853/-537 lines)
Core Architecture:
Examples & Documentation:
Supporting Changes:
🎉 Migration Path
Existing MemoryStore usage continues to work:
New custom store patterns available:
🔗 Related
This change enables future enhancements like:
Closes: Enhanced flexibility and performance for Cano workflows
Type: Breaking change (major version bump required)
Testing: ✅ All tests pass, examples verified