pkg

package
v0.0.0-...-2ec8670 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeUndefined = -1
)

Variables

View Source
var (
	ErrUndefined = ErrorRegistry().
					AddErrorCode(ErrCodeUndefined).
					HttpStatus(http.StatusInternalServerError).
					NewError("undefined error")

	ErrInvalidParam = ErrorRegistry().
					AddErrorCode(4000).
					HttpStatus(http.StatusBadRequest).
					NewError("invalid parameter")
	ErrExists = ErrorRegistry().
				AddErrorCode(4001).
				HttpStatus(http.StatusConflict).
				NewError("resource already existed")
	ErrNotExists = ErrorRegistry().
					AddErrorCode(4002).
					HttpStatus(http.StatusNotFound).
					NewError("resource does not exist")

	ErrSystem = ErrorRegistry().
				AddErrorCode(5000).
				HttpStatus(http.StatusInternalServerError).
				NewError("system issue")
	ErrDatabase = ErrorRegistry().
				AddErrorCode(5001).
				HttpStatus(http.StatusInternalServerError).
				NewError("database issue")
)
View Source
var (
	ErrInvalidUsername = ErrorRegistry().
		AddErrorCode(6000).
		WrapError("username must be having a upper letter", ErrInvalidParam)
)

Functions

func ErrorRegistry

func ErrorRegistry() *utility.ErrorRegistry

func Init

func Init(conf *Config) io.Closer

Init initializes the necessary default global variables

func Logger

func Logger() *wlog.Logger

func Shutdown

func Shutdown() *utility.Shutdown

func UnwrapError

func UnwrapError(err error) *utility.CustomError

func Version

func Version() version

Types

type Config

type Config struct {
	AppId_      string       `yaml:"AppId"`
	Hack        utility.Hack `yaml:"Hack"`
	ShowErrCode bool         `yaml:"ShowErrCode"`

	Filename Filename `yaml:"Filename"`
	Http     Http     `yaml:"Http"`
	MySql    MySql    `yaml:"MySql"`
	Redis    Redis    `yaml:"Redis"`

	O11Y   utility.O11YConfig `yaml:"O11Y"`
	Logger wlog.Config        `yaml:"Logger"`
}

func MustLoadConfig

func MustLoadConfig() *Config

func (*Config) AppId

func (c *Config) AppId() string

type Filename

type Filename struct {
	Logger string `yaml:"Logger"` // output to stderr if empty
	Event  string `yaml:"Event"`  // output to stdout if empty
}

type Http

type Http struct {
	Port  string `yaml:"Port"`
	Debug bool   `yaml:"Debug"`
}

type MySql

type MySql struct {
	User     string `yaml:"User"`
	Password string `yaml:"Password"`
	Host     string `yaml:"Host"`
	Port     string `yaml:"Port"`
	Database string `yaml:"Database"`
	Debug    bool   `yaml:"Debug"`
}

func (*MySql) DSN

func (conf *MySql) DSN() string

type Redis

type Redis struct {
	User     string `yaml:"User"`
	Password string `yaml:"Password"`
	Host     string `yaml:"Host"`
	Port     string `yaml:"Port"`
}

func (Redis) Address

func (conf Redis) Address() string

Directories

Path Synopsis
api
Package app is a generated GoMock package.
Package app is a generated GoMock package.
dataflow
ref1: https://github.com/KScaesar/art?tab=readme-ov-file#example
ref1: https://github.com/KScaesar/art?tab=readme-ov-file#example
wfiber
wfiber is a wrapped fiber
wfiber is a wrapped fiber
wgin
wgin is a wrapped gin
wgin is a wrapped gin
wlog
wlog is a wrapped logger
wlog is a wrapped logger

Jump to

Keyboard shortcuts

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