Skip to content

Commit

Permalink
Add Action and WorkflowRule definitions (#554)
Browse files Browse the repository at this point in the history
<!-- Describe what has changed in this PR -->
**What changed?**
* Add Action proto definition
* Add WorkflowRuleSpec/WorkflowRule proto definitions

<!-- Tell your future self why have you made these changes -->
**Why?**
Part of WorkflowRules workstream.

Changes are reviewed in [this
PR](#554)
  • Loading branch information
ychebotarev authored Feb 12, 2025
1 parent add5b50 commit e942bf1
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
9 changes: 9 additions & 0 deletions temporal/api/enums/v1/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,12 @@ enum NexusOperationCancellationState {
// Cancellation request is blocked (eg: by circuit breaker).
NEXUS_OPERATION_CANCELLATION_STATE_BLOCKED = 6;
}

enum RuleActionScope {
// Default value, unspecified scope.
RULE_ACTION_SCOPE_UNSPECIFIED = 0;
// The action will be applied to the entire workflow.
RULE_ACTION_SCOPE_WORKFLOW = 1;
// The action will be applied to a specific activity.
RULE_ACTION_SCOPE_ACTIVITY = 2;
}
99 changes: 99 additions & 0 deletions temporal/api/rules/v1/message.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// The MIT License
//
// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

syntax = "proto3";

package temporal.api.rules.v1;

option go_package = "go.temporal.io/api/rules/v1;rules";
option java_package = "io.temporal.api.rules.v1";
option java_multiple_files = true;
option java_outer_classname = "MessageProto";
option ruby_package = "Temporalio::Api::Rules::V1";
option csharp_namespace = "Temporalio.Api.Rules.V1";


import "google/protobuf/timestamp.proto";
import "temporal/api/enums/v1/common.proto";

message Action {
// Pause action.
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;
}

// Supported actions.
oneof variant {
ActionPause pause = 1;
}
}

message WorkflowRuleSpec {
// The id of the new workflow rule. Must be unique within the namespace.
string id = 1;

// Activity trigger will be triggered when an activity is about to start.
message ActivityStartTrigger {
// Activity predicate is used to match against workflow data, based on rule trigger type.
// The following activity attributes are supported as part of the predicate:
// - ActivityType: The type of the activity.
// - ActivityId: The ID of the activity.
// - ActivityAttempt: The number attempts of the activity.
// - 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;
}

// Specifies how the rule should be triggered and evaluated.
// Currently, only "activity start" type is supported.
oneof trigger {
ActivityStartTrigger activity_start = 2;
}

// Restricted Visibility query.
// The following activity attributes are supported as part of the predicate:
// - WorkflowType
// - WorkflowId
// - StartTime
// - ExecutionStatus
string visibility_query = 3;

// Action to be taken when the rule is triggered and predicate is matched.
repeated Action actions = 4;

// Expiration time of the rule. After this time, the rule will be deleted.
// Can be empty if the rule should never expire.
google.protobuf.Timestamp expiration_time = 5;
}

// WorkflowRule describes a rule that can be applied to any workflow in this namespace.
message WorkflowRule {
// Rule creation date.
google.protobuf.Timestamp create_time = 1;

// Rule specification
WorkflowRuleSpec spec = 2;
}

0 comments on commit e942bf1

Please sign in to comment.