infrastructure

package
v0.0.0-...-da3856f Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDatabase

func NewDatabase(config *Config) (*gorm.DB, error)

func NewDatabaseMock

func NewDatabaseMock() (*gorm.DB, sqlmock.Sqlmock)

func NewFormatter

func NewFormatter(f string) glo.Formatter

NewFormatter creates a Formatter from a string

func NewFractalManager

func NewFractalManager() *fractal.Manager

func NewHashID

func NewHashID(salt string, len int) *hashids.HashID

func NewLoggerAdapterGlo

func NewLoggerAdapterGlo(cfg *LoggerConfig) glo.Facility

Types

type AppConfig

type AppConfig struct {
	Port  uint
	Debug bool
}

type AuthConfig

type AuthConfig struct {
	Header  string
	Token   string
	Enabled bool
}

type Config

type Config struct {
	App      AppConfig      `mapstructure:"app"`
	Auth     AuthConfig     `mapstructure:"auth"`
	Crypt    CryptoConfig   `mapstructure:"crypt"`
	HashIds  HashIdsConfig  `mapstructure:"hashids"`
	Database DatabaseConfig `mapstructure:"database"`
	Logger   LoggerConfig   `mapstructure:"logger"`
}

func NewConfig

func NewConfig(configPath string) (*Config, error)

func NewConfigMock

func NewConfigMock() (*Config, error)

func (*Config) GetAppPort

func (c *Config) GetAppPort() string

func (*Config) GetDatabaseDsn

func (c *Config) GetDatabaseDsn() string

type Container

type Container struct {
	Config  *Config
	Logger  Logger
	HashIds *HashIds
	Fractal *fractal.Manager
	DB      *gorm.DB
	PG      PasswordGenerator
}

type CryptoConfig

type CryptoConfig struct {
	Cost int
}

type DatabaseConfig

type DatabaseConfig struct {
	Host               string
	Port               uint16
	Name               string
	User               string
	Password           string
	MaxConnections     int    `mapstructure:"max_connections"`
	MaxIdleConnections int    `mapstructure:"max_idle_connections"`
	SslMode            string `mapstructure:"ssl_mode"`
}

type HashIds

type HashIds struct {
	*hashids.HashID
}

func NewHashIds

func NewHashIds(cfg *Config) *HashIds

func (HashIds) DecodeUint64

func (h HashIds) DecodeUint64(hash string) (uint64, error)

func (HashIds) EncodeUint64

func (h HashIds) EncodeUint64(num uint64) (string, error)

type HashIdsConfig

type HashIdsConfig struct {
	Length int
	Salt   string
}

type Logger

type Logger interface {
	// Logger logs an debug line
	Debug(string, ...interface{})
	// Logger logs an info line
	Info(string, ...interface{})
	// Logger logs an info line
	Notice(string, ...interface{})
	// Logger logs a warning line
	Warning(string, ...interface{})
	// Logger logs an error line
	Error(string, ...interface{})
	// Logger logs an critical line
	Critical(string, ...interface{})
	// Logger logs an alert line
	Alert(string, ...interface{})
	// Logger logs an emergency line
	Emergency(string, ...interface{})
}

func NewLogger

func NewLogger(cfg *Config) Logger

type LoggerAdapterGlo

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

func (*LoggerAdapterGlo) Alert

func (l *LoggerAdapterGlo) Alert(msg string, params ...interface{})

func (*LoggerAdapterGlo) Critical

func (l *LoggerAdapterGlo) Critical(msg string, params ...interface{})

func (*LoggerAdapterGlo) Debug

func (l *LoggerAdapterGlo) Debug(msg string, params ...interface{})

func (*LoggerAdapterGlo) Emergency

func (l *LoggerAdapterGlo) Emergency(msg string, params ...interface{})

func (*LoggerAdapterGlo) Error

func (l *LoggerAdapterGlo) Error(msg string, params ...interface{})

func (*LoggerAdapterGlo) Info

func (l *LoggerAdapterGlo) Info(msg string, params ...interface{})

func (*LoggerAdapterGlo) Notice

func (l *LoggerAdapterGlo) Notice(msg string, params ...interface{})

func (*LoggerAdapterGlo) Warning

func (l *LoggerAdapterGlo) Warning(msg string, params ...interface{})

type LoggerAdapterMattermostConfig

type LoggerAdapterMattermostConfig struct {
	WebhookUrl string `mapstructure:"webhook_url"`
	Username   string `mapstructure:"user_name"`
}

type LoggerConfig

type LoggerConfig struct {
	Mattermost LoggerAdapterMattermostConfig `mapstructure:"mattermost"`
}

type LoggerMock

type LoggerMock struct {
	Level  glo.Level
	Msg    string
	Params interface{}
}

func NewLoggerMock

func NewLoggerMock() *LoggerMock

func (*LoggerMock) Alert

func (l *LoggerMock) Alert(msg string, params ...interface{})

func (*LoggerMock) Critical

func (l *LoggerMock) Critical(msg string, params ...interface{})

func (*LoggerMock) Debug

func (l *LoggerMock) Debug(msg string, params ...interface{})

func (*LoggerMock) Emergency

func (l *LoggerMock) Emergency(msg string, params ...interface{})

func (*LoggerMock) Error

func (l *LoggerMock) Error(msg string, params ...interface{})

func (*LoggerMock) Info

func (l *LoggerMock) Info(msg string, params ...interface{})

func (*LoggerMock) Notice

func (l *LoggerMock) Notice(msg string, params ...interface{})

func (*LoggerMock) Warning

func (l *LoggerMock) Warning(msg string, params ...interface{})

type MattermostFormatter

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

func (*MattermostFormatter) Format

func (f *MattermostFormatter) Format(time time.Time, level glo.Level, line string, params ...interface{}) string

type MattermostHandler

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

func (*MattermostHandler) ClearFilters

func (h *MattermostHandler) ClearFilters() glo.Handler

func (*MattermostHandler) Log

func (h *MattermostHandler) Log(level glo.Level, line string, params ...interface{}) error

Log logs a line with a specific level

func (*MattermostHandler) PushFilter

func (h *MattermostHandler) PushFilter(filter glo.Filter) glo.Handler

func (*MattermostHandler) SetFormatter

func (h *MattermostHandler) SetFormatter(formatter glo.Formatter) glo.Handler

type MattermostHandlerConfig

type MattermostHandlerConfig struct {
	Username string
}

type PasswordGenerator

type PasswordGenerator interface {
	HashPassword(password string) (string, error)
	CheckPassword(password, hash string) bool
}

func NewPasswordGenerator

func NewPasswordGenerator(config *Config) PasswordGenerator

type PasswordGeneratorBCrypt

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

func (*PasswordGeneratorBCrypt) CheckPassword

func (pg *PasswordGeneratorBCrypt) CheckPassword(password, hash string) bool

func (*PasswordGeneratorBCrypt) HashPassword

func (pg *PasswordGeneratorBCrypt) HashPassword(password string) (string, error)

Jump to

Keyboard shortcuts

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