Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteOldLogFiles(d time.Duration, dir string)
- func IdleTimeout(ctx context.Context, timeout time.Duration)
- func StashFiles(paths []string) func()
- type Executor
- type Forecast
- type LocalPool
- type Server
- func (s *Server) AddProxyEvents(ctx context.Context, req *ppb.AddProxyEventsRequest) (*ppb.AddProxyEventsResponse, error)
- func (s *Server) DrainAndReleaseResources()
- func (s *Server) GetRecords(ctx context.Context, req *ppb.GetRecordsRequest) (*ppb.GetRecordsResponse, error)
- func (s *Server) Init()
- func (s *Server) MonitorFailBuildConditions(ctx context.Context)
- func (s *Server) RunCommand(ctx context.Context, req *ppb.RunRequest) (*ppb.RunResponse, error)
- func (s *Server) SetInputProcessor(ip *inputprocessor.InputProcessor, cleanup func())
- func (s *Server) SetREClient(rclient *rexec.Client, cleanup func())
- func (s *Server) SetStartupErr(err error)
- func (s *Server) Shutdown(ctx context.Context, req *ppb.ShutdownRequest) (*ppb.ShutdownResponse, error)
- func (s *Server) WaitForCleanupDone() <-chan bool
- func (s *Server) WaitForShutdownCommand() <-chan bool
Constants ¶
const ( // ReclientTimeoutExitCode is an exit code corresponding to a timeout within reproxy ReclientTimeoutExitCode = command.RemoteErrorExitCode + 14 )
Variables ¶
var ( // AllowedIPTimeouts is the max number of IP timeouts before failing the build AllowedIPTimeouts = int64(7) )
Functions ¶
func DeleteOldLogFiles ¶
DeleteOldLogFiles removes RE tooling log files older than d from dir.
func IdleTimeout ¶
IdleTimeout checks the latest request received timestamp and sends a SIGINT signal if last request received is greater than the expected idle timeout.
func StashFiles ¶
func StashFiles(paths []string) func()
StashFiles copies the given files to a temporary location. It returns a function that restores the original files.
Types ¶
type Executor ¶
type Executor interface { // ExecuteWithOutErr runs the given command inside the working directory. ExecuteWithOutErr(ctx context.Context, cmd *command.Command, oe outerr.OutErr) error }
Executor can run commands and retrieve their outputs.
type Forecast ¶
type Forecast struct {
// contains filtered or unexported fields
}
Forecast is responsible for forecasting specific parameters of an action based on historical data.
func (*Forecast) PercentileDownloadLatency ¶
PercentileDownloadLatency returns the expected pth percentile download latency of the given action.
func (*Forecast) RecordSample ¶
func (f *Forecast) RecordSample(a *action)
RecordSample stores a sample from an action to be used to forecast future behavior.
type LocalPool ¶
type LocalPool struct {
// contains filtered or unexported fields
}
LocalPool is responsible for executing commands locally.
func NewLocalPool ¶
func NewLocalPool(exec Executor, resMgr *localresources.Manager) *LocalPool
NewLocalPool creates a pool with the given args.
func (*LocalPool) Run ¶
func (l *LocalPool) Run(ctx, cCtx context.Context, cmd *command.Command, lbls map[string]string, oe outerr.OutErr, rec *logger.LogRecord) (int, error)
Run runs a command locally. Returns the stdout, stderr, exit code, and error in case more information about the failure is needed.
type Server ¶
type Server struct { InputProcessor *inputprocessor.InputProcessor FileMetadataStore filemetadata.Cache REClient *rexec.Client LocalPool *LocalPool Logger *logger.Logger KeepLastRecords int CacheSilo string VersionCacheSilo bool RemoteDisabled bool DumpInputTree bool Forecast *Forecast StartTime time.Time FailEarlyMinActionCount int64 FailEarlyMinFallbackRatio float64 FailEarlyWindow time.Duration RacingBias float64 DownloadTmp string MaxHoldoff time.Duration // Maximum amount of time to wait for downloads before starting racing. StartupCancelFn func() // contains filtered or unexported fields }
Server is the server responsible for executing and retrieving results of RunRequests.
func (*Server) AddProxyEvents ¶
func (s *Server) AddProxyEvents(ctx context.Context, req *ppb.AddProxyEventsRequest) (*ppb.AddProxyEventsResponse, error)
AddProxyEvents saves the provided event times to the proxy level metrics. This method returns immediately and event times are added asynchronously to not block startup.
func (*Server) DrainAndReleaseResources ¶
func (s *Server) DrainAndReleaseResources()
DrainAndReleaseResources closes all external resources, cancels all inflight RunCommand rpcs and prevents future RunCommand rpcs in preparation for server exit. s.stats is populated with aggregated build metrics. All calls after the first are noops.
func (*Server) GetRecords ¶
func (s *Server) GetRecords(ctx context.Context, req *ppb.GetRecordsRequest) (*ppb.GetRecordsResponse, error)
GetRecords returns the latest saved LogRecords.
func (*Server) Init ¶
func (s *Server) Init()
Init initializes internal state and should only be called once.
func (*Server) MonitorFailBuildConditions ¶
MonitorFailBuildConditions monitors fail early conditions. If conditions such as ratio of fallbacks to total actions periodically or number of IP timeouts are exceeded, it sets failBuild flag and failBuildErr. If fail early is disabled the function returns immediately. Should be run in a goroutine.
func (*Server) RunCommand ¶
func (s *Server) RunCommand(ctx context.Context, req *ppb.RunRequest) (*ppb.RunResponse, error)
RunCommand runs a command according to the parameters defined in the RunRequest.
func (*Server) SetInputProcessor ¶
func (s *Server) SetInputProcessor(ip *inputprocessor.InputProcessor, cleanup func())
SetInputProcessor sets the InputProcessor property of Server and then unblocks startup. cleanup will be run in Server.DrainAndReleaseResources()
func (*Server) SetREClient ¶
SetREClient sets the REClient property of Server and then unblocks startup. If rclient.GrpcClient is not nil then rclient.GrpcClient will be closed in Server.DrainAndReleaseResources()
func (*Server) SetStartupErr ¶
SetStartupErr saves the first error that happens during async startup and then unblocks startup.
func (*Server) Shutdown ¶
func (s *Server) Shutdown(ctx context.Context, req *ppb.ShutdownRequest) (*ppb.ShutdownResponse, error)
Shutdown shuts the server down gracefully.
func (*Server) WaitForCleanupDone ¶
WaitForCleanupDone returns a channel that is closed when all cleanup has been completed.
func (*Server) WaitForShutdownCommand ¶
WaitForShutdownCommand returns a channel that is closed when a shutdown command is recieved.