app

package
v0.0.0-...-a53416d Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: MIT Imports: 3 Imported by: 0

README

APP package

TODO

Explain what it is.

Mix of domain and application logic - for simplicity. We could split this further - separate clean domain.

Errors

TODO

Explain custom errors, how do they help and the helper methods for them.

Ben has a good post about errors, and our errors.go file is exactly what he describes as "application role errors".

Logging

TODO

  1. Explain what is in log.go in context of passing trace id through context.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound represents all kind of problems resulting from not finding something.
	ErrNotFound = errors.New("not found")
)

Sentinel errors.

Functions

func AugmentLogFromCtx

func AugmentLogFromCtx(ctx context.Context, l logrus.FieldLogger) logrus.FieldLogger

AugmentLogFromCtx augments logger with data from context.

func CtxWithLogField

func CtxWithLogField(ctx context.Context, key string, value string) context.Context

CtxWithLogField adds extra log information to context.

func CtxWithTraceID

func CtxWithTraceID(ctx context.Context, id string) context.Context

CtxWithTraceID returns new context with trace id..

func IsConflictError

func IsConflictError(err error) bool

IsConflictError returns true if err has ConflictError in its chain.

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError returns true if err has NotFoundError in its chain.

func IsValidationError

func IsValidationError(err error) bool

IsValidationError returns true if err has ValidationError in its chain.

func NewConflictError

func NewConflictError(message string) error

NewConflictError creates new ConflictError instance.

func NewValidationError

func NewValidationError(message string) error

NewValidationError creates new ValidationError instance.

func TraceIDFromCtx

func TraceIDFromCtx(ctx context.Context) string

TraceIDFromCtx returns trace id from context. If id is not present in context, returns emoty string.

Types

type ConflictError

type ConflictError struct {
	Err error
}

ConflictError represents all kind of problems resulting from conflicting state. For example - something was supposed to be created but it already exists.

func (ConflictError) Error

func (e ConflictError) Error() string

Error fullfills error interface.

type ValidationError

type ValidationError struct {
	Err error
}

ValidationError represents all kind of invalid data errors.

func (ValidationError) Error

func (e ValidationError) Error() string

Error fullfills error interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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