lib

package
v0.0.0-...-65f96c2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Module exports dependency

Functions

This section is empty.

Types

type Command

type Command interface {
	// Short returns string about short description of the command
	// the string is shown in help screen of cobra command
	Short() string

	// Setup is used to setup flags or pre-run steps for the command.
	//
	// For example,
	//  cmd.Flags().IntVarP(&r.num, "num", "n", 5, "description")
	//
	Setup(cmd *cobra.Command)

	// Run runs the command runner
	// run returns command runner which is a function with dependency
	// injected arguments.
	//
	// For example,
	//  Command{
	//   Run: func(l lib.Logger) {
	// 	   l.Info("i am working")
	// 	 },
	//  }
	//
	Run() CommandRunner
}

Command interface is used to implement sub-commands in the system.

type CommandRunner

type CommandRunner interface{}

type Database

type Database struct {
	*gorm.DB
}

Database modal

func NewDatabase

func NewDatabase(env Env, logger Logger) Database

NewDatabase creates a new database instance

type Env

type Env struct {
	ServerPort  string `mapstructure:"SERVER_PORT"`
	Environment string `mapstructure:"ENV"`
	LogOutput   string `mapstructure:"LOG_OUTPUT"`
	DBUsername  string `mapstructure:"DB_USER"`
	DBPassword  string `mapstructure:"DB_PASS"`
	DBHost      string `mapstructure:"DB_HOST"`
	DBPort      string `mapstructure:"DB_PORT"`
	DBName      string `mapstructure:"DB_NAME"`
	JWTSecret   string `mapstructure:"JWT_SECRET"`
}

Env has environment stored

func NewEnv

func NewEnv() Env

NewEnv creates a new environment

type FxLogger

type FxLogger struct {
	*Logger
}

func (*FxLogger) LogEvent

func (l *FxLogger) LogEvent(event fxevent.Event)

LogEvent log event for fx logger

func (FxLogger) Printf

func (l FxLogger) Printf(str string, args ...interface{})

Printf prits go-fx logs

type GinLogger

type GinLogger struct {
	*Logger
}

func (GinLogger) Write

func (l GinLogger) Write(p []byte) (n int, err error)

Write interface implementation for gin-framework

type GormLogger

type GormLogger struct {
	*Logger
	gormlogger.Config
}

func (GormLogger) Error

func (l GormLogger) Error(ctx context.Context, str string, args ...interface{})

Error prints error messages

func (GormLogger) Info

func (l GormLogger) Info(ctx context.Context, str string, args ...interface{})

Info prints info

func (*GormLogger) LogMode

LogMode set log mode

func (GormLogger) Trace

func (l GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

Trace prints trace messages

func (GormLogger) Warn

func (l GormLogger) Warn(ctx context.Context, str string, args ...interface{})

Warn prints warn messages

type Logger

type Logger struct {
	*zap.SugaredLogger
}

Logger structure

func GetLogger

func GetLogger() Logger

GetLogger get the logger

func (*Logger) GetFxLogger

func (l *Logger) GetFxLogger() fxevent.Logger

GetFxLogger gets logger for go-fx

func (Logger) GetGinLogger

func (l Logger) GetGinLogger() GinLogger

GetGinLogger get the gin logger

func (Logger) GetGormLogger

func (l Logger) GetGormLogger() *GormLogger

GetGormLogger gets the gorm framework logger

type RequestHandler

type RequestHandler struct {
	Gin *gin.Engine
}

RequestHandler function

func NewRequestHandler

func NewRequestHandler(logger Logger) RequestHandler

NewRequestHandler creates a new request handler

Jump to

Keyboard shortcuts

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