Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DocumentStoreModule = fx.Provide( func( lc fx.Lifecycle, l *zap.Logger, mp MongoParams, sp SettingsParams, ) (dOut DocumentStoreResult, err error) { return CreateDocumentStore(lc, l, mp.MongoClient, sp.DatabaseURL) }, )
DocumentStoreModule provides to the mfx dependency graph.
var GormModule = fx.Provide( func( lc fx.Lifecycle, l *zap.Logger, dParams GormDriverParams, ) (GormResult, error) { return CreateGormDriver(lc, l, dParams.Dialector) }, )
GormModule is the module for gorm driver https://github.com/go-gorm/gorm
var MongoPureModule = fx.Provide( func( lc fx.Lifecycle, l *zap.Logger, n SettingsParams, ) (MongoResult, error) { return CreateMongoDriver(lc, l, n) }, )
MongoPureModule is the module for mongo driver https://github.com/mongodb/mongo-go-driver
var RedisCacheModule = fx.Provide( func( l *zap.Logger, rParams RedisParams, ) (RedisCacheResult, error) { return CreateRedisCache(l, rParams) }, )
RedisCacheModule provides the RedisCacheModule to the mfx dependency graph.
var RedisModule = fx.Provide( func( lc fx.Lifecycle, l *zap.Logger, n SettingsParams, ) (RedisResult, error) { return CreateRedis(lc, l, n) }, )
RedisModule is the module for redis driver github.com/redis/go-redis/v9
var SettingsModule = fx.Provide( func() (SettingsResult, error) { return CreateSettings() }, )
SettingsModule is a module that provides the settings.
Functions ¶
This section is empty.
Types ¶
type DocumentStoreParams ¶
type DocumentStoreParams struct { fx.In DriverProvider diface.IDocumentProvider `name:"DriverProvider"` }
type DocumentStoreResult ¶
type DocumentStoreResult struct { fx.Out DriverProvider diface.IDocumentProvider `name:"DriverProvider"` }
type GormDriverParams ¶
type GormDriverResult ¶
type GormResult ¶
func CreateGormDriver ¶ added in v1.0.3
func CreateGormDriver( lc fx.Lifecycle, logger *zap.Logger, dialector gorm.Dialector, ) (GormResult, error)
CreateGormDriver creates a new gorm driver
type MongoParams ¶
type MongoResult ¶
func CreateMongoDriver ¶ added in v1.0.3
func CreateMongoDriver( lc fx.Lifecycle, l *zap.Logger, n SettingsParams, ) (MongoResult, error)
CreateMongoDriver creates a new Mongo driver client.
type RedisCacheParams ¶
RedisCacheParams provides the RedisCacheParams to the mfx dependency graph.
type RedisCacheResult ¶
RedisCacheResult provides the RedisCacheResult to the mfx dependency graph.
func CreateRedisCache ¶ added in v1.0.3
func CreateRedisCache( l *zap.Logger, rParams RedisParams, ) (RedisCacheResult, error)
CreateRedisCache creates a redis cathe .
type RedisParams ¶
type RedisParams struct { fx.In //use redis db 0 Redis *goredis.Client `name:"Redis"` //use redis db 1 Cache *goredis.Client `name:"Cache"` }
RedisParams provides the RedisParams to the mfx dependency graph.
type RedisResult ¶
type RedisResult struct { fx.Out //use redis db 0 Redis *goredis.Client `name:"Redis"` //use redis db 1 Cache *goredis.Client `name:"Cache"` }
RedisResult provides the RedisResult to the mfx dependency graph.
func CreateRedis ¶ added in v1.0.3
func CreateRedis( lc fx.Lifecycle, l *zap.Logger, n SettingsParams, ) (RedisResult, error)
CreateRedis creates a new Redis driver
type SettingsParams ¶
type SettingsParams struct { fx.In // DatabaseURL is the url of the database(mongodb). DatabaseURL string `name:"DatabaseURL"` // will replace database url username DatabaseUser string `name:"DatabaseUser"` // will replace database url password DatabasePassword string `name:"DatabasePassword"` // CacheURL is the url of the cache(redis). CacheURL string `name:"CacheURL"` // will replace cache url username CacheUser string `name:"CacheUser"` // will replace cache url password CachePassword string `name:"CachePassword"` }
type SettingsResult ¶
type SettingsResult struct { fx.Out DocumentURL string `name:"DatabaseURL" envconfig:"DATABASE_URL" default:"mongodb://localhost:27017"` DatabaseUser string `name:"DatabaseUser" envconfig:"DATABASE_USER" default:""` DatabasePassword string `name:"DatabasePassword" envconfig:"DATABASE_PASSWORD" default:""` CacheURL string `name:"CacheURL" envconfig:"CACHE_URL" default:"redis://localhost:6379"` CacheUser string `name:"CacheUser" envconfig:"CACHE_USER" default:""` CachePassword string `name:"CachePassword" envconfig:"CACHE_PASSWORD" default:""` }
func CreateSettings ¶ added in v1.0.3
func CreateSettings() (SettingsResult, error)
CreateSettings load orm settings from environment