data

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextFactory added in v1.1.0

type ContextFactory struct {
	Context context.Context
	Timeout int
}

func (ContextFactory) CreateStandardTimeoutContext added in v1.1.0

func (cf ContextFactory) CreateStandardTimeoutContext() (context.Context, context.CancelFunc)

CreateStandardTimeoutContext creates a context with the configured timeout. It is a child of the configured context and can be canceled by that context's cancel function. Returns the created context and its cancel function.

type CoreScopeFactory

type CoreScopeFactory struct {
	DataAdapter DataAdapter
}

func (CoreScopeFactory) CreateDataExecutorScope

func (sf CoreScopeFactory) CreateDataExecutorScope(body func(DataExecutor) error) error

func (CoreScopeFactory) CreateTransactionScope

func (sf CoreScopeFactory) CreateTransactionScope(exec DataExecutor, body func(Transaction) (bool, error)) error

type DataAdapter

type DataAdapter interface {
	// Setup sets up the adapter and returns any errors.
	Setup() error

	// CleanUp cleans up the adapter and returns any errors.
	CleanUp() error

	// GetExecutor gets the DataExecutor for the adapter.
	GetExecutor() DataExecutor
}

type DataCRUD

DataCRUD encapsulates the other CRUD interfaces.

type DataExecutor

type DataExecutor interface {
	DataCRUD

	// CreateTransaction creates a new transaction and returns any errors.
	CreateTransaction() (Transaction, error)
}

type MigrationRepositoryFactory

type MigrationRepositoryFactory interface {
	// CreateMigrationRepository creates a MigrationRepository using the provided data executor.
	CreateMigrationRepository(DataExecutor) migrationrunner.MigrationRepository
}

type ScopeFactory

type ScopeFactory interface {
	// CreateDataExecutorScope handles setup and clean up of the data executor, and passes it to the provided body function.
	// Returns any errors from the executor or body.
	CreateDataExecutorScope(func(DataExecutor) error) error

	// CreateTransactionScope handles transaction creation and commiting, and passes it to the provided body function.
	// Rollbacks on failure or error from body, and returns any errors from the transaction or body.
	CreateTransactionScope(DataExecutor, func(Transaction) (bool, error)) error
}

type Transaction

type Transaction interface {
	DataCRUD

	// Commit saves the transaction changes and returns any errors.
	Commit() error

	// Rollback aborts the transaction changes and returns any errors.
	Rollback() error
}

Jump to

Keyboard shortcuts

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