Skip to content

refactor(orchestrator): add ResultToGetTargetGraphResponse and migrate call sites#179

Open
justinwon777 wants to merge 1 commit into
mainfrom
orchestrator-targetgraph
Open

refactor(orchestrator): add ResultToGetTargetGraphResponse and migrate call sites#179
justinwon777 wants to merge 1 commit into
mainfrom
orchestrator-targetgraph

Conversation

@justinwon777

Copy link
Copy Markdown
Contributor

Adds orchestrator.ResultToGetTargetGraphResponse, copied from core/common. This is only called by orchestrator and the benchmark tool, so I migrated them here also. A follow-up PR will remove the duplicated code once all of core/common is migrated.

Test Plan

unit test

Issue

…e call sites

Adds orchestrator.ResultToGetTargetGraphResponse (and its private
chunkTargets helper), copied from core/common, and switches
native_orchestrator.go and example/cmd/query-bench over to it.
ResultToGetTargetGraphResponse's only real consumer is orchestrator's
GetTargetGraph; keeping it there instead of a shared package avoids a
grab-bag dependency for something with a single production caller.

core/common's copy is left in place for now; a follow-up PR removes
the duplicated code once all consumers have migrated.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@justinwon777 justinwon777 requested review from a team as code owners July 10, 2026 22:15
const _cancelCheckInterval = 4096

// ResultToGetTargetGraphResponse converts a Result to a GetTargetGraphResponse
func ResultToGetTargetGraphResponse(ctx context.Context, result targethasher.Result) ([]*tangopb.GetTargetGraphResponse, error) {

@liujsj liujsj Jul 10, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this part of orchestrator package? Given that it is trying to map the tango result to the proto response, it should be in own mapper package (not orchestrator) which is added as a dependency in the handler code (In this case controller since controller is acting as both handler + controller)

const _cancelCheckInterval = 4096

// ResultToGetTargetGraphResponse converts a Result to a GetTargetGraphResponse
func ResultToGetTargetGraphResponse(ctx context.Context, result targethasher.Result) ([]*tangopb.GetTargetGraphResponse, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're leaking the proto definition to orchestrator now?

@justinwon777

justinwon777 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Why is this part of orchestrator package? Given that it is trying to map the tango result to the proto response, it should be in own mapper package (not orchestrator) which is added as a dependency in the handler code (In this case controller since controller is acting as both handler + controller)

we're leaking the proto definition to orchestrator now?

Addressing both @liujsj @sywhang:
The way this is used right now is in orchestrator's GetTargetGraph:

responses, err := common.ResultToGetTargetGraphResponse(ctx, result)
...
err = storage.WriteGraphStream(ctx, b.storage, treehashPath, responses)

The proto response is not Tango's API response, but it stays in GetTargetGraph and used as the input to a storage API. So orchestrator package already depends on proto from other things and this PR isn't adding it. If we wanted to remove the proto dependency we need to have entities defined so orchestrator (and its deps) only works with those types, and the mapping logic moved to mapper (this function combines processing targethasher result to optimized targets then turning that into proto response). We already have work items that will cover those things, so my intention here is just moving the function out of common package to a more appropriate package, then the fixes come later. If you guys would prefer fixing it first, then moving it, we can do that too.

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.

3 participants