Skip to content

Commit

Permalink
feat(turborepo): Set feature to use Go daemon (#5147)
Browse files Browse the repository at this point in the history
Co-authored-by: Greg Soltis <Greg Soltis>
Co-authored-by: Chris Olszewski <chris.olszewski@vercel.com>
  • Loading branch information
Greg Soltis and chris-olszewski committed May 31, 2023
1 parent 9f86f2e commit ff8aea1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions cli/internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type Server struct {
repoRoot turbopath.AbsoluteSystemPath
closerMu sync.Mutex
closer *closer
timeSavedMu sync.Mutex
timesSaved map[string]uint64
}

// GRPCServer is the interface that the turbo server needs to the underlying
Expand Down Expand Up @@ -82,6 +84,7 @@ func New(serverName string, logger hclog.Logger, repoRoot turbopath.AbsoluteSyst
started: time.Now(),
logFilePath: logFilePath,
repoRoot: repoRoot,
timesSaved: map[string]uint64{},
}
server.watcher.AddClient(cookieJar)
server.watcher.AddClient(globWatcher)
Expand Down Expand Up @@ -137,6 +140,9 @@ func (s *Server) Register(grpcServer GRPCServer) {

// NotifyOutputsWritten implements the NotifyOutputsWritten rpc from turbo.proto
func (s *Server) NotifyOutputsWritten(ctx context.Context, req *turbodprotocol.NotifyOutputsWrittenRequest) (*turbodprotocol.NotifyOutputsWrittenResponse, error) {
s.timeSavedMu.Lock()
s.timesSaved[req.Hash] = req.TimeSaved
s.timeSavedMu.Unlock()
outputs := fs.TaskOutputs{
Inclusions: req.OutputGlobs,
Exclusions: req.OutputExclusionGlobs,
Expand All @@ -151,13 +157,17 @@ func (s *Server) NotifyOutputsWritten(ctx context.Context, req *turbodprotocol.N

// GetChangedOutputs implements the GetChangedOutputs rpc from turbo.proto
func (s *Server) GetChangedOutputs(ctx context.Context, req *turbodprotocol.GetChangedOutputsRequest) (*turbodprotocol.GetChangedOutputsResponse, error) {
s.timeSavedMu.Lock()
timeSaved := s.timesSaved[req.Hash]
s.timeSavedMu.Unlock()

changedGlobs, err := s.globWatcher.GetChangedGlobs(req.Hash, req.OutputGlobs)
if err != nil {
return nil, err
}
return &turbodprotocol.GetChangedOutputsResponse{
ChangedOutputGlobs: changedGlobs,
TimeSaved: timeSaved,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "MPL-2.0"
[features]
# Allows configuring a specific tls backend for reqwest.
# See top level Cargo.toml for more details.
default = ["rustls-tls"]
default = ["rustls-tls", "go-daemon"]
native-tls = ["turborepo-api-client/native-tls", "turbo-updater/native-tls"]
rustls-tls = ["turborepo-api-client/rustls-tls", "turbo-updater/rustls-tls"]
run-stub = []
Expand Down

0 comments on commit ff8aea1

Please sign in to comment.