From 4fb4dd9f86ef82f23ac5abca4e05236e87b43241 Mon Sep 17 00:00:00 2001 From: Alfred Landrum Date: Fri, 28 Jul 2023 12:00:24 -0700 Subject: [PATCH] move IsValid to ControllableContext (#4699) **What changed?** This moves the `IsValid` method from `shard.Context` to `shard.ControllableContext`. **Why?** Only the shard controller needs to call `IsValid`. **How did you test it?** CI. **Potential risks** None. **Is hotfix candidate?** No. --- service/history/shard/context.go | 4 ++-- service/history/shard/context_mock.go | 14 -------------- service/history/shard/controller_impl.go | 2 +- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/service/history/shard/context.go b/service/history/shard/context.go index fa3768a394b..2f24b679a99 100644 --- a/service/history/shard/context.go +++ b/service/history/shard/context.go @@ -57,7 +57,6 @@ type ( Context interface { GetShardID() int32 GetRangeID() int64 - IsValid() bool GetOwner() string GetExecutionManager() persistence.ExecutionManager GetNamespaceRegistry() namespace.Registry @@ -126,8 +125,9 @@ type ( // the Controller. ControllableContext interface { Context - common.Pingable + + IsValid() bool FinishStop() } ) diff --git a/service/history/shard/context_mock.go b/service/history/shard/context_mock.go index 07422a6516e..62becd75270 100644 --- a/service/history/shard/context_mock.go +++ b/service/history/shard/context_mock.go @@ -594,20 +594,6 @@ func (mr *MockContextMockRecorder) GetWorkflowExecution(ctx, request interface{} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkflowExecution", reflect.TypeOf((*MockContext)(nil).GetWorkflowExecution), ctx, request) } -// IsValid mocks base method. -func (m *MockContext) IsValid() bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsValid") - ret0, _ := ret[0].(bool) - return ret0 -} - -// IsValid indicates an expected call of IsValid. -func (mr *MockContextMockRecorder) IsValid() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsValid", reflect.TypeOf((*MockContext)(nil).IsValid)) -} - // NewVectorClock mocks base method. func (m *MockContext) NewVectorClock() (*v11.VectorClock, error) { m.ctrl.T.Helper() diff --git a/service/history/shard/controller_impl.go b/service/history/shard/controller_impl.go index 2878feb884c..9e93e2bea53 100644 --- a/service/history/shard/controller_impl.go +++ b/service/history/shard/controller_impl.go @@ -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 }