txs

package
v0.77.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: Apache-2.0 Imports: 4 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 errutils.Error = "transaction is already finished"
	ErrNoCtx  errutils.Error = "context.Context not given"
	ErrNoTx   errutils.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

This section is empty.

Jump to

Keyboard shortcuts

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