Documentation
¶
Index ¶
Constants ¶
View Source
const ( MongoDB = iota + 1 Postgres )
Variables ¶
This section is empty.
Functions ¶
func PostgresInit ¶
func PostgresInit(ctx context.Context, config *PostgresConfig) (*gorm.DB, context.CancelFunc)
PostgresInit initializes the Postgres connection
Types ¶
type DefaultConfig ¶
type DefaultConfig struct {
Host string `env:"HOST,notEmpty"`
Port int `env:"PORT,notEmpty"`
Database string `env:"DATABASE,notEmpty"`
Username string `env:"USERNAME,unset"`
Password string `env:"PASSWORD,unset"`
Timeout time.Duration `env:"TIMEOUT" envDefault:"10s"`
ConnMaxLifeTime time.Duration `env:"CONN_MAX_LIFETIME" envDefault:"1h"`
MaxIdleConnections int `env:"MAX_IDLE_CONNECTIONS" envDefault:"10"`
MaxOpenConnections int `env:"MAX_OPEN_CONNECTIONS" envDefault:"100"`
}
type Migration ¶
type Migration struct {
DBType int
Postgres MigrationConfig
// contains filtered or unexported fields
}
func NewPostgresMigration ¶
func NewPostgresMigration(client *gorm.DB, config *PostgresConfig) *Migration
type MigrationConfig ¶
type MongoDBConfig ¶
type MongoDBConfig struct {
DefaultConfig
AppName string `env:"APP_NAME"`
ReplicaSet string `env:"REPLICA_SET"`
TLSMode bool `env:"TLS_MODE"`
TLSInsecure bool `env:"TLS_INSECURE"`
RetryWrites bool `env:"RETRY_WRITES"`
DirectConnection bool `env:"DIRECT_CONNECTION" envDefault:"true"`
Collections []string `env:"COLLECTIONS"`
}
type MongoDBData ¶
type MongoDBData struct {
Client *mongo.Client
Collections map[string]*mongo.Collection
}
func MongoDBInit ¶
func MongoDBInit(ctx context.Context, config *MongoDBConfig) (*MongoDBData, context.CancelFunc)
MongoDBInit initializes the MongoDB connection
type PostgresConfig ¶
type PostgresConfig struct {
DefaultConfig
SSLMode string `env:"SSL_MODE"`
SSLCert string `env:"SSL_CERT"`
MigrationConfig MigrationConfig
}
type SlogAdapter ¶
type SlogAdapter struct {
io.Writer
Ctx context.Context
Logger *slog.Logger
// contains filtered or unexported fields
}
func (*SlogAdapter) Error ¶
func (s *SlogAdapter) Error(err error, message string, v ...interface{})
func (*SlogAdapter) Info ¶
func (s *SlogAdapter) Info(level int, message string, v ...interface{})
Click to show internal directories.
Click to hide internal directories.