blaze

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

README

blaze

The blaze rpc framework

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsError

func IsError(err error) bool

IsError checks if the passed error is a blaze error

func ServerBadRouteError

func ServerBadRouteError(msg string, method, url string) error

ServerBadRouteError is used when the blaze server cannot route a request

func ServerEnsurePanicResponses

func ServerEnsurePanicResponses(ctx context.Context, resp http.ResponseWriter, log logr.Logger)

ServerEnsurePanicResponses esure panic responses

func ServerHTTPStatusFromErrorType

func ServerHTTPStatusFromErrorType(err error) int

ServerHTTPStatusFromErrorType maps a blaze error type into a similar HTTP response status. It is used by the blaze server handler to set the HTTP response status code. Returns 0 if the error is not a blaze error.

func ServerInvalidRequestError

func ServerInvalidRequestError(argument string, validationMsg string, method, url string) error

ServerInvalidRequestError is used when the server is called with an invalid argument

func ServerWriteError

func ServerWriteError(ctx context.Context, resp http.ResponseWriter, err error, log logr.Logger)

ServerWriteError writes Blaze errors in the response and triggers hooks.

Types

type AbortedErrorType

type AbortedErrorType struct{}

AbortedErrorType indicates the operation was aborted, typically due to a concurrency issue like sequencer check failures, transaction aborts, etc.

func (*AbortedErrorType) Error

func (e *AbortedErrorType) Error() string

type AlreadyExistsErrorType

type AlreadyExistsErrorType struct{}

AlreadyExistsErrorType means an attempt to create an entity failed because one already exists

func (*AlreadyExistsErrorType) Error

func (e *AlreadyExistsErrorType) Error() string

type BadRouteErrorType

type BadRouteErrorType struct{}

BadRouteErrorType means that the requested URL path wasn't routable to a blaze service and method. This is returned by the generated server, and usually shouldn't be returned by applications. Instead, applications should use NotFound or Unimplemented.

func (*BadRouteErrorType) Error

func (e *BadRouteErrorType) Error() string

type CanceledErrorType

type CanceledErrorType struct{}

CanceledErrorType indicates the operation was cancelled (typically by the caller).

func (*CanceledErrorType) Error

func (e *CanceledErrorType) Error() string

type DataLossErrorType

type DataLossErrorType struct{}

DataLossErrorType indicates unrecoverable data loss or corruption.

func (*DataLossErrorType) Error

func (e *DataLossErrorType) Error() string

type DeadlineExceededErrorType

type DeadlineExceededErrorType struct{}

DeadlineExceededErrorType means operation expired before completion. For operations that change the state of the system, this error may be returned even if the operation has completed successfully (timeout).

func (*DeadlineExceededErrorType) Error

func (e *DeadlineExceededErrorType) Error() string

type Error

type Error interface {
	// Type returns the type of the error
	Type() string
	// Msg returns a human-readable, unstructured messages describing the error.
	Msg() string

	// WithMeta returns a copy of the Error with the given key-value pair attached
	// as metadata. If the key is already set, it is overwritten.
	WithMeta(key string, val string) Error

	// Meta returns the stored value for the given key. If the key has no set
	// value, Meta returns an empty string. There is no way to distinguish between
	// an unset value and an explicit empty string.
	Meta(key string) string

	// MetaMap returns a copy of the complete key-value metadata map stored on the error.
	MetaMap() map[string]string

	// Error returns a string of the form "blaze error <Type>: <Msg>"
	Error() string

	//Unwrap returns the wrapped error
	Unwrap() error
}

Error represents an error in a Blaze service call.

func ErrorAborted

func ErrorAborted() Error

ErrorAborted constructs a aborted error

func ErrorAlreadyExists

func ErrorAlreadyExists() Error

ErrorAlreadyExists constructs a already exists error

func ErrorBadRoute

func ErrorBadRoute(msg string) Error

ErrorBadRoute constructs bad route error

func ErrorCanceled

func ErrorCanceled() Error

ErrorCanceled constructs a canceled error

func ErrorDataLoss

func ErrorDataLoss() Error

ErrorDataLoss constructs a data loss error

func ErrorDeadlineExeeded

func ErrorDeadlineExeeded() Error

ErrorDeadlineExeeded constructs a canceled error

func ErrorFailedPrecondition

func ErrorFailedPrecondition() Error

ErrorFailedPrecondition constructs a failed precondition error

func ErrorInternal

func ErrorInternal(msg string) Error

ErrorInternal When some invariants expected by the underlying system have been broken. In other words, something bad happened in the library or backend service. Do not confuse with HTTP Internal Server Error; an Internal error could also happen on the client code, i.e. when parsing a server response.

func ErrorInternalWith

func ErrorInternalWith(err error, msg string) Error

ErrorInternalWith When some invariants expected by the underlying system have been broken. In other words, something bad happened in the library or backend service. Do not confuse with HTTP Internal Server Error; an Internal error could also happen on the client code, i.e. when parsing a server response. Wraps an other error for more information

func ErrorInvalidArgument

func ErrorInvalidArgument(argument string, validationMsg string) Error

ErrorInvalidArgument constructs invalid argument error

func ErrorMalformed

func ErrorMalformed(msg string) Error

ErrorMalformed constructs a malformed error

