Skip to content

Commit ef0a692

Browse files
authored
Merge pull request #535 from conductor-oss/wf-cache-config
Added cache config for workflow
2 parents acd6120 + c79f0fa commit ef0a692

File tree

7 files changed

+93
-47
lines changed

7 files changed

+93
-47
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2025 Conductor Authors.
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
* <p>
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* <p>
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package com.netflix.conductor.common.metadata.workflow;
14+
15+
import com.netflix.conductor.annotations.protogen.ProtoField;
16+
import com.netflix.conductor.annotations.protogen.ProtoMessage;
17+
18+
@ProtoMessage
19+
public class CacheConfig {
20+
21+
@ProtoField(id = 1)
22+
private String key;
23+
24+
@ProtoField(id = 2)
25+
private int ttlInSecond;
26+
27+
public String getKey() {
28+
return key;
29+
}
30+
31+
public void setKey(String key) {
32+
this.key = key;
33+
}
34+
35+
public int getTtlInSecond() {
36+
return ttlInSecond;
37+
}
38+
39+
public void setTtlInSecond(int ttlInSecond) {
40+
this.ttlInSecond = ttlInSecond;
41+
}
42+
}

common/src/main/java/com/netflix/conductor/common/metadata/workflow/WorkflowDef.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ public enum TimeoutPolicy {
109109
@ProtoField(id = 22)
110110
private Map<String, Object> metadata = new HashMap<>();
111111

112+
@ProtoField(id = 23)
113+
private CacheConfig cacheConfig;
114+
112115
public boolean isEnforceSchema() {
113116
return enforceSchema;
114117
}
@@ -377,6 +380,14 @@ public void setMetadata(Map<String, Object> metadata) {
377380
this.metadata = metadata;
378381
}
379382

383+
public CacheConfig getCacheConfig() {
384+
return cacheConfig;
385+
}
386+
387+
public void setCacheConfig(final CacheConfig cacheConfig) {
388+
this.cacheConfig = cacheConfig;
389+
}
390+
380391
public boolean containsType(String taskType) {
381392
return collectTasks().stream().anyMatch(t -> t.getType().equals(taskType));
382393
}

common/src/main/java/com/netflix/conductor/common/metadata/workflow/WorkflowTask.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,6 @@
3838
@ProtoMessage
3939
public class WorkflowTask {
4040

41-
@ProtoMessage
42-
public static class CacheConfig {
43-
44-
@ProtoField(id = 1)
45-
private String key;
46-
47-
@ProtoField(id = 2)
48-
private int ttlInSecond;
49-
50-
public String getKey() {
51-
return key;
52-
}
53-
54-
public void setKey(String key) {
55-
this.key = key;
56-
}
57-
58-
public int getTtlInSecond() {
59-
return ttlInSecond;
60-
}
61-
62-
public void setTtlInSecond(int ttlInSecond) {
63-
this.ttlInSecond = ttlInSecond;
64-
}
65-
}
66-
6741
@ProtoField(id = 1)
6842
@NotEmpty(message = "WorkflowTask name cannot be empty or null")
6943
private String name;

grpc/src/main/java/com/netflix/conductor/grpc/AbstractProtoMapper.java

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.netflix.conductor.common.metadata.tasks.TaskDef;
1111
import com.netflix.conductor.common.metadata.tasks.TaskExecLog;
1212
import com.netflix.conductor.common.metadata.tasks.TaskResult;
13+
import com.netflix.conductor.common.metadata.workflow.CacheConfig;
1314
import com.netflix.conductor.common.metadata.workflow.DynamicForkJoinTask;
1415
import com.netflix.conductor.common.metadata.workflow.DynamicForkJoinTaskList;
1516
import com.netflix.conductor.common.metadata.workflow.RateLimitConfig;
@@ -25,6 +26,7 @@
2526
import com.netflix.conductor.common.run.TaskSummary;
2627
import com.netflix.conductor.common.run.Workflow;
2728
import com.netflix.conductor.common.run.WorkflowSummary;
29+
import com.netflix.conductor.proto.CacheConfigPb;
2830
import com.netflix.conductor.proto.DynamicForkJoinTaskListPb;
2931
import com.netflix.conductor.proto.DynamicForkJoinTaskPb;
3032
import com.netflix.conductor.proto.EventExecutionPb;
@@ -61,6 +63,22 @@
6163

6264
@Generated("com.netflix.conductor.annotationsprocessor.protogen")
6365
public abstract class AbstractProtoMapper {
66+
public CacheConfigPb.CacheConfig toProto(CacheConfig from) {
67+
CacheConfigPb.CacheConfig.Builder to = CacheConfigPb.CacheConfig.newBuilder();
68+
if (from.getKey() != null) {
69+
to.setKey( from.getKey() );
70+
}
71+
to.setTtlInSecond( from.getTtlInSecond() );
72+
return to.build();
73+
}
74+
75+
public CacheConfig fromProto(CacheConfigPb.CacheConfig from) {
76+
CacheConfig to = new CacheConfig();
77+
to.setKey( from.getKey() );
78+
to.setTtlInSecond( from.getTtlInSecond() );
79+
return to;
80+
}
81+
6482
public DynamicForkJoinTaskPb.DynamicForkJoinTask toProto(DynamicForkJoinTask from) {
6583
DynamicForkJoinTaskPb.DynamicForkJoinTask.Builder to = DynamicForkJoinTaskPb.DynamicForkJoinTask.newBuilder();
6684
if (from.getTaskName() != null) {
@@ -1342,6 +1360,9 @@ public WorkflowDefPb.WorkflowDef toProto(WorkflowDef from) {
13421360
for (Map.Entry<String, Object> pair : from.getMetadata().entrySet()) {
13431361
to.putMetadata( pair.getKey(), toProto( pair.getValue() ) );
13441362
}
1363+
if (from.getCacheConfig() != null) {
1364+
to.setCacheConfig( toProto( from.getCacheConfig() ) );
1365+
}
13451366
return to.build();
13461367
}
13471368

@@ -1390,6 +1411,9 @@ public WorkflowDef fromProto(WorkflowDefPb.WorkflowDef from) {
13901411
metadataMap.put( pair.getKey(), fromProto( pair.getValue() ) );
13911412
}
13921413
to.setMetadata(metadataMap);
1414+
if (from.hasCacheConfig()) {
1415+
to.setCacheConfig( fromProto( from.getCacheConfig() ) );
1416+
}
13931417
return to;
13941418
}
13951419

@@ -1651,22 +1675,6 @@ public WorkflowTask fromProto(WorkflowTaskPb.WorkflowTask from) {
16511675
return to;
16521676
}
16531677

1654-
public WorkflowTaskPb.WorkflowTask.CacheConfig toProto(WorkflowTask.CacheConfig from) {
1655-
WorkflowTaskPb.WorkflowTask.CacheConfig.Builder to = WorkflowTaskPb.WorkflowTask.CacheConfig.newBuilder();
1656-
if (from.getKey() != null) {
1657-
to.setKey( from.getKey() );
1658-
}
1659-
to.setTtlInSecond( from.getTtlInSecond() );
1660-
return to.build();
1661-
}
1662-
1663-
public WorkflowTask.CacheConfig fromProto(WorkflowTaskPb.WorkflowTask.CacheConfig from) {
1664-
WorkflowTask.CacheConfig to = new WorkflowTask.CacheConfig();
1665-
to.setKey( from.getKey() );
1666-
to.setTtlInSecond( from.getTtlInSecond() );
1667-
return to;
1668-
}
1669-
16701678
public abstract WorkflowTaskPb.WorkflowTask.WorkflowTaskList toProto(List<WorkflowTask> in);
16711679

16721680
public abstract List<WorkflowTask> fromProto(WorkflowTaskPb.WorkflowTask.WorkflowTaskList in);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
syntax = "proto3";
2+
package conductor.proto;
3+
4+
5+
option java_package = "com.netflix.conductor.proto";
6+
option java_outer_classname = "CacheConfigPb";
7+
option go_package = "github.com/netflix/conductor/client/gogrpc/conductor/model";
8+
9+
message CacheConfig {
10+
string key = 1;
11+
int32 ttl_in_second = 2;
12+
}

grpc/src/main/proto/model/workflowdef.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import "model/ratelimitconfig.proto";
55
import "model/workflowtask.proto";
66
import "google/protobuf/struct.proto";
77
import "model/schemadef.proto";
8+
import "model/cacheconfig.proto";
89

910
option java_package = "com.netflix.conductor.proto";
1011
option java_outer_classname = "WorkflowDefPb";
@@ -36,4 +37,5 @@ message WorkflowDef {
3637
SchemaDef output_schema = 20;
3738
bool enforce_schema = 21;
3839
map<string, google.protobuf.Value> metadata = 22;
40+
CacheConfig cache_config = 23;
3941
}

grpc/src/main/proto/model/workflowtask.proto

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ package conductor.proto;
44
import "model/taskdef.proto";
55
import "model/subworkflowparams.proto";
66
import "google/protobuf/struct.proto";
7+
import "model/cacheconfig.proto";
78

89
option java_package = "com.netflix.conductor.proto";
910
option java_outer_classname = "WorkflowTaskPb";
1011
option go_package = "github.com/netflix/conductor/client/gogrpc/conductor/model";
1112

1213
message WorkflowTask {
13-
message CacheConfig {
14-
string key = 1;
15-
int32 ttl_in_second = 2;
16-
}
1714
message WorkflowTaskList {
1815
repeated WorkflowTask tasks = 1;
1916
}
@@ -46,6 +43,6 @@ message WorkflowTask {
4643
string evaluator_type = 27;
4744
string expression = 28;
4845
string join_status = 30;
49-
WorkflowTask.CacheConfig cache_config = 31;
46+
CacheConfig cache_config = 31;
5047
bool permissive = 32;
5148
}

0 commit comments

Comments
 (0)