lib

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

exports libraries 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 {
	Postgres *gorm.DB
	Redis    *redis.Client
}

func NewDatabase

func NewDatabase(env Env, logger Logger) Database

type Env

type Env struct {
	ServerPort  string `mapstructure:"SERVER_PORT"`
	Environment string `mapstructure:"ENV"`

	LogOutput string `mapstructure:"LOG_OUTPUT"`
	LogLevel  string `mapstructure:"LOG_LEVEL"`

	JWTSecret string `mapstructure:"JWT_SECRET"`

	PostgresUserName string `mapstructure:"POSTGRES_USER"`
	PostgresPassword string `mapstructure:"POSTGRES_PASS"`
	PostgresHost     string `mapstructure:"POSTGRES_HOST"`
	PostgresPort     string `mapstructure:"POSTGRES_PORT"`
	PostgresDB       string `mapstructure:"POSTGRES_DATABASE"`

	RedisPassword string `mapstructure:"REDIS_PASS"`
	RedisHost     string `mapstructure:"REDIS_HOST"`
	RedisPort     string `mapstructure:"REDIS_PORT"`
	RedisName     string `mapstructure:"REDIS_NAME"`
}

func NewEnv

func NewEnv() Env

create 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 (gl GinLogger) Write(p []byte) (n int, err error)

Write interface implementation for gin-framework

type GormLogger

type GormLogger struct {
	*Logger
	gorm_logger.Config
}

func (GormLogger) Error

func (gl GormLogger) Error(ctx context.Context, msg string, data ...interface{})

Error print error messages

func (GormLogger) Info

func (gl GormLogger) Info(ctx context.Context, msg string, data ...interface{})

Info print info messages

func (*GormLogger) LogMode

LogMode log mode

func (GormLogger) Trace

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

Trace print sql message

func (GormLogger) Warn

func (gl GormLogger) Warn(ctx context.Context, msg string, data ...interface{})

Warn print warn messages

type Logger

type Logger struct {
	*zap.SugaredLogger
}

func GetLogger

func GetLogger() Logger

GetLogger get the logger

func (*Logger) GetFxLogger

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

GetFxLogger get the fx logger

func (Logger) GetGinLogger

func (l Logger) GetGinLogger() GinLogger

GetGinLogger get the gin logger

func (Logger) GetGormLogger

func (l Logger) GetGormLogger() *GormLogger

GetGormLogger get the gorm logger

type Router

type Router struct {
	Gin *gin.Engine
}

func NewRouter

func NewRouter() Router

create a new router

Jump to

Keyboard shortcuts

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