Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Transaction ¶
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 MigrationsModule ¶ added in v1.1.0
type MigrationsModule struct {
// contains filtered or unexported fields
}
Represents a single module for database migrations.
func NewMigrationsModule ¶ added in v1.1.0
func NewMigrationsModule(name string, dir string, fs fs.FS) MigrationsModule
Builds a new migrations module with the given module name (used as a migrations history table name prefix) and the directory where migrations are stored in the given filesystem.