ofx

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: MIT Imports: 13 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
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

View Source
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

View Source
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.

View Source
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

View Source
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"`
}

func CreateDocumentStore added in v1.0.3

func CreateDocumentStore(
	lc fx.Lifecycle,
	l *zap.Logger,
	mClient *mongo2.Client,
	connect string,
) (DocumentStoreResult, error)

CreateDocumentStore creates a new DocumentStoreResult.

type GormDriverParams

type GormDriverParams struct {
	fx.In

	Dialector gorm.Dialector `name:"Dialector"`
}

type GormDriverResult

type GormDriverResult struct {
	fx.Out

	Dialector gorm.Dialector `name:"Dialector"`
}

type GormParams

type GormParams struct {
	fx.In

	GormDB *gorm.DB `name:"GormDB"`
}

type GormResult

type GormResult struct {
	fx.Out

	GormDB *gorm.DB `name:"GormDB"`
}

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 MongoParams struct {
	fx.In

	MongoClient *mongo2.Client `name:"MongoClient"`
}

type MongoResult

type MongoResult struct {
	fx.Out

	MongoClient *mongo2.Client `name:"MongoClient"`
}

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

type RedisCacheParams struct {
	fx.In
	RedisCache diface.ICache `name:"RedisCache"`
}

RedisCacheParams provides the RedisCacheParams to the mfx dependency graph.

type RedisCacheResult

type RedisCacheResult struct {
	fx.Out
	RedisCache diface.ICache `name:"RedisCache"`
}

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

Jump to

Keyboard shortcuts

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