sqlite

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Transaction

func Transaction(ctx context.Context) *sql.Tx

Retrieve the transaction in the given context if any, or nil if it doesn't have one.

func WriteAndDispatch

func WriteAndDispatch[T event.Source](
	db Database,
	ctx context.Context,
	entities []T,
	switcher func(context.Context, event.Event) error,
) (finalErr error)

Helpers to handle database writes from an array of event sources and handle events dispatching. It will open and manage a transaction if none exist in the given context. This way, we make sure event handlers participates in the same transaction so they are resolved as a whole.

There's no way to add this method to the DB without type conversion so this is the easiest way for now.

Types

type Database

type Database interface {
	builder.Executor
	Dispatcher() event.Dispatcher
	WithTransaction(ctx context.Context) (context.Context, *sql.Tx)
	Migrate(MigrationsDir) error
	Close() error
}

func Open

func Open(dsn string, logger log.Logger, dispatcher event.Dispatcher) (Database, error)

Opens a connection to a sqlite database file.

type MigrationsDir

type MigrationsDir map[string]fs.FS

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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