Skip to content

Commit 9ecb2a4

Browse files
authoredJun 6, 2024··
Change GetUpdateInfo to GetCurrentUpdateInfo (#1505)
1 parent bf29944 commit 9ecb2a4

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed
 

‎internal/interceptor.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ type WorkflowOutboundInterceptor interface {
200200
// GetTypedSearchAttributes intercepts workflow.GetTypedSearchAttributes.
201201
GetTypedSearchAttributes(ctx Context) SearchAttributes
202202

203-
// GetUpdateInfo intercepts workflow.GetUpdateInfo.
203+
// GetCurrentUpdateInfo intercepts workflow.GetCurrentUpdateInfo.
204204
//
205205
// NOTE: Experimental
206-
GetUpdateInfo(ctx Context) *UpdateInfo
206+
GetCurrentUpdateInfo(ctx Context) *UpdateInfo
207207

208208
// GetLogger intercepts workflow.GetLogger.
209209
GetLogger(ctx Context) log.Logger

‎internal/interceptor_base.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ func (w *WorkflowOutboundInterceptorBase) GetTypedSearchAttributes(ctx Context)
233233
return w.Next.GetTypedSearchAttributes(ctx)
234234
}
235235

236-
// GetUpdateInfo implements WorkflowOutboundInterceptor.GetUpdateInfo.
237-
func (w *WorkflowOutboundInterceptorBase) GetUpdateInfo(ctx Context) *UpdateInfo {
238-
return w.Next.GetUpdateInfo(ctx)
236+
// GetCurrentUpdateInfo implements WorkflowOutboundInterceptor.GetCurrentUpdateInfo.
237+
func (w *WorkflowOutboundInterceptorBase) GetCurrentUpdateInfo(ctx Context) *UpdateInfo {
238+
return w.Next.GetCurrentUpdateInfo(ctx)
239239
}
240240

241241
// GetLogger implements WorkflowOutboundInterceptor.GetLogger.

‎internal/internal_update.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ func defaultUpdateHandler(
275275

276276
updateRunner := func(ctx Context) {
277277
ctx = WithValue(ctx, updateInfoContextKey, &UpdateInfo{
278-
ID: id,
278+
ID: id,
279+
Name: name,
279280
})
280281

281282
eo := getWorkflowEnvOptions(ctx)

‎internal/workflow.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,10 @@ type WorkflowInfo struct {
10341034

10351035
// UpdateInfo information about a currently running update
10361036
type UpdateInfo struct {
1037+
// ID of the update
10371038
ID string
1039+
// Name of the update
1040+
Name string
10381041
}
10391042

10401043
// GetBinaryChecksum returns the binary checksum of the last worker to complete a task for this
@@ -1094,12 +1097,12 @@ func (wc *workflowEnvironmentInterceptor) GetTypedSearchAttributes(ctx Context)
10941097
}
10951098

10961099
// GetUpdateInfo extracts info of a currently running update from a context.
1097-
func GetUpdateInfo(ctx Context) *UpdateInfo {
1100+
func GetCurrentUpdateInfo(ctx Context) *UpdateInfo {
10981101
i := getWorkflowOutboundInterceptor(ctx)
1099-
return i.GetUpdateInfo(ctx)
1102+
return i.GetCurrentUpdateInfo(ctx)
11001103
}
11011104

1102-
func (wc *workflowEnvironmentInterceptor) GetUpdateInfo(ctx Context) *UpdateInfo {
1105+
func (wc *workflowEnvironmentInterceptor) GetCurrentUpdateInfo(ctx Context) *UpdateInfo {
11031106
uc := ctx.Value(updateInfoContextKey)
11041107
if uc == nil {
11051108
panic("getWorkflowOutboundInterceptor: No update associated with this context")

‎test/workflow_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,10 @@ func (w *Workflows) UpdateCancelableWorkflow(ctx workflow.Context) error {
354354

355355
func (w *Workflows) UpdateInfoWorkflow(ctx workflow.Context) error {
356356
err := workflow.SetUpdateHandlerWithOptions(ctx, "update", func(ctx workflow.Context) (string, error) {
357-
return workflow.GetUpdateInfo(ctx).ID, nil
357+
return workflow.GetCurrentUpdateInfo(ctx).ID, nil
358358
}, workflow.UpdateHandlerOptions{
359359
Validator: func(ctx workflow.Context) error {
360-
if workflow.GetUpdateInfo(ctx).ID != "testID" {
360+
if workflow.GetCurrentUpdateInfo(ctx).ID != "testID" {
361361
return errors.New("invalid update ID")
362362
}
363363
return nil

‎workflow/workflow.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,12 @@ func GetTypedSearchAttributes(ctx Context) temporal.SearchAttributes {
207207
return internal.GetTypedSearchAttributes(ctx)
208208
}
209209

210-
func GetUpdateInfo(ctx Context) *UpdateInfo {
211-
return internal.GetUpdateInfo(ctx)
210+
// GetCurrentUpdateInfo returns information about the currently running update if any
211+
// from the context.
212+
//
213+
// NOTE: Experimental
214+
func GetCurrentUpdateInfo(ctx Context) *UpdateInfo {
215+
return internal.GetCurrentUpdateInfo(ctx)
212216
}
213217

214218
// GetLogger returns a logger to be used in workflow's context

0 commit comments

Comments
 (0)
Please sign in to comment.