func ErrorNotFound

func ErrorNotFound() Error

ErrorNotFound constructs a canceled error

func ErrorOutOfRange

func ErrorOutOfRange() Error

ErrorOutOfRange constructs a out of range error

func ErrorPermissionDenied

func ErrorPermissionDenied() Error

ErrorPermissionDenied constructs a already exists error

func ErrorRequiredArgument

func ErrorRequiredArgument(argument string) Error

ErrorRequiredArgument is a more specific constructor for ErrorInvalidArgument. Should be used when the argument is required (expected to have a non-zero value).

func ErrorResourceExhausted

func ErrorResourceExhausted() Error

ErrorResourceExhausted constructs a resource exhousted error

func ErrorUnauthenticated

func ErrorUnauthenticated() Error

ErrorUnauthenticated constructs a unauthenticated error

func ErrorUnavailable

func ErrorUnavailable() Error

ErrorUnavailable constructs an unavailable error

func ErrorUnimplemented

func ErrorUnimplemented() Error

ErrorUnimplemented constructs an unimplemented error

func ErrorUnknown

func ErrorUnknown() Error

ErrorUnknown constructs a Unknown error

func NewError

func NewError(err error, msg string) Error

NewError is the generic constructor for a blaze.Error. The error must be one of the valid predefined ones in errors.go, otherwise it will be converted to an error {type: Internal, msg: "invalid error type {{code}}"}. If you need to add metadata, use .WithMeta(key, value) method after building the error.

type FailedPreconditionErrorType

type FailedPreconditionErrorType struct{}

FailedPreconditionErrorType indicates operation was rejected because the system is not in a state required for the operation's execution. For example, doing an rmdir operation on a directory that is non-empty, or on a non-directory object, or when having conflicting read-modify-write on the same resource.

func (*FailedPreconditionErrorType) Error

type InternalErrorType

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

InternalErrorType error is an error produced by a downstream dependency of blaze

func (*InternalErrorType) Error

func (e *InternalErrorType) Error() string

func (*InternalErrorType) Unwrap

func (e *InternalErrorType) Unwrap() error

Unwrap implements the wrappable error

type InvalidArgumentErrorType

type InvalidArgumentErrorType struct{}

InvalidArgumentErrorType indicates client specified an invalid argument. It indicates arguments that are problematic regardless of the state of the system (i.e. a malformed file name, required argument, number out of range, etc.).

func (*InvalidArgumentErrorType) Error

func (e *InvalidArgumentErrorType) Error() string

type MalformedErrorType

type MalformedErrorType struct{}

MalformedErrorType indicates an error occured while decoding the client's request. This means that the message was encoded improperly, or that there is an disagreement in message format between client and server

func (*MalformedErrorType) Error

func (e *MalformedErrorType) Error() string

type NotFoundErrorType

type NotFoundErrorType struct{}

NotFoundErrorType indicates a common NotFound error

func (*NotFoundErrorType) Error

func (e *NotFoundErrorType) Error() string

type OutOfRangeErrorType

type OutOfRangeErrorType struct{}

OutOfRangeErrorType means operation was attempted past the valid range. For example, seeking or reading past end of a paginated collection.

Unlike InvalidArgument, this error indicates a problem that may be fixed if the system state changes (i.e. adding more items to the collection).

There is a fair bit of overlap between FailedPrecondition and OutOfRange. We recommend using OutOfRange (the more specific error) when it applies so that callers who are iterating through a space can easily look for an OutOfRange error to detect when they are done.

func (*OutOfRangeErrorType) Error

func (e *OutOfRangeErrorType) Error() string

type PermissionDeniedErrorType

type PermissionDeniedErrorType struct{}

PermissionDeniedErrorType indicates the caller does not have permission to execute the specified operation. It must not be used if the caller cannot be identified (Unauthenticated).

func (*PermissionDeniedErrorType) Error

func (e *PermissionDeniedErrorType) Error() string

type ResourceExhaustedErrorType

type ResourceExhaustedErrorType struct{}

ResourceExhaustedErrorType indicates some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space.

func (*ResourceExhaustedErrorType) Error

type Server

type Server interface {
	Mux() *chi.Mux
	MountPath() string
}

Server defines the interface of blazeserver

type UnauthenticatedErrorType

type UnauthenticatedErrorType struct{}

UnauthenticatedErrorType indicates the request does not have valid authentication credentials for the operation.

func (*UnauthenticatedErrorType) Error

func (e *UnauthenticatedErrorType) Error() string

type UnavailableErrorType

type UnavailableErrorType struct{}

UnavailableErrorType indicates the service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff.

func (*UnavailableErrorType) Error

func (e *UnavailableErrorType) Error() string

type UnimplementedErrorType

type UnimplementedErrorType struct{}

UnimplementedErrorType indicates operation is not implemented or not supported/enabled in this service.

func (*UnimplementedErrorType) Error

func (e *UnimplementedErrorType) Error() string

type UnknownErrorType

type UnknownErrorType struct{}

UnknownErrorType For example handling errors raised by APIs that dont return enough error information

func (*UnknownErrorType) Error

func (e *UnknownErrorType) Error() string

Directories

Path Synopsis
cmd
internal
pkg

Jump to

Keyboard shortcuts

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