MCPcopy Create free account
hub / github.com/cloudwan/gohan / tryWithinTx

Function tryWithinTx

db/db.go:83–108  ·  view source on GitHub ↗
(
	beginStrategy func() (ITransaction, error),
	fn func(ITransaction) error,
)

Source from the content-addressed store, hash-verified

81}
82
83func tryWithinTx(
84 beginStrategy func() (ITransaction, error),
85 fn func(ITransaction) error,
86) error {
87 tx, err := beginStrategy()
88 if err != nil {
89 log.Warning("failed to begin scoped transaction: %s", err)
90 return err
91 }
92
93 defer func() {
94 if tx != nil && !tx.Closed() {
95 if err := tx.Close(); err != nil {
96 log.Warning(
97 "close scoped database transaction failed with error: %s",
98 err,
99 )
100 }
101 }
102 }()
103
104 if err = tryToCommit(fn)(tx); err != nil {
105 log.Debug("scoped database transaction failed with error: %s", err)
106 }
107 return err
108}
109
110func WithinTemplate(
111 retries int,

Callers 1

WithinTemplateFunction · 0.85

Calls 5

tryToCommitFunction · 0.85
WarningMethod · 0.65
ClosedMethod · 0.65
CloseMethod · 0.65
DebugMethod · 0.65

Tested by

no test coverage detected