move context from record to pipeline level#39
Open
divyanshu-tiwari wants to merge 3 commits intomainfrom
Open
Conversation
- storing metadata in context at record level was creating chain of references preventing garbage collection of records, which was leading to OOM issues. - Moving context to pipeline level and only storing necessary metadata in record resolves the issue.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request refactors metadata handling in pipeline records by replacing Go's context.Context with a custom Meta map, while introducing pipeline-level context for cancellation support. The change addresses memory leaks caused by context reference chains preventing garbage collection of records.
Changes:
- Replaced
Record.Contextfield withRecord.Metamap for metadata storage, maintaining JSON backward compatibility - Updated all task
Runmethods to acceptcontext.Contextparameter for cancellation support - Modified configuration handling to use new meta methods while preserving template function names for backward compatibility
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/pkg/pipeline/record/record.go | Replaced Context field with Meta map in Record struct |
| internal/pkg/pipeline/record/meta.go | Added new SetMetaValue/GetMetaValue methods for metadata management |
| internal/pkg/pipeline/record/context.go | Removed old context-based metadata methods |
| internal/pkg/pipeline/pipeline.go | Added pipeline-level context with cancellation support |
| internal/pkg/pipeline/task/task.go | Updated Task interface and base methods to use context parameter and Meta map |
| internal/pkg/pipeline/task/*/*.go | Updated all task implementations to use new Run signature and Meta instead of Context |
| internal/pkg/config/context.go | Renamed functions to use Meta terminology while maintaining backward compatibility |
| internal/pkg/config/config.go | Updated template function registration to use renamed meta functions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 pull request introduces a significant refactor to how metadata is handled in pipeline records, replacing the previous usage of Go's
context.Contextwith a customMetamap. It also updates the pipeline and task interfaces to usecontext.Contextfor cancellation and control, improving robustness and clarity. The changes touch core pipeline logic, task implementations, and configuration handling.Metadata handling refactor:
Contextfield in theRecordstruct with aMetamap for storing metadata, ensuring backward compatibility by keeping the JSON key ascontext.SetContextValueandGetContextValuemethods in favor of newSetMetaValueandGetMetaValuemethods for managing record metadata. [1] [2]Metafor metadata storage and retrieval instead ofContext. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]Pipeline and task interface improvements:
context.Contextandcancelfunction for supporting cancellation and control flow, and updated task concurrency handling to pass context to tasks. [1] [2] [3] [4]Runmethods to accept acontext.Contextparameter, enabling cancellation and consistent interface usage. [1] [2] [3] [4] [5] [6] [7] [8]Configuration and macro/context handling:
These changes modernize metadata handling, improve cancellation support, and ensure backward compatibility for configuration templates.- storing metadata in context at record level was creating chain of references preventing garbage collection of records, which was leading to OOM issues.
Description
Types of changes
Checklist