Skip to content

Commit

Permalink
remove unused GetName method for activity interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ketsiambaku committed Jun 9, 2024
1 parent 4045559 commit 944bdfe
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 27 deletions.
2 changes: 0 additions & 2 deletions internal/internal_task_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1505,8 +1505,6 @@ func (t *testActivityDeadline) GetOptions() RegisterActivityOptions {
return RegisterActivityOptions{}
}

func (t *testActivityDeadline) GetName() string { return "test-Activity-Deadline" }

type deadlineTest struct {
actWaitDuration time.Duration
ScheduleTS time.Time
Expand Down
2 changes: 0 additions & 2 deletions internal/internal_worker_interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ func (ga greeterActivity) GetOptions() RegisterActivityOptions {
return RegisterActivityOptions{}
}

func (ga greeterActivity) GetName() string { return "Greeter_Activity" }

// Greeter activity func
func greeterActivityFunc(ctx context.Context, input []byte) ([]byte, error) {
return []byte("Hello world"), nil
Expand Down
15 changes: 10 additions & 5 deletions internal/workflow_replayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"context"
"errors"
"fmt"
"reflect"
"runtime"
"testing"
"time"

Expand Down Expand Up @@ -143,13 +145,16 @@ func (s *workflowReplayerSuite) TestActivityRegistration() {
name := "test-Activity"
s.replayer.RegisterActivityWithOptions(testActivityFunction, RegisterActivityOptions{Name: name})
a := s.replayer.GetRegisteredActivities()[0]
require.Equal(s.T(), name, a)
s.Equal(name, a)

_, ok := s.replayer.GetActivityAlias(getFunctionName(testActivityFunction))
require.True(s.T(), ok)
alias, ok := s.replayer.GetActivityAlias(getFunctionName(testActivityFunction))
s.True(ok)
s.Equal(name, alias)

_, ok = s.replayer.GetActivityFn(a)
require.True(s.T(), ok)
fn, ok := s.replayer.GetActivityFn(a)
s.True(ok)
s.Equal(reflect.Func, reflect.ValueOf(fn).Kind())
s.Equal(getFunctionName(testActivityFunction), runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name())
}

func testReplayWorkflow(ctx Context) error {
Expand Down
13 changes: 8 additions & 5 deletions internal/workflow_shadower_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ package internal
import (
"context"
"fmt"
"reflect"
"runtime"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -439,14 +441,15 @@ func (s *workflowShadowerSuite) TestShadowWorker_ExpectedReplayError() {

func (s *workflowShadowerSuite) TestWorkflowRegistration() {
wfName := s.testShadower.GetRegisteredWorkflows()[0]
require.Equal(s.T(), getFunctionName(testReplayWorkflow), wfName)
fnName := getFunctionName(testReplayWorkflow)
s.Equal(fnName, wfName)

_, ok := s.testShadower.GetWorkflowAlias(wfName)
require.False(s.T(), ok)

_, ok = s.testShadower.GetWorkflowFn(wfName)
require.True(s.T(), ok)
s.False(ok)

fn, ok := s.testShadower.GetWorkflowFn(wfName)
s.True(ok)
s.Equal(fnName, runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name())
}

func newTestWorkflowExecutions(size int) []*shared.WorkflowExecutionInfo {
Expand Down
26 changes: 13 additions & 13 deletions worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,22 @@ type (
// type name twice. Use workflow.RegisterOptions.DisableAlreadyRegisteredCheck to allow multiple registrations.
RegisterWorkflowWithOptions(w interface{}, options workflow.RegisterOptions)

// GetRegisteredWorkflows returns a list of all registered workflow names on the registry.
// The workflow name is by default the method name. However, if the workflow was registered
// with options (see RegisterWorkflowWithOptions), it may have a customized name.
// For chained registries, this returns a combined list of all registered workflows from the current
// instance to the global registry. In this case, the list may contain duplicates names.
// GetRegisteredWorkflows returns a list of all workflows registered on the worker.
// The returned workflow name is by default the method name. However, if the workflow was registered
// with options (see Worker.RegisterWorkflowWithOptions), the workflow may have customized name.
// For chained registries, this returns a combined list of all registered activities from the current
// instance to the global registry. In this case, the list may contain duplicate names.
GetRegisteredWorkflows() []string

// GetWorkflowAlias returns the customized workflow name recorded for the provided function name
// and a boolean value indicating whether an alias was found.
// All customization on the workflow name are provided with workflow.RegisterOptions{}.
// The function returns "", false if no alias was found.
// This method returns an empty string and false if no alias was found.
GetWorkflowAlias(fnName string) (string, bool)

// GetWorkflowFn takes a name and returns the corresponding workflow
// function and a boolean value indicating whether the activity was found.
// It returns nil, false when no activity was registered with the provided name.
// It returns nil, false when no workflow was registered with the provided name.
// The registerName is the resolved name recorded on the registry after all options
// from workflow.RegisterOptions{} are applied.
GetWorkflowFn(registerName string) (interface{}, bool)
Expand Down Expand Up @@ -152,19 +152,19 @@ type (
// worker.RegisterActivityWithOptions(barActivity, RegisterActivityOptions{DisableAlreadyRegisteredCheck: true})
RegisterActivityWithOptions(a interface{}, options activity.RegisterOptions)

// GetRegisteredActivities returns a list of all registered activity names on the registry.
// GetRegisteredActivities returns the names of all activities registered on the worker.
// The activity name is by default the method name. However, if the activity was registered
// with options (see worker.RegisterActivityWithOptions), it may be a customized name.
// with options (see Worker.RegisterActivityWithOptions), the activity may have customized name.
// For example, struct pointer activities that were registered with the Name option activity.RegisterOptions{Name: ...}
// will have their method names prepended with the option name.
// will have their method names prepended with the provided name option.
// For chained registries, this returns a combined list of all registered activities from the current
// instance to the global registry. In this case, the list may contain duplicates names.
// instance to the global registry. In this case, the list may contain duplicate names.
GetRegisteredActivities() []string

// GetActivityAlias returns the customized activity name recorded for the provided function name
// and a boolean value indicating whether an alias was found.
// All customization on the activity name are provided with activity.RegisterOptions{}.
// The function returns "", false if no alias was found
// All customization on the activity name are provided with Worker.RegisterActivityWithOptions.
// This method returns an empty string and false if no alias was found.
GetActivityAlias(fnName string) (string, bool)

// GetActivityFn takes a name and returns the corresponding activity
Expand Down

0 comments on commit 944bdfe

Please sign in to comment.