feat(core): add branch service (#18379)
Co-authored-by: unknown unknown <unknown@unknown>
This commit is contained in:
parent
05261cc46e
commit
d52a7c432a
@ -36,6 +36,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
* [#18379](https://github.com/cosmos/cosmos-sdk/pull/18379) Add branch service.
|
||||
|
||||
## [v0.12.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.0)
|
||||
|
||||
:::note
|
||||
|
||||
19
core/branch/branch.go
Normal file
19
core/branch/branch.go
Normal file
@ -0,0 +1,19 @@
|
||||
// Package branch contains the core branch service interface.
|
||||
package branch
|
||||
|
||||
import "context"
|
||||
|
||||
// Service is the branch service interface. It can be used to execute
|
||||
// code paths in an isolated execution context that can be reverted.
|
||||
// A revert typically means a rollback on events and state changes.
|
||||
type Service interface {
|
||||
// Execute executes the given function in an isolated context. If the
|
||||
// `f` function returns an error, the execution is considered failed,
|
||||
// and every change made affecting the execution context is rolled back.
|
||||
// If the function returns nil, the execution is considered successful, and
|
||||
// committed.
|
||||
// The context.Context passed to the `f` function is a child of the context
|
||||
// passed to the Execute function, and is what should be used with other
|
||||
// core services in order to ensure the execution remains isolated.
|
||||
Execute(ctx context.Context, f func(ctx context.Context) error) error
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user