Skip to content

Commit

Permalink
refactor: avoid breaking change due to #16415 included in v0.50 (#16430)
Browse files Browse the repository at this point in the history
(cherry picked from commit dda81a2)

# Conflicts:
#	baseapp/msg_service_router.go
  • Loading branch information
julienrbrt authored and mergify[bot] committed Jun 6, 2023
1 parent 67f33bd commit 47ac2e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 2 additions & 4 deletions baseapp/circuit.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package baseapp

import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
import "context"

// CircuitBreaker is an interface that defines the methods for a circuit breaker.
type CircuitBreaker interface {
IsAllowed(ctx sdk.Context, typeURL string) bool
IsAllowed(ctx context.Context, typeURL string) (bool, error)
}
13 changes: 13 additions & 0 deletions baseapp/msg_service_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,24 @@ func (msr *MsgServiceRouter) RegisterService(sd *grpc.ServiceDesc, handler inter
return nil, err
}

<<<<<<< HEAD
if msr.circuitBreaker != nil {
msgURL := sdk.MsgTypeURL(req)
if !msr.circuitBreaker.IsAllowed(ctx, msgURL) {
return nil, fmt.Errorf("circuit breaker disables execution of this message: %s", msgURL)
}
=======
if msr.circuitBreaker != nil {
msgURL := sdk.MsgTypeURL(req)

isAllowed, err := msr.circuitBreaker.IsAllowed(ctx, msgURL)
if err != nil {
return nil, err
}

if !isAllowed {
return nil, fmt.Errorf("circuit breaker disables execution of this message: %s", msgURL)
>>>>>>> dda81a227 (refactor: avoid breaking change due to #16415 included in v0.50 (#16430))
}
}
// Call the method handler from the service description with the handler object.
Expand Down

0 comments on commit 47ac2e2

Please sign in to comment.