• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

temporalio / sdk-java / #157

pending completion
#157

push

github-actions

web-flow
Provide SerializationContext for PayloadConverter and PayloadCodec (#1695)

Issue #1694

497 of 497 new or added lines in 32 files covered. (100.0%)

16942 of 20806 relevant lines covered (81.43%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.86
/temporal-sdk/src/main/java/io/temporal/internal/client/ActivityClientHelper.java
1
/*
2
 * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved.
3
 *
4
 * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
 *
6
 * Modifications copyright (C) 2017 Uber Technologies, Inc.
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this material except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 *   http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20

21
package io.temporal.internal.client;
22

23
import static io.temporal.serviceclient.MetricsTag.METRICS_TAGS_CALL_OPTIONS_KEY;
24

25
import com.google.common.base.Preconditions;
26
import com.google.protobuf.ByteString;
27
import com.uber.m3.tally.Scope;
28
import io.temporal.activity.ManualActivityCompletionClient;
29
import io.temporal.api.common.v1.Payloads;
30
import io.temporal.api.common.v1.WorkflowExecution;
31
import io.temporal.api.workflowservice.v1.RecordActivityTaskHeartbeatByIdRequest;
32
import io.temporal.api.workflowservice.v1.RecordActivityTaskHeartbeatByIdResponse;
33
import io.temporal.api.workflowservice.v1.RecordActivityTaskHeartbeatRequest;
34
import io.temporal.api.workflowservice.v1.RecordActivityTaskHeartbeatResponse;
35
import io.temporal.serviceclient.WorkflowServiceStubs;
36
import java.util.Optional;
37
import javax.annotation.Nonnull;
38

39
/**
40
 * Contains methods that could but didn't become a part of the main {@link
41
 * ManualActivityCompletionClient}, because they are not intended to be called by our users
42
 * directly.
43
 */
44
public final class ActivityClientHelper {
45
  private ActivityClientHelper() {}
46

47
  public static RecordActivityTaskHeartbeatResponse sendHeartbeatRequest(
48
      WorkflowServiceStubs service,
49
      String namespace,
50
      String identity,
51
      byte[] taskToken,
52
      Optional<Payloads> payloads,
53
      Scope metricsScope) {
54
    RecordActivityTaskHeartbeatRequest.Builder request =
55
        RecordActivityTaskHeartbeatRequest.newBuilder()
1✔
56
            .setTaskToken(ByteString.copyFrom(taskToken))
1✔
57
            .setNamespace(namespace)
1✔
58
            .setIdentity(identity);
1✔
59
    payloads.ifPresent(request::setDetails);
1✔
60
    return service
1✔
61
        .blockingStub()
1✔
62
        .withOption(METRICS_TAGS_CALL_OPTIONS_KEY, metricsScope)
1✔
63
        .recordActivityTaskHeartbeat(request.build());
1✔
64
  }
65

66
  public static RecordActivityTaskHeartbeatByIdResponse recordActivityTaskHeartbeatById(
67
      WorkflowServiceStubs service,
68
      String namespace,
69
      String identity,
70
      WorkflowExecution execution,
71
      @Nonnull String activityId,
72
      Optional<Payloads> payloads,
73
      Scope metricsScope) {
74
    Preconditions.checkNotNull(activityId, "Either activity id or task token are required");
×
75
    RecordActivityTaskHeartbeatByIdRequest.Builder request =
76
        RecordActivityTaskHeartbeatByIdRequest.newBuilder()
×
77
            .setRunId(execution.getRunId())
×
78
            .setWorkflowId(execution.getWorkflowId())
×
79
            .setActivityId(activityId)
×
80
            .setNamespace(namespace)
×
81
            .setIdentity(identity);
×
82
    payloads.ifPresent(request::setDetails);
×
83
    return service
×
84
        .blockingStub()
×
85
        .withOption(METRICS_TAGS_CALL_OPTIONS_KEY, metricsScope)
×
86
        .recordActivityTaskHeartbeatById(request.build());
×
87
  }
88
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc