singleton

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCustomCallerEncoder added in v1.0.5

func GetCustomCallerEncoder(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder)

func GetCustomTimeEncoder added in v1.0.5

func GetCustomTimeEncoder(prefix string) zapcore.TimeEncoder

func GetEncodeLevel added in v1.0.5

func GetEncodeLevel(c *zapcore.EncoderConfig, level string)

Set logger encode level based on config

func GetEncoderConfig added in v1.0.5

func GetEncoderConfig(options ZapOptions) (config zapcore.EncoderConfig)

Types

type Option added in v1.0.1

type Option func(*Singleton) error

func WithPGSQL added in v1.0.4

func WithPGSQL(options PGSQLOptions) Option

func WithRedisClient added in v1.0.1

func WithRedisClient(options *redis.Options) Option

func WithViper added in v1.0.3

func WithViper(options ViperOptions) Option

func WithZapLogger added in v1.0.5

func WithZapLogger(options ZapOptions) Option

type PGSQLOptions added in v1.0.4

type PGSQLOptions struct {
	Source          string
	MaxConns        int32
	MaxConnIdleTime time.Duration
}

type Singleton added in v1.0.1

type Singleton struct {
	Redis  *redis.Client
	Viper  *viper.Viper
	PGPool *pgxpool.Pool
	Logger *zap.Logger
}

func (*Singleton) AddPlugin added in v1.0.2

func (s *Singleton) AddPlugin(opts ...Option) (err error)

type ViperOptions added in v1.0.3

type ViperOptions struct {
	Path     string // path to look for the config file in, absolute path start with / and relative path start with .
	FileName string // name of config file (without extension)
	FileType string // REQUIRED if the config file does not have the extension in the name
	EnvName  string // Env to read from the config file
	Target   any
}

type ZapOptions added in v1.0.5

type ZapOptions struct {
	LogLevel          int    // -1-debug, 0-info, 1-warn, 2-error, 3-DPanic, 4-Panic, 5-Fatal
	Development       bool   // development mode
	DisableStacktrace bool   `default:"true"`    // DisableStacktrace completely disables automatic stacktrace capturing. By default, stacktraces are captured for WarnLevel and above logs in development and ErrorLevel and above in production.
	EncodingFormat    string `default:"console"` // json or console
	Prefix            string
	EncodeLevel       string
	ServiceName       string
	OutputPath        []string
}

Jump to

Keyboard shortcuts

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