infrastructure

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultGormConfig

func GetDefaultGormConfig() *gorm.Config

GetDefaultGormConfig get default config.

func GetDefaultOptions

func GetDefaultOptions() *session.Options

GetDefaultOptions retrieves the options that enable SharedConfigState. Basically, Options assumes that an IAM role has been assigned in the execution environment.

func GetS3Config

func GetS3Config(e *logrus.Entry, id, secret, token, region, endpoint string, isMinio bool) *aws.Config

GetS3Config get config.

func GetS3ConfigNoCredentials

func GetS3ConfigNoCredentials(e *logrus.Entry, region, endpoint string, isMinio bool) *aws.Config

GetS3ConfigNoCredentials get no credentials config. If AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are environment variables and are in the execution environment, Credentials is not required.

func GetSESConfig

func GetSESConfig(e *logrus.Entry, id, secret, token, region, endpoint string) *aws.Config

GetSESConfig get config.

func GetSESConfigNoCredentials

func GetSESConfigNoCredentials(e *logrus.Entry, region, endpoint string) *aws.Config

GetSESConfigNoCredentials get no credentials config. If AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are environment variables and are in the execution environment, Credentials is not required.

func NewMySQL

func NewMySQL(c *MySQLConfig, gc *gorm.Config) *gorm.DB

NewMySQL returns an gorm db instance.

func NewPostgres

func NewPostgres(c *PostgresConfig, gc *gorm.Config) *gorm.DB

NewPostgres returns an gorm db instance.

func NewS3

func NewS3(o *session.Options, c *aws.Config) *s3.S3

NewS3 returns s3 instance.

func NewSES

func NewSES(
	o *session.Options,
	c *aws.Config,
) *ses.SES

NewSES returns ses instance.

func NewSQLServer

func NewSQLServer(c *SQLServerConfig, gc *gorm.Config) *gorm.DB

NewSQLServer returns an gorm db instance.

func NewSlack

func NewSlack(c *SlackConfig) *slack.Client

NewSlack returns an SlackClient instance.

Types

type DBConfig

type DBConfig struct {
	// ConnMaxLifetime sets max life time(sec)
	ConnMaxLifetime time.Duration
	// ConnMaxIdletime sets max idle time(sec)
	ConnMaxIdletime time.Duration
	// MaxIdleConns sets idle connection
	MaxIdleConns int
	// MaxOpenConns sets max connection
	MaxOpenConns int
}

DBConfig set configurations.

type GormConfig

type GormConfig struct {
	// If the time specified by SlowThreshold is exceeded, it is displayed in the log as a SlowQuery.
	SlowThreshold time.Duration
	// If true is specified for IgnoreRecordNotFoundError, no log is output at the error level even if the record does not exist as a search result.
	// If false, logs are output at the error level when a record does not exist as a search result.
	IgnoreRecordNotFoundError bool
	// LogLevel outputs logs above the specified level.
	LogLevel LogLevel
}

GormConfig set configurations.

type Interface

type Interface interface {
	LogMode(logger.LogLevel) Interface
	Info(context.Context, string, ...interface{})
	Warn(context.Context, string, ...interface{})
	Error(context.Context, string, ...interface{})
	Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)
}

Interface Gorm Logger interface.

type LogLevel

type LogLevel int

LogLevel log level.

const (
	// Silent silent log level
	Silent LogLevel = iota + 1
	// Error error log level
	Error
	// Warn warn log level
	Warn
	// Info info log level
	Info
)

type Logger

type Logger struct {
	Entry *logrus.Entry
}

Logger struct.

func NewLogger

func NewLogger(logger *logrus.Logger) *Logger

NewLogger returns an instance of logger

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

Debug outputs debug level log.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

Debugf outputs debug level log.

func (*Logger) Debugln

func (l *Logger) Debugln(args ...interface{})

Debugln outputs debug level log.

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

Error outputs error level log.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

Errorf outputs error level log.

func (*Logger) Errorln

func (l *Logger) Errorln(args ...interface{})

Errorln outputs error level log.

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

Fatal outputs fatal level log.

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...interface{})

