uow

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package uow provides an interface in which the "repositories" that participate on it are asure that the functions/actions that are called will be rollback if the Unit of Work fails at some point. So it's not necessary to care about removing the already created data if an error raises on the middle of the Unit of Work. It's basically an interface to emulate a Transaction which is a more common word for it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StartUnitOfWork

type StartUnitOfWork func(ctx context.Context, t Type, uowFn UnitOfWorkFn, repositories ...interface{}) error

StartUnitOfWork it's the way to initialize a typed UoW, it has a uowFn which is the callback where all the work should be done, it also has the repositories, which are all the Repositories that belong to this UoW

type Type

type Type int

Type is the type of the UniteOfWork

const (
	// Read is the type of UoW that only reads data
	Read Type = iota

	// Write is the type of UoW that Reads and Writes data
	Write
)

type UnitOfWork

type UnitOfWork interface {
	Files() file.Repository
	IDXKeys() idxkey.Repository
	IDXVolumes() idxvolume.Repository
	Fs() afero.Fs
	Replicas() replica.Repository
	State() state.Repository
}

UnitOfWork is the interface that any UnitOfWork has to follow the only methods it as are to return Repositories that work together to achive a common purpose/work.

type UnitOfWorkFn

type UnitOfWorkFn func(ctx context.Context, uw UnitOfWork) error

UnitOfWorkFn is the signature of the function that is the callback of the StartUnitOfWork

Jump to

Keyboard shortcuts

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