Documentation
¶
Overview ¶
Code generated by fabricator-generate-go
Modifications in code regions will be lost during regeneration!
Index ¶
- func GetVersionYaml() []byte
- func GrpcCodeFromErrorType(err error) codes.Code
- func IsError(err error) bool
- func NewHTTPRequest(ctx context.Context, url string, reqBody io.Reader, contentType string, ...) (*http.Request, error)
- func NewTracingClient(client *http.Client) *http.Client
- func OtelCodeFromErrorType(err error) otelc.Code
- func ServerBadRouteError(msg string, method, url string) error
- func ServerEnsurePanicResponses(ctx context.Context, resp http.ResponseWriter, log logr.Logger)
- func ServerHTTPStatusFromErrorType(err error) int
- func ServerInvalidRequestError(argument string, validationMsg string, method, url string) error
- func ServerWriteError(ctx context.Context, resp http.ResponseWriter, err error, log logr.Logger)
- func UrlBase(addr string) string
- func WithoutRedirects(in *http.Client) *http.Client
- type AbortedErrorType
- type AlreadyExistsErrorType
- type BadRouteErrorType
- type CanceledErrorType
- type ClientOption
- type ClientOptions
- type DataLossErrorType
- type DeadlineExceededErrorType
- type Error
- func ErrorAborted(msg string) Error
- func ErrorAlreadyExists(msg string) Error
- func ErrorBadRoute(msg string) Error
- func ErrorCanceled(msg string) Error
- func ErrorDataLoss(msg string) Error
- func ErrorDeadlineExeeded(msg string) Error
- func ErrorFailedPrecondition(msg string) Error
- func ErrorFromResponse(resp *http.Response) Error
- func ErrorInternal(msg string) Error
- func ErrorInternalWith(err error, msg string) Error
- func ErrorInvalidArgument(argument string, validationMsg string) Error
- func ErrorJSONToError(j ErrorJSON) (Error, error)
- func ErrorMalformed(msg string) Error
- func ErrorNotFound(msg string) Error
- func ErrorOutOfRange(msg string) Error
- func ErrorPermissionDenied(msg string) Error
- func ErrorRequiredArgument(argument string) Error
- func ErrorResourceExhausted(msg string) Error
- func ErrorUnauthenticated(msg string) Error
- func ErrorUnavailable(msg string) Error
- func ErrorUnimplemented(msg string) Error
- func ErrorUnknown(msg string) Error
- func NewError(err error, msg string) Error
- type ErrorJSON
- type FailedPreconditionErrorType
- type HTTPClient
- type InternalErrorType
- type InvalidArgumentErrorType
- type MalformedErrorType
- type NotFoundErrorType
- type OutOfRangeErrorType
- type PermissionDeniedErrorType
- type ResourceExhaustedErrorType
- type Service
- type ServiceOption
- type ServiceOptions
- type UnauthenticatedErrorType
- type UnavailableErrorType
- type UnimplementedErrorType
- type UnknownErrorType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetVersionYaml ¶ added in v0.7.2
func GetVersionYaml() []byte
func GrpcCodeFromErrorType ¶ added in v0.0.5
GrpcCodeFromErrorType converts a blaze error into a grpc error code
func NewHTTPRequest ¶ added in v0.0.2
func NewHTTPRequest(ctx context.Context, url string, reqBody io.Reader, contentType string, version string) (*http.Request, error)
NewHTTPRequest creates a httprequest for a client, adding common headers.
func NewTracingClient ¶ added in v0.4.0
NewTracingClient is a convenience function to create an http client with tracing capabilities
func OtelCodeFromErrorType ¶ added in v0.3.0
OtelCodeFromErrorType converts to the open telemetry codes they are not using instead of GRPC.Code
func ServerBadRouteError ¶
ServerBadRouteError is used when the blaze server cannot route a request
func ServerEnsurePanicResponses ¶
ServerEnsurePanicResponses esure panic responses
func ServerHTTPStatusFromErrorType ¶
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 ¶
ServerInvalidRequestError is used when the server is called with an invalid argument
func ServerWriteError ¶
ServerWriteError writes Blaze errors in the response and triggers hooks.
func UrlBase ¶ added in v0.0.2
UrlBase helps ensure that addr specifies a scheme. If it is unparsable as a URL, it returns addr unchanged.
func WithoutRedirects ¶ added in v0.0.2
WithoutRedirects makes sure that the POST request can not be redirected. The standard library will, by default, redirect requests (including POSTs) if it gets a 302 or 303 response, and also 301s in go1.8. It redirects by making a second request, changing the method to GET and removing the body. This produces very confusing error messages, so instead we set a redirect policy that always errors. This stops Go from executing the redirect.
We have to be a little careful in case the user-provided http.Client has its own CheckRedirect policy - if so, we'll run through that policy first.
Because this requires modifying the http.Client, we make a new copy of the client and return it.
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 ClientOption ¶ added in v0.0.2
type ClientOption func(*ClientOptions)
ClientOption is a functional option for extending a Blaze client.
type ClientOptions ¶ added in v0.0.2
type ClientOptions struct { // Trace implementation for distributed tracing Trace blazetrace.ClientTracer }
ClientOptions encapsulate the configurable parameters on a Blaze client.
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 ErrorAlreadyExists ¶
ErrorAlreadyExists constructs a already exists error
func ErrorDataLoss ¶
ErrorDataLoss constructs a data loss error
func ErrorDeadlineExeeded ¶
ErrorDeadlineExeeded constructs a canceled error
func ErrorFailedPrecondition ¶
ErrorFailedPrecondition constructs a failed precondition error
func ErrorFromResponse ¶ added in v0.0.2
ErrorFromResponse builds a blaze.Error from a non-200 HTTP response. If the response has a valid serialized Blaze error, then it's returned. If not, the response status code is used to generate a similar Blaze error. See blazeErrorFromIntermediary for more info on intermediary errors.
func ErrorInternal ¶
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 ¶
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 ¶
ErrorInvalidArgument constructs invalid argument error
func ErrorJSONToError ¶ added in v0.0.2
ErrorJSONToError converts a ErrorJSON struct into an Error
func ErrorMalformed ¶
ErrorMalformed constructs a malformed error
func ErrorOutOfRange ¶
ErrorOutOfRange constructs a out of range error
func ErrorPermissionDenied ¶
ErrorPermissionDenied constructs a permission denied error
func ErrorRequiredArgument ¶
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 ¶
ErrorResourceExhausted constructs a resource exhousted error
func ErrorUnauthenticated ¶
ErrorUnauthenticated constructs a unauthenticated error
func ErrorUnavailable ¶
ErrorUnavailable constructs an unavailable error
func ErrorUnimplemented ¶
ErrorUnimplemented constructs an unimplemented error
func NewError ¶
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 ErrorJSON ¶ added in v0.0.2
type ErrorJSON struct { Code string `json:"code"` Msg string `json:"msg"` Type string `json:"blaze_type"` Meta map[string]string `json:"meta,omitempty"` }
ErrorJSON is JSON serialization for blaze errors
func ErrorToErrorJSON ¶ added in v0.0.2
ErrorToErrorJSON concerts a Error into a ErrorJSON struct
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 ¶
func (e *FailedPreconditionErrorType) Error() string
type HTTPClient ¶ added in v0.0.2
HTTPClient is the interface used by generated clients to send HTTP requests. It is fulfilled by *(net/http).Client, which is sufficient for most users. Users can provide their own implementation for special retry policies.
HTTPClient implementations should not follow redirects. Redirects are automatically disabled if *(net/http).Client is passed to client constructors. See the withoutRedirects function in this file for more details.
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 ¶
func (e *ResourceExhaustedErrorType) Error() string
type Service ¶ added in v0.0.4
type Service interface { Mux() *chi.Mux MountPath() string }
Service defines the interface of blazeservice
type ServiceOption ¶ added in v0.0.4
type ServiceOption func(*ServiceOptions)
ServiceOption is a functional option for extending a Blaze service.
func WithJSONEmitDefaults ¶ added in v0.0.3
func WithJSONEmitDefaults(v bool) ServiceOption
WithJSONEmitDefaults makes JSON structs to render fields even if they are empty or the default value
func WithJSONEnumsAsInts ¶ added in v0.0.3
func WithJSONEnumsAsInts(v bool) ServiceOption
WithJSONEnumsAsInts makes enums be rendered as ints instead of strings
func WithMux ¶ added in v0.0.3
func WithMux(mux *chi.Mux) ServiceOption
WithMux allows to set the chi mux to use by a service
func WithServiceTracer ¶ added in v0.0.5
func WithServiceTracer(trace blazetrace.ServiceTracer) ServiceOption
WithServiceTracer replaces the default tracer
type ServiceOptions ¶ added in v0.0.4
type ServiceOptions struct { // Uses a specific mux instead of chi.NewRouter() Mux *chi.Mux // Whether to render enum values as integers, as opposed to string values. JSONEnumsAsInts bool // Whether to render fields with zero values. JSONEmitDefaults bool // Trace implementation for distributed tracing Trace blazetrace.ServiceTracer }
ServiceOptions encapsulate the configurable parameters on a Blaze service.
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