Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions controller/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go_library(
srcs = [
"controller.go",
"distance_filter.go",
"getchangedtargetgraph.go",
"getchangedtargets.go",
"gettargetgraph.go",
"metrics.go",
Expand All @@ -31,7 +30,6 @@ go_library(
"//tangopb",
"@com_github_uber_go_tally//:tally",
"@org_uber_go_fx//:fx",
"@org_uber_go_yarpc//yarpcerrors",
"@org_uber_go_zap//:zap",
],
)
Expand Down
6 changes: 4 additions & 2 deletions controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ response streaming.
The package is intentionally thin. It owns the cross-cutting concerns that
sit between the wire protocol and the rest of the system:

- **Request validation and translation.** Each RPC validates its inputs and
normalizes them into the internal call shapes used downstream.
- **Request validation and translation.** GetChangedTargets validates its
inputs and normalizes them into the internal call shapes used downstream.
GetTargetGraph receives an entity request and the resolved repository
configuration from the handler, which maps and validates the request.
- **Read-through caching.** Where a request can be satisfied from previously
computed artifacts, the controller fetches them from storage and streams
them back without invoking the orchestrator. Cache misses fall through to
Expand Down
7 changes: 5 additions & 2 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/uber/tango/config"
tangoerrors "github.com/uber/tango/core/errors"
"github.com/uber/tango/core/storage"
"github.com/uber/tango/entity"
"github.com/uber/tango/observability/metrics"
"github.com/uber/tango/orchestrator"
pb "github.com/uber/tango/tangopb"
Expand Down Expand Up @@ -81,9 +82,11 @@ type controller struct {
appCtx context.Context
}

// Controller is the service implementation the handler depends on.
// Controller is the business-logic surface the handler depends on. repo is the
// configured repository that the handler resolved for the request.
type Controller interface {
pb.TangoYARPCServer
GetTargetGraph(request entity.GetTargetGraphRequest, outputConfig *pb.OutputConfig, stream pb.TangoServiceGetTargetGraphYARPCServer, repo config.RepositoryConfig) error
GetChangedTargets(request *pb.GetChangedTargetsRequest, stream pb.TangoServiceGetChangedTargetsYARPCServer) error
}

// NewController creates a new controller. appCtx is cancelled on process
Expand Down
2 changes: 2 additions & 0 deletions controller/controllermock/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ go_library(
importpath = "github.com/uber/tango/controller/controllermock",
visibility = ["//visibility:public"],
deps = [
"//config",
"//entity",
"//tangopb",
"@org_uber_go_mock//gomock",
],
Expand Down
32 changes: 10 additions & 22 deletions controller/controllermock/controllermock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 0 additions & 31 deletions controller/getchangedtargetgraph.go

This file was deleted.

18 changes: 5 additions & 13 deletions controller/gettargetgraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,16 @@ import (
"go.uber.org/zap"
)

// GetTargetGraph returns the target graph for a given request.
func (c *controller) GetTargetGraph(request *pb.GetTargetGraphRequest, stream pb.TangoServiceGetTargetGraphYARPCServer) error {
entityReq, mappingErr := mapper.ProtoToGetTargetGraphRequest(request)
if mappingErr != nil {
mappingErr = tangoerrors.NewUser(fmt.Errorf("convert get target graph request: %w", mappingErr))
}
repoCfg, repo, repositoryErr := c.resolveRequestRepository(entityReq.Build.Remote, mappingErr)
e := c.emitter.Tagged(map[string]string{metrics.TagRepo: repo})
// GetTargetGraph streams the target graph for a given request. repoCfg is the
// configured repository that the caller resolved for the request.
func (c *controller) GetTargetGraph(entityReq entity.GetTargetGraphRequest, outputConfig *pb.OutputConfig, stream pb.TangoServiceGetTargetGraphYARPCServer, repoCfg config.RepositoryConfig) error {
e := c.emitter.Tagged(map[string]string{metrics.TagRepo: repoCfg.RepositoryID})
logger := c.logger.WithLazy(
zap.String("repository", repo),
zap.String("repository", repoCfg.RepositoryID),
)
start := time.Now()
ctx, cancelLink := c.linkRequestCtx(stream.Context())
defer cancelLink()
if repositoryErr != nil {
return repositoryErr
}
graphReader, err := c.getGraph(ctx, e, entityReq, repoCfg.RepositoryID)
if err != nil {
return fmt.Errorf("get graph: %w", err)
Expand All @@ -60,7 +53,6 @@ func (c *controller) GetTargetGraph(request *pb.GetTargetGraphRequest, stream pb
}
defer func() { _ = graphReader.Close() }()
sendStart := time.Now()
outputConfig := request.GetOutputConfig()
for {
chunk, err := graphReader.Read()
if err == io.EOF {
Expand Down
Loading
Loading