Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7bf3c1a

Browse files
Merge branch 'master' into issue-1587
2 parents e0a8cc3 + 0b88507 commit 7bf3c1a

36 files changed

+473
-57
lines changed

AGENTS.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Contributor Quickstart Guide
2+
3+
## Repository Layout
4+
- `temporal-sdk`: core SDK implementation.
5+
- `temporal-testing`: utilities to help write workflow and activity tests.
6+
- `temporal-test-server`: in-memory Temporal server for fast tests.
7+
- `temporal-serviceclient`: gRPC client for communicating with the service.
8+
- `temporal-shaded`: prepackaged version of the SDK with shaded dependencies.
9+
- `temporal-spring-boot-autoconfigure`: Spring Boot auto configuration.
10+
- `temporal-kotlin`: Kotlin DSL for the SDK.
11+
- `temporal-opentracing`: OpenTracing interceptor integration.
12+
13+
## General Guidance
14+
- Avoid changing public API signatures. Anything under an `internal` directory
15+
is not part of the public API and may change freely.
16+
- The SDK code is written for Java 8.
17+
18+
## Building and Testing
19+
1. Format the code before committing:
20+
```bash
21+
./gradlew --offline spotlessApply
22+
```
23+
2. Run the tests. This can take a long time so you may prefer to run individual tests.
24+
```bash
25+
./gradlew test
26+
```
27+
To run only the core SDK tests or a single test:
28+
```bash
29+
./gradlew :temporal-sdk:test --offline --tests "io.temporal.workflow.*"
30+
./gradlew :temporal-sdk:test --offline --tests "<package.ClassName>"
31+
```
32+
3. Build the project:
33+
```bash
34+
./gradlew clean build
35+
```
36+
37+
## Tests
38+
- All tests for this each package is located in `$PACKAGE_NAME/src/test/java/io/temporal`, where `$PACKAGE_NAME` is the name of the package
39+
- Workflow API tests should rely on `SDKTestWorkflowRule` to create a worker and
40+
register workflows, activities, and nexus services.
41+
42+
## Commit Messages and Pull Requests
43+
- Follow the [Chris Beams](http://chris.beams.io/posts/git-commit/) style for
44+
commit messages.
45+
- Every pull request should answer:
46+
- **What changed?**
47+
- **Why?**
48+
- **Breaking changes?**
49+
- **Server PR** (if the change requires a coordinated server update)
50+
- Comments should be complete sentences and end with a period.
51+
52+
## Review Checklist
53+
- `./gradlew spotlessCheck` must pass.
54+
- All tests from `./gradlew test` must succeed.
55+
- Add new tests for any new feature or bug fix.
56+
- Update documentation for user facing changes.
57+
58+
For more details see `CONTRIBUTING.md` in the repository root.

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ext {
4343
// We don't move past 3.25.x because the next version is a major version bump and we don't want to break our users.
4444
//
4545
// For more information see: https://github.com/grpc/grpc-java/issues/11015#issuecomment-2560196695
46-
protoVersion = '3.25.5'
46+
protoVersion = '3.25.7'
4747
annotationApiVersion = '1.3.2'
4848
guavaVersion = '32.0.1-jre' // [10.0,)
4949
tallyVersion = '0.13.0' // [0.4.0,)
@@ -65,7 +65,7 @@ ext {
6565
junitVersion = '4.13.2'
6666
// Edge Dependencies are used by tests to validate the SDK with the latest version of various libraries.
6767
// Not just the version of the library the SDK is built against.
68-
protoVersionEdge = '4.30.2'
68+
protoVersionEdge = '4.31.0'
6969
grpcVersionEdge = '1.72.0'
7070
}
7171

temporal-kotlin/AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Unlike the rest of this repository, this directory is for the Kotlin SDK so most of the code here is written in Kotlin, not Java.

temporal-sdk/AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
This directory contains the core Temporal SDK code, which is used to build Temporal applications. The SDK provides a set of APIs and libraries that allow developers to create, manage, and execute workflows and activities in a distributed environment. The SDK is designed to be easy to use and provides a high-level abstraction over the underlying Temporal service.
2+
3+
The SDK is written in Java and is designed to be used with the Temporal service. It provides a set of APIs for defining workflows and activities, as well as for managing the execution of those workflows and activities.
4+
5+
# Testing
6+
7+
All tests are written using JUnit4.

temporal-sdk/src/main/java/io/temporal/client/WorkflowOptions.java

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public static WorkflowOptions merge(
6666
.setLinks(o.getLinks())
6767
.setOnConflictOptions(o.getOnConflictOptions())
6868
.setPriority(o.getPriority())
69+
.setVersioningOverride(o.getVersioningOverride())
6970
.validateBuildWithDefaults();
7071
}
7172

@@ -115,6 +116,8 @@ public static final class Builder {
115116

116117
private Priority priority;
117118

119+
private VersioningOverride versioningOverride;
120+
118121
private Builder() {}
119122

120123
private Builder(WorkflowOptions options) {
@@ -143,6 +146,7 @@ private Builder(WorkflowOptions options) {
143146
this.links = options.links;
144147
this.onConflictOptions = options.onConflictOptions;
145148
this.priority = options.priority;
149+
this.versioningOverride = options.versioningOverride;
146150
}
147151

148152
/**
@@ -472,6 +476,13 @@ public Builder setPriority(Priority priority) {
472476
return this;
473477
}
474478

479+
/** Sets the versioning override to use when starting this workflow. */
480+
@Experimental
481+
public Builder setVersioningOverride(VersioningOverride versioningOverride) {
482+
this.versioningOverride = versioningOverride;
483+
return this;
484+
}
485+
475486
public WorkflowOptions build() {
476487
return new WorkflowOptions(
477488
workflowId,
@@ -495,7 +506,8 @@ public WorkflowOptions build() {
495506
completionCallbacks,
496507
links,
497508
onConflictOptions,
498-
priority);
509+
priority,
510+
versioningOverride);
499511
}
500512

501513
/**
@@ -524,7 +536,8 @@ public WorkflowOptions validateBuildWithDefaults() {
524536
completionCallbacks,
525537
links,
526538
onConflictOptions,
527-
priority);
539+
priority,
540+
versioningOverride);
528541
}
529542
}
530543

@@ -569,6 +582,7 @@ public WorkflowOptions validateBuildWithDefaults() {
569582
private final List<Link> links;
570583
private final OnConflictOptions onConflictOptions;
571584
private final Priority priority;
585+
private final VersioningOverride versioningOverride;
572586

573587
private WorkflowOptions(
574588
String workflowId,
@@ -592,7 +606,8 @@ private WorkflowOptions(
592606
List<Callback> completionCallbacks,
593607
List<Link> links,
594608
OnConflictOptions onConflictOptions,
595-
Priority priority) {
609+
Priority priority,
610+
VersioningOverride versioningOverride) {
596611
this.workflowId = workflowId;
597612
this.workflowIdReusePolicy = workflowIdReusePolicy;
598613
this.workflowRunTimeout = workflowRunTimeout;
@@ -615,6 +630,7 @@ private WorkflowOptions(
615630
this.links = links;
616631
this.onConflictOptions = onConflictOptions;
617632
this.priority = priority;
633+
this.versioningOverride = versioningOverride;
618634
}
619635

620636
public String getWorkflowId() {
@@ -721,6 +737,11 @@ public Priority getPriority() {
721737
return priority;
722738
}
723739

740+
@Experimental
741+
public VersioningOverride getVersioningOverride() {
742+
return versioningOverride;
743+
}
744+
724745
public Builder toBuilder() {
725746
return new Builder(this);
726747
}
@@ -751,7 +772,8 @@ public boolean equals(Object o) {
751772
&& Objects.equal(completionCallbacks, that.completionCallbacks)
752773
&& Objects.equal(links, that.links)
753774
&& Objects.equal(onConflictOptions, that.onConflictOptions)
754-
&& Objects.equal(priority, that.priority);
775+
&& Objects.equal(priority, that.priority)
776+
&& Objects.equal(versioningOverride, that.versioningOverride);
755777
}
756778

757779
@Override
@@ -778,7 +800,8 @@ public int hashCode() {
778800
completionCallbacks,
779801
links,
780802
onConflictOptions,
781-
priority);
803+
priority,
804+
versioningOverride);
782805
}
783806

784807
@Override
@@ -831,6 +854,8 @@ public String toString() {
831854
+ onConflictOptions
832855
+ ", priority="
833856
+ priority
857+
+ ", versioningOverride="
858+
+ versioningOverride
834859
+ '}';
835860
}
836861
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package io.temporal.common;
2+
3+
import javax.annotation.Nonnull;
4+
5+
/** Represents the override of a worker's versioning behavior for a workflow execution. */
6+
@Experimental
7+
public abstract class VersioningOverride {
8+
private VersioningOverride() {}
9+
10+
/** Workflow will be pinned to a specific deployment version. */
11+
public static final class PinnedVersioningOverride extends VersioningOverride {
12+
private final WorkerDeploymentVersion version;
13+
14+
/**
15+
* Creates a new PinnedVersioningOverride.
16+
*
17+
* @param version The worker deployment version to pin the workflow to.
18+
*/
19+
public PinnedVersioningOverride(@Nonnull WorkerDeploymentVersion version) {
20+
this.version = version;
21+
}
22+
23+
/**
24+
* @return The worker deployment version to pin the workflow to.
25+
*/
26+
public WorkerDeploymentVersion getVersion() {
27+
return version;
28+
}
29+
}
30+
31+
/** The workflow will auto-upgrade to the current deployment version on the next workflow task. */
32+
public static final class AutoUpgradeVersioningOverride extends VersioningOverride {
33+
public AutoUpgradeVersioningOverride() {}
34+
}
35+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
All files in this directory and subdirectory are intended to be internal to the SDK and should not be used by external users. They do not have the same backwards compatibility guarantees as our other APIS

temporal-sdk/src/main/java/io/temporal/internal/activity/ActivityExecutionContextImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ public Object getLastHeartbeatValue() {
167167
return heartbeatContext.getLatestHeartbeatDetails();
168168
}
169169

170+
@Override
171+
public void cancelOutstandingHeartbeat() {
172+
heartbeatContext.cancelOutstandingHeartbeat();
173+
}
174+
170175
@Override
171176
public WorkflowClient getWorkflowClient() {
172177
return client;

temporal-sdk/src/main/java/io/temporal/internal/activity/ActivityInfoImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import io.temporal.api.common.v1.Payloads;
66
import io.temporal.api.workflowservice.v1.PollActivityTaskQueueResponseOrBuilder;
77
import io.temporal.common.Priority;
8-
import io.temporal.internal.common.PriorityUtils;
8+
import io.temporal.internal.common.ProtoConverters;
99
import io.temporal.internal.common.ProtobufTimeUtils;
1010
import io.temporal.workflow.Functions;
1111
import java.time.Duration;
@@ -138,7 +138,7 @@ public boolean isLocal() {
138138

139139
@Override
140140
public Priority getPriority() {
141-
return PriorityUtils.fromProto(response.getPriority());
141+
return ProtoConverters.fromProto(response.getPriority());
142142
}
143143

144144
@Override

temporal-sdk/src/main/java/io/temporal/internal/activity/ActivityTaskExecutors.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ public ActivityTaskHandler.Result execute(ActivityInfoInternal info, Scope metri
128128
metricsScope,
129129
local,
130130
dataConverterWithActivityContext);
131+
} finally {
132+
if (!context.isDoNotCompleteOnReturn()) {
133+
// if the activity is not completed, we need to cancel the heartbeat
134+
// to avoid sending it after the activity is completed
135+
context.cancelOutstandingHeartbeat();
136+
}
131137
}
132138
}
133139

0 commit comments

Comments
 (0)