fxpostgres

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(
	fx.Provide(func(lc fx.Lifecycle, cfg *Config) (Driver, error) {
		driver, err := postgres.New(context.Background(), cfg.URL)
		if err != nil {
			return nil, err
		}
		lc.Append(fx.Hook{
			OnStart: func(ctx context.Context) error {
				return driver.Ping(ctx)
			},
			OnStop: func(context.Context) error {
				driver.Close()
				return nil
			},
		})

		return driver, nil
	}),
)

Functions

This section is empty.

Types

type Config

type Config struct {
	URL            string `json:"url"`
	MigrationsPath string `json:"migrationsPath"`
}

type Driver

type Driver interface {
	Ping(ctx context.Context) error
	Close()
	CountRows(ctx context.Context, query string, args ...interface{}) (int, error)
	ExecuteQuery(ctx context.Context, query string, args ...interface{}) error
	QueryRow(ctx context.Context, query string, args ...interface{}) (pgx.Row, error)
	QueryRows(ctx context.Context, query string, args ...interface{}) (pgx.Rows, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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