fix: load cancelable + graph redudant - #27
Conversation
Signed-off-by: Cloorc <wittcnezh@foxmail.com>
There was a problem hiding this comment.
Pull Request Overview
This pull request addresses two issues: context management in the matcher and redundant graph relationship tracking in the dump functionality.
- Changes context initialization from using the passed context to
context.Background() - Updates graph relationship tracking from boolean map to
anytype map with explicit nil assignment
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| matcher.go | Changes context initialization to use context.Background() instead of passed context |
| dump.go | Updates graph relationship map from bool to any type and adds explicit nil assignment |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| nodeID: nodeID, | ||
| snapshotChanged: 0, // Initialize atomic flag to 1 (no changes) | ||
| ctx: ctx, | ||
| ctx: context.Background(), |
There was a problem hiding this comment.
Using context.Background() ignores the passed context parameter, which could break cancellation and timeout functionality. The original context should be used to maintain proper context propagation and cancellation behavior.
| ctx: context.Background(), | |
| ctx: ctx, |
| graphLines = append(graphLines, fmt.Sprintf("# Tenant: %s", tenantKey)) | ||
| mappingLines = append(mappingLines, fmt.Sprintf("# Tenant: %s", tenantKey)) | ||
| graphs, relationship := make(map[string]bool), "" | ||
| graphs, relationship := make(map[string]any), "" |
There was a problem hiding this comment.
The change from map[string]bool to map[string]any with nil values is unnecessary and reduces type safety. The original boolean map approach was cleaner - the presence of a key in the map already indicates the relationship exists, making the value irrelevant.
| for rid, next := range trans { | ||
| relationship = fmt.Sprintf("%s %s", current, next) | ||
| if _, ok := graphs[relationship]; !ok { | ||
| graphs[relationship] = nil |
There was a problem hiding this comment.
The change from map[string]bool to map[string]any with nil values is unnecessary and reduces type safety. The original boolean map approach was cleaner - the presence of a key in the map already indicates the relationship exists, making the value irrelevant.
No description provided.