Skip to content

Commit ba1c0ce

Browse files
authored
Exposed startedEventAttribute and DataConverter (#799)
* exposing startedEventAttributes through DecisionContext in WorkflowInfo for using in ContinueAsNew * addition of workflowEventAttributes in dummy implementation * Addition of dataConverter
1 parent c495e7b commit ba1c0ce

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed

src/main/java/com/uber/cadence/internal/replay/DecisionContext.java

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import com.uber.cadence.SearchAttributes;
2121
import com.uber.cadence.WorkflowExecution;
22+
import com.uber.cadence.WorkflowExecutionStartedEventAttributes;
2223
import com.uber.cadence.WorkflowType;
2324
import com.uber.cadence.context.ContextPropagator;
2425
import com.uber.cadence.converter.DataConverter;
@@ -79,6 +80,9 @@ public interface DecisionContext extends ReplayAware {
7980
*/
8081
SearchAttributes getSearchAttributes();
8182

83+
/** Returns DataConverter that serializes data */
84+
DataConverter getDataConverter();
85+
8286
/**
8387
* Returns all of the current contexts being propagated by a {@link
8488
* com.uber.cadence.context.ContextPropagator}. The key is the {@link ContextPropagator#getName()}
@@ -89,6 +93,9 @@ public interface DecisionContext extends ReplayAware {
8993
/** Returns the set of configured context propagators */
9094
List<ContextPropagator> getContextPropagators();
9195

96+
/** Returns the startedEventWorkflow attributes */
97+
WorkflowExecutionStartedEventAttributes getWorkflowExecutionStartedEventAttributes();
98+
9299
/**
93100
* Used to dynamically schedule an activity for execution
94101
*

src/main/java/com/uber/cadence/internal/replay/DecisionContextImpl.java

+14
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ final class DecisionContextImpl implements DecisionContext, HistoryEventHandler
6060
private final WorkflowContext workflowContext;
6161
private final Scope metricsScope;
6262
private final boolean enableLoggingInReplay;
63+
private final WorkflowExecutionStartedEventAttributes startedEventAttributes;
64+
private final DataConverter dataConverter;
6365

6466
DecisionContextImpl(
6567
DecisionsHelper decisionsHelper,
@@ -77,6 +79,8 @@ final class DecisionContextImpl implements DecisionContext, HistoryEventHandler
7779
this.workflowClock =
7880
new ClockDecisionContext(
7981
decisionsHelper, laTaskPoller, replayDecider, options.getDataConverter());
82+
this.startedEventAttributes = startedAttributes;
83+
this.dataConverter = options.getDataConverter();
8084
this.enableLoggingInReplay = options.getEnableLoggingInReplay();
8185
this.metricsScope =
8286
new ReplayAwareScope(options.getMetricsScope(), this, workflowClock::currentTimeMillis);
@@ -182,6 +186,16 @@ public List<ContextPropagator> getContextPropagators() {
182186
return workflowContext.getContextPropagators();
183187
}
184188

189+
@Override
190+
public WorkflowExecutionStartedEventAttributes getWorkflowExecutionStartedEventAttributes() {
191+
return startedEventAttributes;
192+
}
193+
194+
@Override
195+
public DataConverter getDataConverter() {
196+
return dataConverter;
197+
}
198+
185199
@Override
186200
public Map<String, Object> getPropagatedContexts() {
187201
return workflowContext.getPropagatedContexts();

src/main/java/com/uber/cadence/internal/sync/DeterministicRunnerImpl.java

+11
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import com.uber.cadence.SearchAttributes;
2121
import com.uber.cadence.WorkflowExecution;
22+
import com.uber.cadence.WorkflowExecutionStartedEventAttributes;
2223
import com.uber.cadence.WorkflowType;
2324
import com.uber.cadence.context.ContextPropagator;
2425
import com.uber.cadence.converter.DataConverter;
@@ -596,6 +597,11 @@ public SearchAttributes getSearchAttributes() {
596597
throw new UnsupportedOperationException("not implemented");
597598
}
598599

600+
@Override
601+
public DataConverter getDataConverter() {
602+
return null;
603+
}
604+
599605
@Override
600606
public Map<String, Object> getPropagatedContexts() {
601607
return null;
@@ -606,6 +612,11 @@ public List<ContextPropagator> getContextPropagators() {
606612
return null;
607613
}
608614

615+
@Override
616+
public WorkflowExecutionStartedEventAttributes getWorkflowExecutionStartedEventAttributes() {
617+
return null;
618+
}
619+
609620
@Override
610621
public Consumer<Exception> scheduleActivityTask(
611622
ExecuteActivityParameters parameters, BiConsumer<byte[], Exception> callback) {

src/main/java/com/uber/cadence/internal/sync/WorkflowInfoImpl.java

+12
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
import com.uber.cadence.SearchAttributes;
2121
import com.uber.cadence.WorkflowExecution;
22+
import com.uber.cadence.WorkflowExecutionStartedEventAttributes;
23+
import com.uber.cadence.converter.DataConverter;
2224
import com.uber.cadence.internal.replay.DecisionContext;
2325
import com.uber.cadence.workflow.WorkflowInfo;
2426
import java.time.Duration;
@@ -77,4 +79,14 @@ public String getParentRunId() {
7779
WorkflowExecution parentWorkflowExecution = context.getParentWorkflowExecution();
7880
return parentWorkflowExecution == null ? null : parentWorkflowExecution.getRunId();
7981
}
82+
83+
@Override
84+
public WorkflowExecutionStartedEventAttributes getWorkflowExecutionStartedEventAttributes() {
85+
return context.getWorkflowExecutionStartedEventAttributes();
86+
}
87+
88+
@Override
89+
public DataConverter getDataConverter() {
90+
return context.getDataConverter();
91+
}
8092
}

src/main/java/com/uber/cadence/workflow/WorkflowInfo.java

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
package com.uber.cadence.workflow;
1919

2020
import com.uber.cadence.SearchAttributes;
21+
import com.uber.cadence.WorkflowExecutionStartedEventAttributes;
22+
import com.uber.cadence.converter.DataConverter;
2123
import java.time.Duration;
2224

2325
public interface WorkflowInfo {
@@ -39,4 +41,8 @@ public interface WorkflowInfo {
3941
String getParentWorkflowId();
4042

4143
String getParentRunId();
44+
45+
WorkflowExecutionStartedEventAttributes getWorkflowExecutionStartedEventAttributes();
46+
47+
DataConverter getDataConverter();
4248
}

0 commit comments

Comments
 (0)