From db8b7bed21118e0cb4b5d0e5af36c09777c309b9 Mon Sep 17 00:00:00 2001 From: unknown unknown Date: Mon, 6 Nov 2023 18:42:02 +0100 Subject: [PATCH 1/6] add branch service in core --- core/branch/branch.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 core/branch/branch.go diff --git a/core/branch/branch.go b/core/branch/branch.go new file mode 100644 index 000000000000..5d28bad8882b --- /dev/null +++ b/core/branch/branch.go @@ -0,0 +1,17 @@ +// Package branch contains the core branch service interface and implementation. +package branch + +import "context" + +// Service is the branch service interface. +type Service interface { + // Execute executes the given function in an isolated context. + // If the function returns an error, the execution is considered failed, + // and every ste change made during the execution 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 +} From f950cc7a064bb9c6a84c5c5c35570ef9aaea9ab0 Mon Sep 17 00:00:00 2001 From: unknown unknown Date: Mon, 6 Nov 2023 18:45:53 +0100 Subject: [PATCH 2/6] better docs --- core/branch/branch.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/branch/branch.go b/core/branch/branch.go index 5d28bad8882b..7c08637aeab4 100644 --- a/core/branch/branch.go +++ b/core/branch/branch.go @@ -5,9 +5,9 @@ import "context" // Service is the branch service interface. type Service interface { - // Execute executes the given function in an isolated context. - // If the function returns an error, the execution is considered failed, - // and every ste change made during the execution is rolled back. + // 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 From 8bdd98eca04a47304352d0c0e5a5d5c44f084db9 Mon Sep 17 00:00:00 2001 From: unknown unknown Date: Mon, 6 Nov 2023 18:50:02 +0100 Subject: [PATCH 3/6] CHANGELOG.md --- core/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 4098e12dacf2..3b80170d78aa 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -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 From 32d8862bb5f42e188f2a8d724e48c0063c162ca6 Mon Sep 17 00:00:00 2001 From: testinginprod <98415576+testinginprod@users.noreply.github.com> Date: Mon, 6 Nov 2023 18:51:55 +0100 Subject: [PATCH 4/6] Update branch.go --- core/branch/branch.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/branch/branch.go b/core/branch/branch.go index 7c08637aeab4..ad46e52b6a29 100644 --- a/core/branch/branch.go +++ b/core/branch/branch.go @@ -1,9 +1,10 @@ -// Package branch contains the core branch service interface and implementation. +// Package branch contains the core branch service interface. package branch import "context" -// Service is the branch service interface. +// Service is the branch service interface. It can be used to execute +// code paths in an isolated execution context that can be reverted. type Service interface { // Execute executes the given function in an isolated context. If the // `f` function returns an error, the execution is considered failed, From 644cb17d53d758648b76df0cbed002350bca8891 Mon Sep 17 00:00:00 2001 From: testinginprod <98415576+testinginprod@users.noreply.github.com> Date: Tue, 7 Nov 2023 10:40:40 +0100 Subject: [PATCH 5/6] Update branch.go --- core/branch/branch.go | 1 + 1 file changed, 1 insertion(+) diff --git a/core/branch/branch.go b/core/branch/branch.go index ad46e52b6a29..9b0535062989 100644 --- a/core/branch/branch.go +++ b/core/branch/branch.go @@ -5,6 +5,7 @@ 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, From 1f05dd546beede342face250208efcea1affb6e5 Mon Sep 17 00:00:00 2001 From: unknown unknown Date: Tue, 7 Nov 2023 12:45:02 +0100 Subject: [PATCH 6/6] lint --- core/branch/branch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/branch/branch.go b/core/branch/branch.go index 9b0535062989..c5af0087fc20 100644 --- a/core/branch/branch.go +++ b/core/branch/branch.go @@ -3,7 +3,7 @@ package branch import "context" -// Service is the branch service interface. It can be used to execute +// 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 {