Skip to content

Commit

Permalink
Separate some interfaces from implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ychebotarev committed Jan 7, 2025
1 parent 4c22972 commit a37dce5
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 13 deletions.
5 changes: 3 additions & 2 deletions components/callbacks/executors.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/resource"
components "go.temporal.io/server/components/common"
"go.temporal.io/server/service/history/hsm"
"go.temporal.io/server/service/history/queues"
"go.uber.org/fx"
Expand Down Expand Up @@ -160,7 +161,7 @@ func (e taskExecutor) loadInvocationArgs(

switch variant := callback.GetCallback().GetVariant().(type) {
case *persistencespb.Callback_Nexus_:
target, err := hsm.MachineData[CanGetNexusCompletion](node.Parent)
target, err := hsm.MachineData[components.CanGetNexusCompletion](node.Parent)
if err != nil {
return err
}
Expand All @@ -173,7 +174,7 @@ func (e taskExecutor) loadInvocationArgs(
return err
}
case *persistencespb.Callback_Hsm:
target, err := hsm.MachineData[CanGetHSMCompletionCallbackArg](node.Parent)
target, err := hsm.MachineData[components.CanGetHSMCompletionCallbackArg](node.Parent)
if err != nil {
return err
}
Expand Down
4 changes: 0 additions & 4 deletions components/callbacks/hsm_invocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ import (
"google.golang.org/grpc/status"
)

type CanGetHSMCompletionCallbackArg interface {
GetHSMCompletionCallbackArg(ctx context.Context) (*persistencespb.HSMCompletionCallbackArg, error)
}

type hsmInvocation struct {
hsm *persistencespb.Callback_HSM
callbackArg *persistencespb.HSMCompletionCallbackArg
Expand Down
4 changes: 0 additions & 4 deletions components/callbacks/nexus_invocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ var retryable4xxErrorTypes = []int{
http.StatusTooManyRequests,
}

type CanGetNexusCompletion interface {
GetNexusCompletion(ctx context.Context) (nexus.OperationCompletion, error)
}

type nexusInvocation struct {
nexus *persistencespb.Callback_Nexus
completion nexus.OperationCompletion
Expand Down
33 changes: 33 additions & 0 deletions components/common/hsm_completion_callback.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// The MIT License
//
// Copyright (c) 2024 Temporal Technologies Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package common

import (
"context"

persistencespb "go.temporal.io/server/api/persistence/v1"
)

type CanGetHSMCompletionCallbackArg interface {
GetHSMCompletionCallbackArg(ctx context.Context) (*persistencespb.HSMCompletionCallbackArg, error)
}
33 changes: 33 additions & 0 deletions components/common/nexus_completion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// The MIT License
//
// Copyright (c) 2024 Temporal Technologies Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package common

import (
"context"

"github.com/nexus-rpc/sdk-go/nexus"
)

type CanGetNexusCompletion interface {
GetNexusCompletion(ctx context.Context) (nexus.OperationCompletion, error)
}
6 changes: 3 additions & 3 deletions service/history/workflow/mutable_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import (
"go.temporal.io/server/common/definition"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/persistence"
"go.temporal.io/server/components/callbacks"
components "go.temporal.io/server/components/common"
"go.temporal.io/server/service/history/historybuilder"
"go.temporal.io/server/service/history/hsm"
"go.temporal.io/server/service/history/tasks"
Expand Down Expand Up @@ -151,8 +151,8 @@ type (
ActivityUpdater func(*persistencespb.ActivityInfo, MutableState) error

MutableState interface {
callbacks.CanGetNexusCompletion
callbacks.CanGetHSMCompletionCallbackArg
components.CanGetNexusCompletion
components.CanGetHSMCompletionCallbackArg
AddHistoryEvent(t enumspb.EventType, setAttributes func(*historypb.HistoryEvent)) *historypb.HistoryEvent
LoadHistoryEvent(ctx context.Context, token []byte) (*historypb.HistoryEvent, error)

Expand Down

0 comments on commit a37dce5

Please sign in to comment.