database

package module
v0.0.0-...-2be5f50 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Close() error
}

type DatabaseConfig

type DatabaseConfig[T Client] struct {
	sync.RWMutex

	Host     string `toml:"host"`
	Database string `toml:"database"`
	Port     string `toml:"port"`
	Username string `toml:"username"`
	Password string `toml:"password"`

	CreateEntClient func(dialect.Driver) T
	// contains filtered or unexported fields
}

TODO: we can probably put this in baseplate if we can figure out how to make ent.Client generic

func (*DatabaseConfig[T]) Cleanup

func (c *DatabaseConfig[T]) Cleanup() error

func (*DatabaseConfig[T]) CreateClient

func (c *DatabaseConfig[T]) CreateClient() (*T, error)

func (*DatabaseConfig[T]) GetClient

func (c *DatabaseConfig[T]) GetClient() (T, error)

func (*DatabaseConfig[T]) Merge

func (c *DatabaseConfig[T]) Merge(o *DatabaseConfig[T]) error

func (*DatabaseConfig[T]) RegisterFlags

func (c *DatabaseConfig[T]) RegisterFlags(f *flag.FlagSet)

func (*DatabaseConfig[T]) Validate

func (c *DatabaseConfig[T]) Validate() error

func (*DatabaseConfig[T]) WithClient

func (c *DatabaseConfig[T]) WithClient(client *T)

set the database client manually. useful when writing tests with an already initialized client.

WARNING: if you use this parameter, be careful to not use CreateClient() as it will overwrite the manually set client. I don't currently have a good solution to get around this.

Jump to

Keyboard shortcuts

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