Skip to content

Commit

Permalink
feat(core): add branch service (#18379)
Browse files Browse the repository at this point in the history
Co-authored-by: unknown unknown <unknown@unknown>
  • Loading branch information
testinginprod and unknown unknown authored Nov 7, 2023
1 parent 05261cc commit d52a7c4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions core/branch/branch.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit d52a7c4

Please sign in to comment.