Skip to content

Commit 80e222f

Browse files
vytautas-karpaviciusmeiliang86
authored andcommitted
Register alias for struct activities
1 parent c8b6e9c commit 80e222f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

internal/registry.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,21 @@ func (r *registry) registerActivityStruct(aStruct interface{}, options RegisterA
159159
if method.PkgPath != "" {
160160
continue
161161
}
162-
name := method.Name
162+
methodName := method.Name
163+
structPrefix := options.Name
163164
if err := validateFnFormat(method.Type, false); err != nil {
164-
return fmt.Errorf("failed to register activity method %v of %v: %e", name, structType.Name(), err)
165+
return fmt.Errorf("failed to register activity method %v of %v: %e", methodName, structType.Name(), err)
165166
}
166-
registerName := options.Name + name
167+
registerName := structPrefix + methodName
167168
if !options.DisableAlreadyRegisteredCheck {
168169
if _, ok := r.getActivityNoLock(registerName); ok {
169170
return fmt.Errorf("activity type \"%v\" is already registered", registerName)
170171
}
171172
}
172173
r.activityFuncMap[registerName] = &activityExecutor{registerName, methodValue.Interface()}
174+
if len(structPrefix) > 0 {
175+
r.activityAliasMap[methodName] = registerName
176+
}
173177
count++
174178
}
175179

0 commit comments

Comments
 (0)