Documentation ¶
Index ¶
Constants ¶
const ( DefaultNumWorkers = 10 // This is the key used in context.Value to determine whether // "--download-topcs" should not be added to "gclient sync". SkipDownloadTopicsKey = "skia_infra_skip_download_topics" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LazyTempGitRepo ¶
type LazyTempGitRepo struct {
// contains filtered or unexported fields
}
LazyTempGitRepo is a struct which performs a TempGitRepo only when requested. Intended to be used by multiple users which may or may not need the TempCheckout. Guaranteed to only call TempGitRepo once. Callers MUST call Done() or one of the Syncer's worker goroutines will become permanently stuck.
func (*LazyTempGitRepo) Do ¶
func (r *LazyTempGitRepo) Do(ctx context.Context, fn func(*git.TempCheckout) error) error
Do checks out a TempGitRepo and runs the given function. Returns any error encountered while performing the checkout or the error returned by the passed-in func. The passed-in func is run after all of the checkout work is complete; if the func runs, then the checkout is guaranteed to have completed successfully. Similarly, if the passed-in func returns no error and Do() returns an error, it is because of a failure during checkout. It is safe to write into the parent of the repo dir, as that is a temporary directory which will be cleaned up.
func (*LazyTempGitRepo) Done ¶
func (r *LazyTempGitRepo) Done()
Done frees up the worker goroutine used by this LazyTempGitRepo. Done must be called exactly once per LazyTempGitRepo instance, after all calls to Do().
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
Syncer is a struct used for syncing code to particular RepoStates.
func New ¶
func New(ctx context.Context, repos repograph.Map, depotToolsDir, workdir string, numWorkers int) *Syncer
New returns a Syncer instance.
func (*Syncer) LazyTempGitRepo ¶
func (s *Syncer) LazyTempGitRepo(rs types.RepoState) *LazyTempGitRepo
LazyTempGitRepo returns a LazyTempGitRepo instance. The caller must call Done() exactly once on the LazyTempGitRepo, after all calls to Do(), in order to free up the worker goroutine.
func (*Syncer) TempGitRepo ¶
func (s *Syncer) TempGitRepo(ctx context.Context, rs types.RepoState, fn func(*git.TempCheckout) error) error
TempGitRepo creates a git repository in a subdirectory of a temporary directory, gets it into the given RepoState, and runs the given function inside the repo dir. It is safe to write into the parent of the repo dir, as that is a temporary directory which will be cleaned up.
This method uses a worker pool; if all workers are busy, it will block until one is free.