-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add branch service (#18379)
Co-authored-by: unknown unknown <unknown@unknown>
- Loading branch information
1 parent
05261cc
commit d52a7c4
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |