errorutil

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const FeatureNotAvailableToNonSystemTenantsIssue = 54252

FeatureNotAvailableToNonSystemTenantsIssue is to be used with the Optional and related error interfaces when a feature is simply not available to non-system tenants (i.e. we're not planning to change this). For all other multitenancy errors where there is a plan to improve the situation, a specific issue should be created instead.

Variables

This section is empty.

Functions

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(issue 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) 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(issue 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