-
Notifications
You must be signed in to change notification settings - Fork 68
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 #532
Conversation
// NamespaceRule describes a rule that can be to any workflow in this namespace. | ||
message NamespaceRule { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds more like NamespaceWorkflowRule
. Or is it intended to possibly house rules about more than just workflows (and their activities)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for now I think it will be restricted to workflow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more like:
- I can't imagine this to be on a higher level then workflows
- even if it is I probably want them to be separated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will rename it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or not. This can be used to pause TaskQueue for example. Technically it is not a part of workflow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall - yes, NamespaceRule fills like scope is too big. But NamespaceWorkflowRule feels like scope is too narrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like NamespaceRule
the most.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update the doc that says it's only intended for workflows (unsure if we can expect such a thing when the expected scope-expanse occurs)
// I will remove it once we agree on the overall design | ||
// RULE_ACTION_TYPE_EMIT_VISIBILITY = 3; | ||
// RULE_ACTION_TYPE_PAUSE_WORKFLOW = 4; | ||
// RULE_ACTION_TYPE_SIGNAL = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move them inside enum
(still commented out) with comment saying something like here are other possible actions which might be implemented in future
.
// I will remove it once we agree on the overall design. | ||
// Payload of the rule action. The payload is specific to the rule action type. | ||
// temporal.api.common.v1.Payload payload = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same. Leave it commented out. I think it is acceptable.
// NamespaceRule describes a rule that can be to any workflow in this namespace. | ||
message NamespaceRule { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like NamespaceRule
the most.
// Name of the rule. | ||
string name = 1; | ||
|
||
// ID must be unique within the namespace | ||
string id = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should follow the same approach as we do for namespaces themselves. Id
is hidden from the user (mostly). When user creates rule, it specifies only name
and gets Id
back in response. Then user can address rule by name (and by Id
too). Yes, you can't guarantee uniqueness of the name. We need to discuss what we can do in this case.
} | ||
|
||
// ApplyNamespaceRule allows to apply rule to a certain workflow instance without creating a rule. | ||
// This is useful for one-off operations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and for tests too. I mean users can test how feature works with test workflows.
message DescribeNamespaceRuleRequest { | ||
string namespace = 1; | ||
|
||
string rule_id = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if you use oneof
for both id
and name
. And for Delete
too.
|
||
message RuleAction { | ||
// Type of the rule action. | ||
temporal.api.enums.v1.RuleActionType type = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should consider structured data for the action instead of an enum. Therefore if an action needs data, it can be properly modeled data and not arbitrary payload or whatever. I recommend a oneof
with specific messages representing the actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that is exactly what I did, PR is not updated - I want to update it after the discussion.
// Type of the rule trigger. Right now only activity is supported. | ||
// Trigger type defines when the rule should be evaluated. | ||
// It also defines the columns available in the predicate. | ||
// - activity: Rule will be triggered when an activity is about to start. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't sound like an ACTIVITY
trigger, but rather an ACTIVITY_START
trigger. There are many event situations in an activity.
RULE_TRIGGER_TYPE_ACTIVITY = 1; | ||
RULE_TRIGGER_TYPE_WORKFLOW = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we define what these represent? And if workflow is not in use it does not need to be present.
enum RuleActionType { | ||
RULE_ACTION_TYPE_UNSPECIFIED = 0; | ||
RULE_ACTION_TYPE_PAUSE_ACTIVITY = 1; | ||
RULE_ACTION_TYPE_EMIT_METRIC = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what emit metric means exactly? There are lots of details to emitting a metric (metric name, labels, etc) but I can't find where such things would be set. Also, is that part of this project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about emitting metrics with predefined name, with dimensions like namespace, "type". May be with "rule name" as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you document the exact behavior of this enum? It was unclear to me and I suspect other users of the API what this means exactly? I do think this and other actions make sense as structured messages instead of just enumerates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, in the doc I moved from enum to "oneof" and messages, so we can have structured action payload later if we need to.
// Trigger type defines when the rule should be evaluated. | ||
// It also defines the columns available in the predicate. | ||
// - activity: Rule will be triggered when an activity is about to start. | ||
temporal.api.enums.v1.RuleTriggerType trigger_type = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the concept of "action" and the "trigger" should be merged. Some actions make no sense with some triggers I assume. I think an action should also define when it should take place alongside its other options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no 1:1 mapping between "action" and "trigger". For example workflow pause can be triggered by activity rule.
// RULE_ACTION_TYPE_EMIT_VISIBILITY = 3; | ||
// RULE_ACTION_TYPE_PAUSE_WORKFLOW = 4; | ||
// RULE_ACTION_TYPE_SIGNAL = 5; | ||
enum RuleActionType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum RuleActionType { | |
enum NamespaceRuleActionType { |
Not sure it's safe to assume every use of the term "rule" will apply to namespace rules (same in other places where not qualified)
// If true, the rule will be applied immediately via batch job. | ||
bool force_apply = 3; | ||
|
||
// the workflow query to use to apply the rule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pedantic, but there is a lot of inconsistent with capitalization of comments, punctuation, etc
bool force_apply = 3; | ||
|
||
// the workflow query to use to apply the rule | ||
string workflow_query = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this already in the rule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I go back and force on this a lot...
we will discuss it offline
// - 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 = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is a "predicate"? Is this some kind of new query format? Is it possible to use well-typed structured representations of this? If not, I would at least request a grammar (we didn't have it for the longest time for workflow query and people were confused for a long time), but ideally we are stronger typed and more structural than that.
What changed?
This is a proposal for "namespace level rules". First implementation will be "activity pause".
Each rule is defined by:
Why?
Part of the operational efforts. In case of ongoing issues users don't only want to affect (pause for example) running workflows/activities, but also prevent incoming workflows/activities from running into the same issues.
But based on the feedback the scope can be wider, and this can be solved in more generable way. Thus this proposal.