Fatalf outputs fatal level log.

func (*Logger) Fatalln

func (l *Logger) Fatalln(args ...interface{})

Fatalln outputs fatal level log.

func (*Logger) GetEntry

func (l *Logger) GetEntry() *logrus.Entry

GetEntry gets *logrus.Entry.

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

Info outputs info level log.

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

Infof outputs info level log.

func (*Logger) Infoln

func (l *Logger) Infoln(args ...interface{})

Infoln outputs info level log.

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

Panic outputs panic log.

func (*Logger) Panicf

func (l *Logger) Panicf(format string, args ...interface{})

Panicf outputs panic log.

func (*Logger) Panicln

func (l *Logger) Panicln(args ...interface{})

Panicln outputs panic log.

func (*Logger) Print

func (l *Logger) Print(args ...interface{})

Print outputs printf.

func (*Logger) Printf

func (l *Logger) Printf(format string, args ...interface{})

Printf outputs printf.

func (*Logger) Println

func (l *Logger) Println(args ...interface{})

Println outputs printf.

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

Warn outputs warn level log.

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

Warnf outputs warn level log.

func (*Logger) Warning

func (l *Logger) Warning(args ...interface{})

Warning outputs warn level log.

func (*Logger) Warningf

func (l *Logger) Warningf(format string, args ...interface{})

Warningf outputs warn level log.

func (*Logger) Warningln

func (l *Logger) Warningln(args ...interface{})

Warningln outputs warn level log.

func (*Logger) Warnln

func (l *Logger) Warnln(args ...interface{})

Warnln outputs warn level log.

func (*Logger) WithContext

func (l *Logger) WithContext(ctx context.Context) *Logger

WithContext calls WithContext function of logger entry.

func (*Logger) WithContextValue

func (l *Logger) WithContextValue(key string) *Logger

WithContextValue calls WithField function of logger entry.

func (*Logger) WithError

func (l *Logger) WithError(err error) *Logger

WithError calls WithError function of logger entry.

func (*Logger) WithField

func (l *Logger) WithField(key string, value interface{}) *Logger

WithField calls WithField function of logger entry.

func (*Logger) WithFields

func (l *Logger) WithFields(fields logrus.Fields) *Logger

WithFields calls WithField function of logger entry.

type LoggerGorm

type LoggerGorm struct {
	// contains filtered or unexported fields
}

LoggerGorm struct.

func NewLoggerGorm

func NewLoggerGorm(c *LoggerGormConfig) *LoggerGorm

NewLoggerGorm func

func (*LoggerGorm) Error

func (l *LoggerGorm) Error(ctx context.Context, msg string, data ...interface{})

Error print the error level log.

func (*LoggerGorm) Info

func (l *LoggerGorm) Info(ctx context.Context, msg string, data ...interface{})

Info print the info level log.

func (*LoggerGorm) LogMode

func (l *LoggerGorm) LogMode(level logger.LogLevel) logger.Interface

LogMode log mode(same logrus.level)

func (*LoggerGorm) Trace

func (l *LoggerGorm) Trace(
	ctx context.Context,
	begin time.Time,
	fc func() (sql string, rowsAffected int64),
	err error,
)

Trace print the SQL log.

func (*LoggerGorm) Warn

func (l *LoggerGorm) Warn(ctx context.Context, msg string, data ...interface{})

Warn print the warn level log.

type LoggerGormConfig

type LoggerGormConfig struct {
	Logger     *logrus.Logger
	GormConfig *GormConfig
}

LoggerGormConfig sets configurations.

type MySQLConfig

type MySQLConfig struct {
	Config *mysql.Config
	DBConfig
}

MySQLConfig sets configurations.

type PostgresConfig

type PostgresConfig struct {
	Config *postgres.Config
	DBConfig
}

PostgresConfig sets configurations.

type SQLServerConfig

type SQLServerConfig struct {
	Config *sqlserver.Config
	DBConfig
}

SQLServerConfig sets configurations.

type SlackConfig

type SlackConfig struct {
	OauthAccessToken string
}

SlackConfig sets configurations.

Jump to

Keyboard shortcuts

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