Documentation

Overview

    Package common implements code and utilities shared across all packages in client/.

    Index

    Examples

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func IsTerminal

    func IsTerminal(out io.Writer) bool

      IsTerminal returns true if the specified io.Writer is a terminal.

      func WalkFuncSkipFile

      func WalkFuncSkipFile(file os.FileInfo) error

        WalkFuncSkipFile is a helper for implementations of filepath.WalkFunc. The value that it returns may in turn be returned by the WalkFunc implementatiton to indicate that file should be skipped.

        Types

        type FilesystemView

        type FilesystemView struct {
        	// contains filtered or unexported fields
        }

          FilesystemView provides a filtered "view" of a filesystem. It translates absolute paths to relative paths based on its configured root path.

          func NewFilesystemView

          func NewFilesystemView(root string, ignoredPathRe string) (FilesystemView, error)

            NewFilesystemView returns a FilesystemView based on the supplied root, or an error if ignoredPathRe contains a bad pattern.

            root is the the base path used by RelativePath to calculate relative paths.

            ignoredPathRe is a regular expression string. Note that this is NOT a full string match, so "foo/.*" may match "bar/foo/xyz". Prepend ^ explicitly if you need to match a path that starts with the pattern. Similarly, append $ if necessary.

            func (FilesystemView) NewSymlinkedView

            func (ff FilesystemView) NewSymlinkedView(source, linkname string) FilesystemView

              NewSymlinkedView returns a filesystem view from a symlinked directory within itself.

              func (FilesystemView) RelativePath

              func (ff FilesystemView) RelativePath(path string) (string, error)

                RelativePath returns a version of path which is relative to the FilesystemView root or an empty string if path matches a ignored path filter.

                type Flags

                type Flags struct {
                	Quiet   bool
                	Verbose bool
                }

                  Flags contains values parsed from command line arguments.

                  func (*Flags) Init

                  func (d *Flags) Init(f *flag.FlagSet)

                    Init registers flags in a given flag set.

                    func (*Flags) MakeLoggingContext

                    func (d *Flags) MakeLoggingContext(out io.Writer) context.Context

                      MakeLoggingContext makes a luci-go/common/logging compatible context using gologger onto the given writer.

                      The default logging level will be Info, with Warning and Debug corresponding to quiet/verbose respectively.

                      func (*Flags) Parse

                      func (d *Flags) Parse() error

                        Parse applies changes specified by command line flags.

                        type GoroutinePool

                        type GoroutinePool struct {
                        	// contains filtered or unexported fields
                        }

                          GoroutinePool executes at a limited number of jobs concurrently, queueing others.

                          func NewGoroutinePool

                          func NewGoroutinePool(ctx context.Context, maxConcurrentJobs int) *GoroutinePool

                            NewGoroutinePool creates a new GoroutinePool running at most maxConcurrentJobs concurrent operations.

                            Example
                            Output:
                            
                            knock!knock!
                            canceled because context canceled
                            all jobs either executed or canceled (context canceled)
                            

                            func (*GoroutinePool) Schedule

                            func (g *GoroutinePool) Schedule(job, onCanceled func())

                              Schedule adds a new job for execution as a separate goroutine.

                              If the GoroutinePool context is canceled, onCanceled is called instead. It is fine to pass nil as onCanceled.

                              func (*GoroutinePool) Wait

                              func (g *GoroutinePool) Wait() error

                                Wait blocks until all started jobs are done, or the context is canceled.

                                Returns nil if all jobs have been executed, or the error if the associated context is canceled.

                                type GoroutinePriorityPool

                                type GoroutinePriorityPool struct {
                                	// contains filtered or unexported fields
                                }

                                  GoroutinePriorityPool executes a limited number of jobs concurrently, queueing others.

                                  func NewGoroutinePriorityPool

                                  func NewGoroutinePriorityPool(ctx context.Context, maxConcurrentJobs int) *GoroutinePriorityPool

                                    NewGoroutinePriorityPool creates a new goroutine pool with at most maxConcurrentJobs.

                                    Each task is run according to the priority of each item.

                                    func (*GoroutinePriorityPool) Schedule

                                    func (g *GoroutinePriorityPool) Schedule(priority int64, job, onCanceled func())

                                      Schedule adds a new job for execution as a separate goroutine.

                                      If the GoroutinePriorityPool is canceled, onCanceled is called instead. It is fine to pass nil as onCanceled. Smaller values of priority imply earlier execution.

                                      The lower the priority value, the higher the priority of the item.

                                      func (*GoroutinePriorityPool) Wait

                                      func (g *GoroutinePriorityPool) Wait() error

                                        Wait blocks until all started jobs are done, or the context is canceled.

                                        Returns nil if all jobs have been executed, or the error if the associated context is canceled.

                                        type Strings

                                        type Strings []string

                                          Strings accumulates string values from repeated flags.

                                          Use with flag.Var to accumulate values from "-flag s1 -flag s2".

                                          func (*Strings) Set

                                          func (c *Strings) Set(value string) error

                                            Set is needed to implements flag.Var interface.

                                            func (*Strings) String

                                            func (c *Strings) String() string
                                            GOOS=linux, GOARCH=amd64