Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental user metadata and workflow metadata query support #1597

Merged
merged 7 commits into from
Aug 30, 2024

Conversation

cretz
Copy link
Member

@cretz cretz commented Aug 16, 2024

What was changed

  • Added StartWorkflowOptions.StaticSummary and StartWorkflowOptions.StaticDetails fields that are populated on workflow start event and execution config
  • Added workflow.SetCurrentDetails and workflow.GetCurrentDetails functions that set current details available on workflow metadata query
  • Added workflow.NewTimerWithOptions that accepts a TimerOptions which has a Summary to be put on the timer event
    • Note, this required a new outbound interceptor method and may have broken compile for PHP SDK internalbindings (by intention)
  • Added workflow.SetQueryHandlerWithOptions that accepts a QueryHandlerOptions which has a Description
  • Added workflow.GetSignalChannelWithOptions that accepts a SignalChannelOptions which has a Description
  • Added support for __temporal_workflow_metadata query that returns query, signal, and update definitions and the current details

Note, some things are not supported:

Checklist

  1. Closes User metadata and workflow metadata query #1565

@cretz cretz requested a review from a team as a code owner August 16, 2024 22:20
internal/internal_schedule_client.go Outdated Show resolved Hide resolved
@@ -231,6 +231,9 @@ type WorkflowOutboundInterceptor interface {
// NewTimer intercepts workflow.NewTimer.
NewTimer(ctx Context, d time.Duration) Future

// NewTimer intercepts workflow.NewTimerWithOptions.
NewTimerWithOptions(ctx Context, d time.Duration, options TimerOptions) Future
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on available options, a new outbound method seemed like the best approach here. Should be safe since we require the base to be embedded.

if options.Summary != "" {
var err error
if summary, err = dc.ToPayload(options.Summary); err != nil {
panic(err)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be rare (it's just serializing string), but there is precedent with other commandsHelper calls panicking if they can't convert.

internal/internal_workflow.go Outdated Show resolved Hide resolved
@@ -45,7 +45,7 @@ type (

// NewTimer - Creates a new timer that will fire callback after d(resolution is in seconds).
// The callback indicates the error(TimerCanceledError) if the timer is canceled.
NewTimer(d time.Duration, callback ResultHandler) *TimerID
NewTimer(d time.Duration, options TimerOptions, callback ResultHandler) *TimerID
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may break PHP SDK since it's exposed via internalbindings but unsure if they use it. This seemed like the best way and should cause a clear compile break.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they do but it should be fine

@@ -231,6 +231,9 @@ type WorkflowOutboundInterceptor interface {
// NewTimer intercepts workflow.NewTimer.
NewTimer(ctx Context, d time.Duration) Future

// NewTimer intercepts workflow.NewTimerWithOptions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can other primitives support metadata like activities? Do we plan to add support for them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and yes! We intentionally decided that workflow summary/details and timer summary was the first use case. But the user metadata is on the command/event and not the attributes for this reason. Any UI/CLI-visible metadata you could ever need on an event we can look into adding.

Copy link
Member

@Sushisource Sushisource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we had the ability to add this to child workflows straight away too?

internal/internal_command_state_machine.go Outdated Show resolved Hide resolved
@@ -45,7 +45,7 @@ type (

// NewTimer - Creates a new timer that will fire callback after d(resolution is in seconds).
// The callback indicates the error(TimerCanceledError) if the timer is canceled.
NewTimer(d time.Duration, callback ResultHandler) *TimerID
NewTimer(d time.Duration, options TimerOptions, callback ResultHandler) *TimerID
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they do but it should be fine

internal/internal_workflow.go Outdated Show resolved Hide resolved
internal/internal_workflow.go Outdated Show resolved Hide resolved
internal/internal_workflow.go Outdated Show resolved Hide resolved
internal/internal_workflow.go Show resolved Hide resolved
@@ -281,6 +281,23 @@ type (
//
// Deprecated - This is only for update of older search attributes. This may be removed in a future version.
UntypedSearchAttributes map[string]*commonpb.Payload

// Summary - Single-line summary for this workflow execution that will appear in UI/CLI. This can be in
// single-line Temporal markdown format.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these strings that reference this markdown format have info about what it is. Probably because it doesn't exist yet, but, if it does somewhere, link would be good.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, as this concept is stabilized (i.e. non-experimental) and we have something at docs.temporal.io, would definitely want to link it here.

@cretz
Copy link
Member Author

cretz commented Aug 19, 2024

I thought we had the ability to add this to child workflows straight away too?

Yes, will add

@cretz
Copy link
Member Author

cretz commented Aug 19, 2024

Actually I am not seeing child workflow as working. I put in a bunch of work to wire it up for child workflows then my integration tests show it didn't propagate. I will get with authors of temporalio/temporal#5857, but in the meantime I will add everything but the final user-facing option.

@cretz
Copy link
Member Author

cretz commented Aug 22, 2024

Updated to change to StaticSummary/StaticDetails for workflows

if err != nil {
return nil, err
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a similar change when the schedule is updated. The UpdateSchedule API on the server is structured to completely replace the schedule.Action with the value provided in the update API. So if the client wants to update a single field, it should echo back the whole schedule with the updated field. The client already seems to be doing that.
But in my testing I noticed that the usermetadata is not being copied over between these two calls - https://github.com/temporalio/sdk-go/blob/master/internal/internal_schedule_client.go#L276-L280. Looks like ScheduleWorkflowAction struct needs some updates?
cc @dnr

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This same code is used for update. The way update works in SDKs is it's a get-then-update which calls these same helpers to go from user model to proto model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User metadata and workflow metadata query
4 participants