Skip to content

Commit

Permalink
move IsValid to ControllableContext (#4699)
Browse files Browse the repository at this point in the history
<!-- Describe what has changed in this PR -->
**What changed?**
This moves the `IsValid` method from `shard.Context` to
`shard.ControllableContext`.

<!-- Tell your future self why have you made these changes -->
**Why?**
Only the shard controller needs to call `IsValid`.

<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
CI.

<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**
None.

<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
No.
  • Loading branch information
alfred-landrum authored Jul 28, 2023
1 parent 9269507 commit 4fb4dd9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
4 changes: 2 additions & 2 deletions service/history/shard/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ type (
Context interface {
GetShardID() int32
GetRangeID() int64
IsValid() bool
GetOwner() string
GetExecutionManager() persistence.ExecutionManager
GetNamespaceRegistry() namespace.Registry
Expand Down Expand Up @@ -126,8 +125,9 @@ type (
// the Controller.
ControllableContext interface {
Context

common.Pingable

IsValid() bool
FinishStop()
}
)
14 changes: 0 additions & 14 deletions service/history/shard/context_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/history/shard/controller_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (c *ControllerImpl) shardRemoveAndStop(shard ControllableContext) {
// getOrCreateShardContext returns a shard context for the given shard ID, creating a new one
// if necessary. If a shard context is created, it will initialize in the background.
// This function won't block on rangeid lease acquisition.
func (c *ControllerImpl) getOrCreateShardContext(shardID int32) (Context, error) {
func (c *ControllerImpl) getOrCreateShardContext(shardID int32) (ControllableContext, error) {
if err := c.validateShardId(shardID); err != nil {
return nil, err
}
Expand Down

0 comments on commit 4fb4dd9

Please # to comment.