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

temporalio / sdk-java / #283

19 Jul 2024 12:46PM CUT coverage: 77.364% (-0.2%) from 77.584%
#283

push

github

web-flow
Experimental cloud operations client (#2146)

Fixes #2059

7 of 80 new or added lines in 6 files covered. (8.75%)

19102 of 24691 relevant lines covered (77.36%)

0.77 hits per line

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

0.0
/temporal-serviceclient/src/main/java/io/temporal/serviceclient/CloudServiceStubsImpl.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.serviceclient;
22

23
import io.grpc.ClientInterceptor;
24
import io.grpc.ManagedChannel;
25
import io.grpc.health.v1.HealthCheckResponse;
26
import io.temporal.api.cloud.cloudservice.v1.CloudServiceGrpc;
27
import io.temporal.api.workflowservice.v1.GetSystemInfoResponse;
28
import java.time.Duration;
29
import java.util.Collections;
30
import java.util.concurrent.TimeUnit;
31
import java.util.function.Supplier;
32
import javax.annotation.Nullable;
33
import org.slf4j.Logger;
34
import org.slf4j.LoggerFactory;
35

36
final class CloudServiceStubsImpl implements CloudServiceStubs {
NEW
37
  private static final Logger log = LoggerFactory.getLogger(CloudServiceStubsImpl.class);
×
38

39
  private final ChannelManager channelManager;
40

41
  private final CloudServiceGrpc.CloudServiceBlockingStub blockingStub;
42
  private final CloudServiceGrpc.CloudServiceFutureStub futureStub;
43

44
  /**
45
   * Creates gRPC Channel and Stubs that connects to the {@link CloudServiceGrpc} according to the
46
   * specified options.
47
   */
NEW
48
  CloudServiceStubsImpl(CloudServiceStubsOptions options) {
×
NEW
49
    ClientInterceptor deadlineInterceptor =
×
NEW
50
        new GrpcDeadlineInterceptor(options.getRpcTimeout(), null, null);
×
51

NEW
52
    options = CloudServiceStubsOptions.newBuilder(options).validateAndBuildWithDefaults();
×
53

NEW
54
    this.channelManager =
×
55
        new ChannelManager(
56
            options,
NEW
57
            Collections.singletonList(deadlineInterceptor),
×
NEW
58
            GetSystemInfoResponse.Capabilities.newBuilder()
×
NEW
59
                .setInternalErrorDifferentiation(true)
×
NEW
60
                .build());
×
61

NEW
62
    log.info("Created CloudServiceStubs for channel: {}", channelManager.getRawChannel());
×
63

NEW
64
    this.blockingStub = CloudServiceGrpc.newBlockingStub(channelManager.getInterceptedChannel());
×
NEW
65
    this.futureStub = CloudServiceGrpc.newFutureStub(channelManager.getInterceptedChannel());
×
NEW
66
  }
×
67

68
  @Override
69
  public ManagedChannel getRawChannel() {
NEW
70
    return channelManager.getRawChannel();
×
71
  }
72

73
  @Override
74
  public CloudServiceGrpc.CloudServiceBlockingStub blockingStub() {
NEW
75
    return blockingStub;
×
76
  }
77

78
  @Override
79
  public CloudServiceGrpc.CloudServiceFutureStub futureStub() {
NEW
80
    return futureStub;
×
81
  }
82

83
  @Override
84
  public void shutdown() {
NEW
85
    log.info("shutdown");
×
NEW
86
    channelManager.shutdown();
×
NEW
87
  }
×
88

89
  @Override
90
  public void shutdownNow() {
NEW
91
    log.info("shutdownNow");
×
NEW
92
    channelManager.shutdownNow();
×
NEW
93
  }
×
94

95
  @Override
96
  public boolean isShutdown() {
NEW
97
    return channelManager.isShutdown();
×
98
  }
99

100
  @Override
101
  public boolean isTerminated() {
NEW
102
    return channelManager.isTerminated();
×
103
  }
104

105
  @Override
106
  public boolean awaitTermination(long timeout, TimeUnit unit) {
NEW
107
    return channelManager.awaitTermination(timeout, unit);
×
108
  }
109

110
  @Override
111
  public void connect(@Nullable Duration timeout) {
NEW
112
    channelManager.connect(HEALTH_CHECK_SERVICE_NAME, timeout);
×
NEW
113
  }
×
114

115
  @Override
116
  public HealthCheckResponse healthCheck() {
117
    // no need to pass timeout, timeout will be assigned by GrpcDeadlineInterceptor
NEW
118
    return this.channelManager.healthCheck(HEALTH_CHECK_SERVICE_NAME, null);
×
119
  }
120

121
  @Override
122
  public Supplier<GetSystemInfoResponse.Capabilities> getServerCapabilities() {
NEW
123
    return this.channelManager.getServerCapabilities();
×
124
  }
125
}
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

© 2025 Coveralls, Inc