Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions temporal-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ tasks.named('check') {
// Use -PnexgenBinary=/path/to/nexgen to test an unreleased generator.
def nexusGeneratedDir = layout.buildDirectory.dir('generated/nexus/workflow').get().asFile
def nexusCheckedInDir = file('src/main/generated/io/temporal/workflow')
def nexgenVersion = '0.2.12'
def nexgenVersion = '0.2.14'
tasks.register('generateNexusSystemApi', Exec) {
dependsOn ':temporal-serviceclient:generateProto'
def binary = providers.gradleProperty('nexgenBinary').orElse('nexgen')
Expand All @@ -365,7 +365,8 @@ tasks.register('generateNexusSystemApi', Exec) {
invocation.commandLine(binary.get(), '--version')
invocation.standardOutput = versionOutput
}
if (versionOutput.toString('UTF-8').trim() != "nexgen ${nexgenVersion}") {
if (!providers.gradleProperty('nexgenBinary').isPresent()
&& versionOutput.toString('UTF-8').trim() != "nexgen ${nexgenVersion}") {
throw new GradleException("System Nexus regeneration requires nexgen ${nexgenVersion} with the advanced feature.")
}
delete nexusGeneratedDir
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated by nexgen v0.2.12. DO NOT EDIT!
// Generated by nexgen v0.2.14. DO NOT EDIT!
package io.temporal.workflow;

/** Options for the {@code signalWithStartWorkflow} operation. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated by nexgen v0.2.12. DO NOT EDIT!
// Generated by nexgen v0.2.14. DO NOT EDIT!
package io.temporal.workflow;

/** Request fields for signaling a workflow, starting it first if needed. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated by nexgen v0.2.12. DO NOT EDIT!
// Generated by nexgen v0.2.14. DO NOT EDIT!
package io.temporal.workflow;

/** Result of signaling a workflow and starting it if needed. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated by nexgen v0.2.12. DO NOT EDIT!
// Generated by nexgen v0.2.14. DO NOT EDIT!
package io.temporal.workflow;

/** Generated typed system Nexus hooks, separate from ordinary Nexus interception. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated by nexgen v0.2.12. DO NOT EDIT!
// Generated by nexgen v0.2.14. DO NOT EDIT!
package io.temporal.workflow;

/** Static metadata for a workflow execution. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated by nexgen v0.2.12. DO NOT EDIT!
// Generated by nexgen v0.2.14. DO NOT EDIT!
package io.temporal.workflow;

@io.temporal.common.Experimental
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated by nexgen v0.2.12. DO NOT EDIT!
// Generated by nexgen v0.2.14. DO NOT EDIT!
package io.temporal.workflow.internal;

/** Generated operation dispatch and serialization context acquisition. */
Expand Down Expand Up @@ -37,4 +37,14 @@ public static io.temporal.payload.context.SerializationContext serializationCont
(io.temporal.workflow.SignalWithStartWorkflowRequest) request);
return null;
}

public static io.temporal.payload.storage.StorageDriverTargetInfo storageTarget(
String service, String operation, Object request) {
if ("temporal.api.workflowservice.v1.WorkflowService".equals(service)
&& "SignalWithStartWorkflowExecution".equals(operation))
return io.temporal.internal.nexus.system.TemporalModelConverters
.signalWithStartWorkflowStorageTarget(
(io.temporal.api.workflowservice.v1.SignalWithStartWorkflowExecutionRequest) request);
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated by nexgen v0.2.12. DO NOT EDIT!
// Generated by nexgen v0.2.14. DO NOT EDIT!
package io.temporal.workflow.internal;

@io.temporal.common.Experimental
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ public static WorkflowSerializationContext signalWithStartWorkflowSerializationC
return new WorkflowSerializationContext(request.getNamespace(), request.getWorkflowId());
}

/** Identifies the destination without decoding embedded workflow arguments. */
public static io.temporal.payload.storage.StorageDriverWorkflowInfo
signalWithStartWorkflowStorageTarget(
io.temporal.api.workflowservice.v1.SignalWithStartWorkflowExecutionRequest request) {
return new io.temporal.payload.storage.StorageDriverWorkflowInfo(
request.getNamespace(), request.getWorkflowId(), null, request.getWorkflowType().getName());
}

public static RuntimeException failureFromProto(
DataConverter converter, io.temporal.api.failure.v1.Failure value) {
return converter.failureToException(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,22 @@ static StorageDriverTargetInfo deriveStorageTarget(
return current;
case COMPLETE_WORKFLOW_EXECUTION_COMMAND_ATTRIBUTES:
return completionTarget != null ? completionTarget : current;
case SCHEDULE_NEXUS_OPERATION_COMMAND_ATTRIBUTES:
io.temporal.api.command.v1.ScheduleNexusOperationCommandAttributes nexus =
command.getScheduleNexusOperationCommandAttributes();
if (io.temporal.internal.nexus.system.SystemNexusDataConverter.ENDPOINT.equals(
nexus.getEndpoint())
&& io.temporal.internal.payload.visitor.SystemNexusPayloads.isSystemPayload(
nexus.getInput())) {
StorageDriverTargetInfo target =
io.temporal.workflow.internal.SystemNexusOperations.storageTarget(
nexus.getService(),
nexus.getOperation(),
io.temporal.internal.payload.visitor.SystemNexusPayloads.unpack(nexus.getInput())
.build());
if (target != null) return target;
}
return current;
case SCHEDULE_ACTIVITY_TASK_COMMAND_ATTRIBUTES:
case ATTRIBUTES_NOT_SET:
case START_TIMER_COMMAND_ATTRIBUTES:
Expand All @@ -591,7 +607,6 @@ static StorageDriverTargetInfo deriveStorageTarget(
case UPSERT_WORKFLOW_SEARCH_ATTRIBUTES_COMMAND_ATTRIBUTES:
case PROTOCOL_MESSAGE_COMMAND_ATTRIBUTES:
case MODIFY_WORKFLOW_PROPERTIES_COMMAND_ATTRIBUTES:
case SCHEDULE_NEXUS_OPERATION_COMMAND_ATTRIBUTES:
case REQUEST_CANCEL_NEXUS_OPERATION_COMMAND_ATTRIBUTES:
return current;
}
Expand Down
8 changes: 7 additions & 1 deletion temporal-sdk/src/main/nexus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ eventually consume these definitions from the API repo instead. Protobuf
descriptors from
`temporal-serviceclient:generateProto` validate the mappings during generation.

Regenerate with nexgen 0.2.12 from temporalio/nexgen#245, built with its
Regenerate with nexgen from temporalio/nexgen#245 (currently 0.2.14), built with its
`advanced` feature, and `google-java-format` 1.24.0 on `PATH`:

```sh
Expand Down Expand Up @@ -66,5 +66,11 @@ Normal Java SDK builds do not require Rust or nex-gen.
The SDK wraps any configured `DataConverter` in `SystemNexusDataConverter` for
system operations. That wrapper handles the outer envelope and delegates nested
user conversion; custom converters do not need to recognize system envelopes.

The generated operation registry also exposes destination storage-target hooks.
The worker unpacks the system request envelope and obtains its workflow identity
before visiting nested payloads. Storage hooks receive the protobuf request, so
routing never invokes argument decoders or user codecs. The storing namespace
remains separate from the destination namespace.
The shared payload visitor descends into marked envelopes for payload traversal.
`CodecDataConverter` contains no system Nexus handling.
4 changes: 3 additions & 1 deletion temporal-sdk/src/main/nexus/SIGNAL_WITH_START.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ arguments, including a null, into one payload. The receiving workflow decodes
them using its declared argument types and arity. The
storage cases verify nested references in history, inline system envelopes,
retrieval during workflow execution, and destination codec metadata after
retrieval. Replaying both caller and target histories also exercises retrieval
retrieval. They also assert that storage selectors receive the destination
namespace, workflow ID, and workflow type, with no run ID, rather than the caller.
Replaying both caller and target histories also exercises retrieval
of stored workflow and signal inputs. Converter unit tests cover valid and
unknown versioning override shapes; unknown shapes are rejected.

Expand Down
1 change: 1 addition & 0 deletions temporal-sdk/src/main/nexus/workflow-service.wit
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ interface workflow-service {
/// @nexus.operation name="SignalWithStartWorkflowExecution"
/// @nexus.serialization-context java="signalWithStartWorkflowSerializationContext" python="signal_with_start_workflow_serialization_context" typescript="signalWithStartWorkflowSerializationContext" dotnet="WorkflowServiceSerializationContexts.SignalWithStartWorkflow" go="SignalWithStartWorkflowSerializationContext"
/// @nexus.context-propagation go="request.headers" java="request.headers"
/// @nexus.storage-target java="signalWithStartWorkflowStorageTarget"
/// @nexus.experimental
signal-with-start-workflow: func(
request: signal-with-start-workflow-request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.temporal.payload.context.SerializationContext;
import io.temporal.payload.context.WorkflowSerializationContext;
import io.temporal.payload.storage.ExternalStorage;
import io.temporal.payload.storage.StorageDriverWorkflowInfo;
import io.temporal.testing.CloudTestExclusion.RequiresCloudProvisioning;
import io.temporal.testing.CloudTestExclusionNote;
import io.temporal.testing.WorkflowReplayer;
Expand Down Expand Up @@ -60,8 +61,30 @@ public static Object[][] storageAndCodecModes() {
private final boolean externalStorageEnabled;
private final boolean batchCodecEnabled;
private final TestStorageDriver storageDriver = TestStorageDriver.named("signal-with-start");
private final Map<String, StorageDriverWorkflowInfo> routedTargets =
new java.util.concurrent.ConcurrentHashMap<>();
private final ExternalStorage storage =
ExternalStorage.newBuilder().setDriver(storageDriver).setPayloadSizeThreshold(0).build();
ExternalStorage.newBuilder()
.setDriver(storageDriver)
.setDriverSelector(
(context, payload) -> {
if (context.getTarget() instanceof StorageDriverWorkflowInfo) {
StorageDriverWorkflowInfo target =
(StorageDriverWorkflowInfo) context.getTarget();
if ("SystemSignalTarget".equals(target.getType()) && target.getRunId() == null) {
assertEquals(context.getNamespace(), target.getNamespace());
if (payload.containsMetadata(DestinationCodec.KEY)) {
assertEquals(
target.getNamespace() + "/" + target.getId(),
payload.getMetadataOrThrow(DestinationCodec.KEY).toStringUtf8());
}
routedTargets.put(target.getId(), target);
}
}
return storageDriver;
})
.setPayloadSizeThreshold(0)
.build();

@Rule public final SDKTestWorkflowRule rule;

Expand Down Expand Up @@ -164,6 +187,7 @@ public void startsThenSignalsTheExistingExecutionAndReplays() throws Exception {
"start:first:second",
rule.getWorkflowClient().newUntypedWorkflowStub(target).getResult(String.class));
assertStorageUsed();
if (externalStorageEnabled) assertTrue(routedTargets.containsKey(target));
String callerId =
io.temporal.client.WorkflowStub.fromTyped(caller).getExecution().getWorkflowId();
WorkflowReplayer.replayWorkflowExecution(rule.getExecutionHistory(callerId), rule.getWorker());
Expand All @@ -175,6 +199,7 @@ public void concurrentCallsUseDestinationCodecContextAndPreserveOuterEnvelopes()
throws Exception {
ConcurrentCaller caller = rule.newWorkflowStubTimeoutOptions(ConcurrentCaller.class);
List<String> targets = caller.run();
if (externalStorageEnabled) assertTrue(routedTargets.keySet().containsAll(targets));
for (String target : targets) {
assertEquals(
"start:first:second",
Expand Down
Loading