[errors] de-specialize Transient in favor of Tags.

Previously 'transience' was a hard-coded attribute of the errors package. This
change adds 'tags' as a way to put attributes (potentially with some data) onto an
error as it goes up the stack.

This removes multiple symbols from the errors package (the stack context stuff
is now an implementation detail, tags are better than ExtractData).

The 'transience' bit has now moved to the 'common/retry/transient' package.
Marking an error as transient is now `err = transient.Tag.Apply(err)`, or
`errors.Annotate(err).Tag(transient.Tag).Err()` (as part of another batch
of annotations).

API Review in a Nutshell:
  // for simple 'boolean' tags, where presence is the only important piece of
  // information.
  var FatalTag = errors.BoolTag{errors.NewTagKey("this is a fatal error!")}

  func (...) error {
    return FatalTag.Apply(err)
  }

  func (...) {
    if FatalTag.In(err) {
      os.Exit(-1)
    }
  }

  // tags may also have associated typesafe values
  type Severity int
  type severityTagType struct {Key errors.TagKey}
  func (t severityTagType) With(s Severity) errors.TagValue { return errors.MkTagValue(t.Key, s) }
  func (t severityTagType) In(err error) (s Severity, ok bool) {
    d, ok := errors.TagValueIn(t.Key, err)
    if ok {
      s = d.(Severity)
    }
    return
  }
  var SeverityTag = severityTagType{errors.NewTagKey("holds a Severity value")}

  func (...) error {
    return SeverityTag.With(Severity(10)).Apply(err)
  }

  func (...) {
    if s, hasSeverity := SeverityTag.In(err); hasSeverity {
      if s.(Severity) > 9000 {
        fmt.Println("it's pretty severe")
      }
    }
  }

BUG=

Review-Url: https://codereview.chromium.org/2951393002
104 files changed
tree: 5d51e928ecb18f1853f998b1ace5a9f37109d257
  1. appengine/
  2. buildbucket/
  3. cipd/
  4. client/
  5. common/
  6. deploytool/
  7. dm/
  8. examples/
  9. grpc/
  10. hardcoded/
  11. infra/
  12. logdog/
  13. luci_config/
  14. lucictx/
  15. milo/
  16. scheduler/
  17. scripts/
  18. server/
  19. swarming/
  20. tokenserver/
  21. tools/
  22. tumble/
  23. vpython/
  24. web/
  25. .travis.yml
  26. AUTHORS
  27. codereview.settings
  28. CONTRIBUTORS
  29. LICENSE
  30. luci-deploy.cfg
  31. pre-commit-go.yml
  32. PRESUBMIT.py
  33. README.md
  34. WATCHLISTS
README.md

luci-go: LUCI services and tools in Go

GoDoc Build Status Coverage Status

Installing

go get -u github.com/luci/luci-go/client/cmd/...
go get -u github.com/luci/luci-go/server/cmd/...

Code layout

  • /appengine/... contains AppEngine server code. It imports packages from /common/... and /server/....
  • /client/... contains all client code.
  • /common/... contains code and structures shared between all of /appengine/..., /client/... and /server/...; for example, the structures used by the server APIs. These are inherently APIs.
  • /deploytool/... contains the LUCI cloud services deployment tool.
  • /logdog/... contains LogDog client and server code, as well as APIs, protobufs, and support libraries.
  • /server/... contains standalone server code. Its packages are reusable by /appengine/....
  • /tools/... contains support tools used by other LUCI components.

Versioning

  • Branch go1 contains the stable code.
  • Branch master constains the latest code.

Contributing

  • Sign the Google CLA.
  • Make sure your user.email and user.name are configured in git config.
  • Install test-only packages: go get -u -t github.com/luci/luci-go/client/...
  • Install the pcg git hook: go get -u github.com/maruel/pre-commit-go/cmd/... && pcg

Run the following to setup the code review tool and create your first review:

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $HOME/src/depot_tools
export PATH="$PATH:$HOME/src/depot_tools"
cd $GOROOT/github.com/luci/luci-go
git checkout -b work origin/master

# hack hack

git commit -a -m "This is awesome\nR=joe@example.com"
# This will ask for your Google Account credentials.
git cl upload -s
# Wait for LGTM over email.
# Check the commit queue box in codereview website.
# Wait for the change to be tested and landed automatically.

Use git cl help and git cl help <cmd> for more details.