txs

package
v0.123.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Example (PkgLevelTxFunctions)
package main

import (
	"context"

	"github.com/adamluzsi/frameless/pkg/txs"
)

func main() {
	ctx := context.Background()

	_ = func(ctx context.Context) (rerr error) {
		tx, _ := txs.Begin(ctx)
		defer txs.Finish(&rerr, tx)

		txs.OnRollback(tx, func() {
			// something to do
		})
		return nil
	}(ctx)
}
Output:

Index

Examples

Constants

View Source
const (
	ErrTxDone errorutil.Error = "transaction is already finished"
	ErrNoCtx  errorutil.Error = "context.Context not given"
	ErrNoTx   errorutil.Error = "no transaction present in the current context"
)

Variables

This section is empty.

Functions

func Begin

func Begin(ctx context.Context) (context.Context, error)

func Commit added in v0.74.0

func Commit(ctx context.Context) error

func Finish

func Finish(returnError *error, tx context.Context)

func OnRollback

func OnRollback[StepFn onRollbackStepFn](ctx context.Context, step StepFn) error

func Rollback added in v0.74.0

func Rollback(ctx context.Context) error

Types

type TxRollbackError added in v0.90.1

type TxRollbackError struct {
	Err   error
	Cause error
}

func (*TxRollbackError) Error added in v0.90.1

func (err *TxRollbackError) Error() string

func (*TxRollbackError) Unwrap added in v0.90.1

func (err *TxRollbackError) Unwrap() error

Jump to

Keyboard shortcuts

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