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 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()
Click to show internal directories.
Click to hide internal directories.