types

package
v0.0.0-...-988e9ee Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const LogAllowedTimeDrift = 5 * time.Minute

LogAllowedTimeDrift is the maximum amount of time that the Log.CreatedAt value can be in the future relative to the current system clock. A low value is recommended to prevent future dates from being accepted for insertion into the db

View Source
const LogIDChars = "0123456789abcdef"

LogIDChars calculation: https://zelark.github.io/nano-id-cc/

View Source
const LogIDLength = 24

LogIDLength calculation: https://zelark.github.io/nano-id-cc/

View Source
const LogMaxMessageLength = 4 * 1024
View Source
const LogMaxModuleLength = 64
View Source
const LogMaxServiceLength = 64

Variables

View Source
var LogLevels = map[Level]int{
	LevelFatal: 6,
	LevelError: 5,
	LevelWarn:  4,
	LevelInfo:  3,
	LevelDebug: 2,
	LevelTrace: 1,
}

Functions

This section is empty.

Types

type Duration

type Duration time.Duration

func (Duration) MarshalBSONValue

func (j Duration) MarshalBSONValue() (bsontype.Type, []byte, error)

func (Duration) MarshalJSON

func (j Duration) MarshalJSON() ([]byte, error)

func (*Duration) UnmarshalBSONValue

func (j *Duration) UnmarshalBSONValue(t bsontype.Type, data []byte) error

func (*Duration) UnmarshalJSON

func (j *Duration) UnmarshalJSON(data []byte) error

type Level

type Level string
const (
	LevelFatal Level = "FATAL"
	LevelError Level = "ERROR"
	LevelWarn  Level = "WARN"
	LevelInfo  Level = "INFO"
	LevelDebug Level = "DEBUG"
	LevelTrace Level = "TRACE"
)

type Log

type Log struct {
	ID        string `json:"id,omitempty" bson:"_id"`
	Level     Level  `json:"level,omitempty" bson:"level"`
	Service   string `json:"service,omitempty" bson:"service"`
	Module    string `json:"module,omitempty" bson:"module"`
	Message   string `json:"message,omitempty" bson:"message"`
	CreatedAt Time   `json:"created_at,omitempty" bson:"created_at"`
}

func (*Log) Errors

func (l *Log) Errors() []string

type Response

type Response[T any] struct {
	Success bool   `json:"success"`
	Message string `json:"message,omitempty"`
	Data    *T     `json:"data,omitempty"`
}

func NewError

func NewError[T any](message string, data T) *Response[T]

func NewErrorNil

func NewErrorNil(message string) *Response[any]

func NewResponse

func NewResponse[T any](success bool, message string, data *T) *Response[T]

func NewSuccess

func NewSuccess[T any](data T) *Response[T]

func NewSuccessNil

func NewSuccessNil() *Response[any]

type Time

type Time time.Time

func (Time) MarshalBSONValue

func (j Time) MarshalBSONValue() (bsontype.Type, []byte, error)

func (Time) MarshalJSON

func (j Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalBSONValue

func (j *Time) UnmarshalBSONValue(t bsontype.Type, data []byte) error

func (*Time) UnmarshalJSON

func (j *Time) UnmarshalJSON(data []byte) error

type Token

type Token struct {
	ID        string `json:"id" bson:"_id"`
	OwnerID   string `json:"owner_id" bson:"owner_id"`
	CreatedAt Time   `json:"created_at" bson:"created_at"`
	ExpiresAt Time   `json:"expires_at" bson:"expires_at"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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