errorutil

package
v0.0.0-...-1dc08c0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsError

func IsError(err error, re string) bool

IsError returns true if the error string matches the supplied regex. An empty regex is interpreted to mean that a nil error is expected.

func SendReport

func SendReport(ctx context.Context, sv *settings.Values, err error)

SendReport creates a Sentry report about the error, if the settings allow. The format string will be reproduced ad litteram in the report; the arguments will be sanitized.

func ShouldCatch

func ShouldCatch(obj interface{}) (ok bool, err error)

ShouldCatch is used for catching errors thrown as panics. Its argument is the object returned by recover(); it succeeds if the object is an error. If the error is a runtime.Error, it is converted to an internal error (see errors.AssertionFailedf).

func UnexpectedWithIssueErrorf

func UnexpectedWithIssueErrorf(issue int, format string, args ...interface{}) error

UnexpectedWithIssueErrorf indicates an error with an associated Github issue. It's supposed to be used for conditions that would otherwise be checked by assertions, except that they fail and we need the public's help for tracking it down. The error message will invite users to report repros.

func UnsupportedWithMultiTenancy

func UnsupportedWithMultiTenancy(issues ...int) error

UnsupportedWithMultiTenancy returns an error suitable for returning when an operation could not be carried out due to the SQL server running in multi-tenancy mode. In that mode, Gossip and other components of the KV layer are not available.

Types

type TenantSQLDeprecatedWrapper

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

TenantSQLDeprecatedWrapper is a helper to annotate uses of components that are in the progress of being phased out due to work towards multi-tenancy. It is usually usually used under a layer of abstraction that is aware of the wrapped object's type.

Deprecated objects are broadly objects that reach deeply into the KV layer and which will be inaccessible from a SQL tenant server. Their uses in SQL fall into two categories:

  • functionality essential for multi-tenancy, i.e. a use which will have to be removed before we can start SQL tenant servers.
  • non-essential functionality, which will be disabled when run in a SQL tenant server. It may or may not be a long-term goal to remove this usage; this is determined on a case-by-case basis.

As work towards multi-tenancy is taking place, semi-dedicated SQL tenant servers are supported. These are essentially SQL tenant servers that get to reach into the KV layer as needed while the first category above is being whittled down.

This wrapper aids that process by offering two methods corresponding to the categories above:

Deprecated() trades in a reference to Github issue (tracking the removal of an essential usage) for the wrapped object; OptionalErr() returns the wrapped object only if the wrapper was set up to allow this.

Note that the wrapped object will in fact always have to be present as long as calls to Deprecated() exist. However, when running semi-dedicated SQL tenants, the wrapper should be set up with exposed=false so that it can pretend that the object is in fact not available.

Finally, once all Deprecated() calls have been removed, it is possible to treat the wrapper as a pure option type, i.e. wrap a nil value with exposed=false.

func MakeTenantSQLDeprecatedWrapper

func MakeTenantSQLDeprecatedWrapper(v interface{}, exposed bool) TenantSQLDeprecatedWrapper

MakeTenantSQLDeprecatedWrapper wraps an arbitrary object. When the 'exposed' parameter is set to true, Optional() will return the object.

func (TenantSQLDeprecatedWrapper) Deprecated

func (w TenantSQLDeprecatedWrapper) Deprecated(issueNo int) interface{}

Deprecated returns the unwrapped object. It takes an issue number that should contain a work item resulting in the removal of the Deprecated() call (i.e. removes the dependency on the wrapped object).

func (TenantSQLDeprecatedWrapper) Optional

func (w TenantSQLDeprecatedWrapper) Optional() (interface{}, bool)

Optional returns the wrapped object if it is available (meaning that the wrapper was set up to make it available). This should be called by functionality that relies on the wrapped object but can be disabled when this is desired.

Optional functionality should be used sparingly as it increases the maintenance and testing burden. It is preferable to use OptionalErr() (and return the error) where possible.

func (TenantSQLDeprecatedWrapper) OptionalErr

func (w TenantSQLDeprecatedWrapper) OptionalErr(issueNos ...int) (interface{}, error)

OptionalErr calls Optional and returns an error (referring to the optionally supplied Github issues) if the wrapped object is not available.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL