transaction

package
v0.2.134 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2019 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Example

func SomeEndpoint(ctx context.COntext, req SomeRequest) error {
	// validation

	tx := transaction.Begin()
	defer tx.Rollback()

	// API Process
	if err := Process(); err != nil {
		return err
	}
	tx.PushRollback("Process", func() error {
		return InverseProcess()
	})

	tx.Done()

	return nil
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RollbackTask

type RollbackTask struct {
	Name string
	Func func() error
}

type Transaction

type Transaction struct {
	// contains filtered or unexported fields
}

func Begin

func Begin() *Transaction

func (*Transaction) Commit

func (tx *Transaction) Commit()

func (*Transaction) PopRollback

func (tx *Transaction) PopRollback() *RollbackTask

func (*Transaction) PushRollback

func (tx *Transaction) PushRollback(name string, f func() error)

func (*Transaction) Rollback

func (tx *Transaction) Rollback() error

func (*Transaction) RollbackWithLog

func (tx *Transaction) RollbackWithLog()

Jump to

Keyboard shortcuts

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