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

Discuss: namespace rules prototype #550

Closed
wants to merge 11 commits into from
Closed

Conversation

ychebotarev
Copy link
Contributor

@ychebotarev ychebotarev commented Feb 5, 2025

What changed?

  • Rename NamespaceRule to WorfklowRule (and all that follows)
  • Add structure to rule triggering
  • Move predicate inside trigger
  • Change RESt API to "workflow-rules"
  • Make "Action" generic message, with scope
  • Move rules into separate package

Not for merge
This is a proposal for "namespace level rules". First implementation will be "activity pause".
This PR is based in the latest discussion, and contains all the changes.

Old PR:
#532

@ychebotarev ychebotarev requested review from a team as code owners February 5, 2025 23:21
temporal/api/batch/v1/message.proto Outdated Show resolved Hide resolved
temporal/api/batch/v1/message.proto Outdated Show resolved Hide resolved
temporal/api/namespace/v1/message.proto Outdated Show resolved Hide resolved
temporal/api/namespace/v1/message.proto Outdated Show resolved Hide resolved
temporal/api/namespace/v1/message.proto Outdated Show resolved Hide resolved
temporal/api/workflowservice/v1/request_response.proto Outdated Show resolved Hide resolved
temporal/api/workflowservice/v1/request_response.proto Outdated Show resolved Hide resolved
temporal/api/workflowservice/v1/request_response.proto Outdated Show resolved Hide resolved
temporal/api/workflowservice/v1/request_response.proto Outdated Show resolved Hide resolved
temporal/api/workflowservice/v1/service.proto Outdated Show resolved Hide resolved
temporal/api/namespace/v1/message.proto Outdated Show resolved Hide resolved
temporal/api/namespace/v1/message.proto Outdated Show resolved Hide resolved
temporal/api/namespace/v1/message.proto Outdated Show resolved Hide resolved
temporal/api/enums/v1/namespace.proto Outdated Show resolved Hide resolved
temporal/api/workflowservice/v1/request_response.proto Outdated Show resolved Hide resolved
temporal/api/workflowservice/v1/request_response.proto Outdated Show resolved Hide resolved
temporal/api/workflowservice/v1/service.proto Outdated Show resolved Hide resolved
temporal/api/workflowservice/v1/service.proto Outdated Show resolved Hide resolved
temporal/api/workflowservice/v1/service.proto Outdated Show resolved Hide resolved
temporal/api/workflowservice/v1/service.proto Outdated Show resolved Hide resolved
Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

Only minor comments, I think overall the updates are great

temporal/api/workflow/v1/message.proto Outdated Show resolved Hide resolved
temporal/api/workflow/v1/message.proto Outdated Show resolved Hide resolved
temporal/api/workflowservice/v1/service.proto Outdated Show resolved Hide resolved
@ychebotarev ychebotarev requested a review from bergundy February 7, 2025 17:28
Copy link
Member

@bergundy bergundy left a comment

Choose a reason for hiding this comment

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

Not sure what was applied from my previous round of feedback, with this drastic change it's hard to follow.

temporal/api/batch/v1/message.proto Show resolved Hide resolved
temporal/api/workflow/v1/message.proto Outdated Show resolved Hide resolved
@bergundy
Copy link
Member

bergundy commented Feb 7, 2025

Not sure what was applied from my previous round of feedback, with this drastic change it's hard to follow.

Ah, for some reason I wasn't getting notifications on all of the comments, I missed a couple of days worth of discussions.

// - BackoffInterval: The current backoff interval of the activity.
// - ActivityStatus: The status of the activity. Can be one of "scheduled", "started", "paused".
// - TaskQueue: The name of the task queue of the activity.
string predicate = 1;
Copy link
Member

Choose a reason for hiding this comment

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

May need to say this takes the same format as visibility queries just with different attributes. @rodrigozhou - now that we're reusing this format, can we now publish the grammar doc that we maintain internally?

temporal/api/enums/v1/common.proto Outdated Show resolved Hide resolved
temporal/api/rules/v1/message.proto Outdated Show resolved Hide resolved
temporal/api/rules/v1/message.proto Show resolved Hide resolved
Copy link
Member

@bergundy bergundy left a comment

Choose a reason for hiding this comment

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

I skimmed this again and don't have any blocking comments. Please also get one SDK approver (@cretz).

temporal/api/enums/v1/common.proto Outdated Show resolved Hide resolved
temporal/api/rules/v1/message.proto Show resolved Hide resolved
Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

Sorry, started this review and realized I didn't submit it.

temporal/api/workflowservice/v1/service.proto Outdated Show resolved Hide resolved
Comment on lines +40 to +45
message ActionPause {
// Indicates what should be paused. Depending on the scope value, the action
// will pause the entire workflow or a specific activity (additional entities
// may be supported in the future).
temporal.api.enums.v1.RuleActionScope scope = 1;
}
Copy link
Member

@cretz cretz Feb 11, 2025

Choose a reason for hiding this comment

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

I am not sure it makes sense to model activity pause and workflow pause together. What do they have in common besides the word "pause"? I think these are two separate actions, I think only activity pause should be implemented now, and I don't think the "action scope" should be a thing. Sooner or later you'll want an action-pause-only or workflow-pause-only specific option and regret that you combined them into the same structure just because they both have the word "pause".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there are two ways of modeling this - have a separate message to encode each valid <action, scope> pair:

message ActivityPauseAction {
}
message WorkflowPauseAction {
}
...

or encapsulation - single action - pause - that can be applied in different scope.

message ActionPause {
   Scope scope;
}

There are multiple pro-con for each of those approaches, but in a context of current WorkflowRule and future rules (according to Roey they will come) generic action with specific scope feels like a cleaner fit.

Yes, its a valid concern, that sooner or later I would have some action that is not applicable to all scopes, like "activity-specific" action. It will be a situation where not every pair of * is supported. "pro" (at least for me) are outweighing "con".

Specifically:

  • less upfront complexity. If we decide to encode every cross-product as a single message it will make a bigger surface. For 4 actions 2 scopes it is already 8 different messages. And it is very likely there will be 4.Messy.
  • Extensibility. We expect more "scope" and "actions". and adding new will be easier this way.
  • This is "reactive' API, so compile-time guarantee (main "pro" of separate messages for every pair) is not that important. Run-time validation is good enough.

}

// Emit a metric.
message ActionEmitMetric {
Copy link
Member

Choose a reason for hiding this comment

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

Is this part of the project expected to be implemented now? If so, can I get more details on what metric is emitted and options and such?

Copy link
Contributor Author

@ychebotarev ychebotarev Feb 12, 2025

Choose a reason for hiding this comment

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

it is not expected to be implemented now. It will not be in the "merge" PR

ychebotarev added a commit that referenced this pull request Feb 12, 2025
<!-- Describe what has changed in this PR -->
**What changed?**
Adding basic workflow rules operations:
* CreateWorkflowRule
* DescribeWorkflowRule
* DeleteWorkflowRule
* ListWorkflowRules

<!-- Tell your future self why have you made these changes -->
**Why?**

Part of workflow rules workstream.

Discussed in [this PR](#550).
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.

3 participants