database

package
v0.0.0-...-09aa624 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB
View Source
var Redis *redis.Client

Functions

func AddDelayedJob

func AddDelayedJob(queue, body string, duration time.Duration) error

func AddRoleToUser

func AddRoleToUser(user *dbTypes.User, role *dbTypes.Role) error

func Connect

func Connect(options DBOptions) error

func ConnectRedis

func ConnectRedis(options RedisOptions)

func FindEmailTemplate

func FindEmailTemplate(name string) (*dbTypes.EmailTemplate, error)

func FindOI

func FindOI(user *dbTypes.User) (string, error)

func FindRatingByShort

func FindRatingByShort(short string) (*dbTypes.Rating, error)

func FindRole

func FindRole(name string) (*dbTypes.Role, error)

func FindUserByCID

func FindUserByCID(cid string) (*dbTypes.User, error)

func FindUsersWithRole

func FindUsersWithRole(role string) ([]dbTypes.User, error)

func GenerateDSN

func GenerateDSN(options DBOptions) (string, error)

func HandleCACert

func HandleCACert(driver string, cacert string) error

func RemoveRoleFromUser

func RemoveRoleFromUser(user *dbTypes.User, role *dbTypes.Role) error

Types

type DBOptions

type DBOptions struct {
	Driver   string
	Host     string
	Port     string
	User     string
	Password string
	Database string
	Options  string

	MaxOpenConns int
	MaxIdleConns int

	CACert string
	Logger *logrus.Logger
}

type Logger

type Logger struct {
	SlowThreshold         time.Duration
	SourceField           string
	SkipErrRecordNotFound bool
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(l *logrus.Logger) *Logger

func (*Logger) Debug

func (l *Logger) Debug(ctx context.Context, s string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, s string, args ...interface{})

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, s string, args ...interface{})

func (*Logger) LogMode

func (l *Logger) LogMode(gormlog.LogLevel) gormlog.Interface

func (*Logger) Trace

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

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, s string, args ...interface{})

type RedisOptions

type RedisOptions struct {
	// Sentinel config
	Sentinel      bool
	MasterName    string
	SentinelAddrs []string

	// Single Redis config
	Addr string

	// Common
	Password string
	DB       int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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