• 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/CloudServiceStubsOptions.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.ManagedChannel;
24
import java.util.Objects;
25

26
/**
27
 * Options for cloud service.
28
 *
29
 * <p>WARNING: The cloud service is currently experimental.
30
 */
31
public final class CloudServiceStubsOptions extends ServiceStubsOptions {
32
  public static final String DEFAULT_CLOUD_TARGET = "saas-api.tmprl.cloud:443";
33

NEW
34
  private static final CloudServiceStubsOptions DEFAULT_INSTANCE =
×
NEW
35
      newBuilder().validateAndBuildWithDefaults();
×
36

37
  /** Version header if any. */
38
  private final String version;
39

40
  public static Builder newBuilder() {
NEW
41
    return new Builder();
×
42
  }
43

44
  public static Builder newBuilder(CloudServiceStubsOptions options) {
45
    // We intentionally only accept our options and not the base class of
46
    // options to ensure our defaults were originally applied at some point
47
    // when the options class was first created.
NEW
48
    return new Builder(options);
×
49
  }
50

51
  public static CloudServiceStubsOptions getDefaultInstance() {
NEW
52
    return DEFAULT_INSTANCE;
×
53
  }
54

55
  private CloudServiceStubsOptions(ServiceStubsOptions serviceStubsOptions, String version) {
NEW
56
    super(serviceStubsOptions);
×
NEW
57
    this.version = version;
×
NEW
58
  }
×
59

60
  /**
61
   * @return Returns the version used for the version header if any.
62
   */
63
  public String getVersion() {
NEW
64
    return version;
×
65
  }
66

67
  @Override
68
  public boolean equals(Object o) {
NEW
69
    if (this == o) return true;
×
NEW
70
    if (o == null || getClass() != o.getClass()) return false;
×
NEW
71
    if (!super.equals(o)) return false;
×
NEW
72
    CloudServiceStubsOptions that = (CloudServiceStubsOptions) o;
×
NEW
73
    return Objects.equals(version, that.version);
×
74
  }
75

76
  @Override
77
  public int hashCode() {
NEW
78
    return Objects.hash(super.hashCode(), version);
×
79
  }
80

81
  /** Builder is the builder for ClientOptions. */
82
  public static class Builder extends ServiceStubsOptions.Builder<Builder> {
83
    private String version;
84

NEW
85
    private Builder() {
×
86
      // Set defaults only in this constructor
NEW
87
      setTarget(DEFAULT_CLOUD_TARGET);
×
NEW
88
      setEnableHttps(true);
×
NEW
89
    }
×
90

91
    private Builder(CloudServiceStubsOptions options) {
NEW
92
      super(options);
×
NEW
93
      this.version = options.version;
×
NEW
94
    }
×
95

96
    /** Set a cloud operation service version. This sets the version header for each call. */
97
    public Builder setVersion(String version) {
NEW
98
      this.version = version;
×
NEW
99
      return this;
×
100
    }
101

102
    /** Default is {@link #DEFAULT_CLOUD_TARGET}. See inherited method for more details. */
103
    @Override
104
    public Builder setTarget(String target) {
NEW
105
      return super.setTarget(target);
×
106
    }
107

108
    @Override
109
    public Builder setChannel(ManagedChannel channel) {
110
      // Unset our defaults
NEW
111
      setEnableHttps(false);
×
NEW
112
      setTarget(null);
×
NEW
113
      return super.setChannel(channel);
×
114
    }
115

116
    /**
117
     * Builds and returns a ClientOptions object.
118
     *
119
     * @return ClientOptions object with the specified params.
120
     */
121
    public CloudServiceStubsOptions build() {
NEW
122
      return new CloudServiceStubsOptions(super.build(), this.version);
×
123
    }
124

125
    public CloudServiceStubsOptions validateAndBuildWithDefaults() {
NEW
126
      ServiceStubsOptions serviceStubsOptions = super.validateAndBuildWithDefaults();
×
NEW
127
      return new CloudServiceStubsOptions(serviceStubsOptions, this.version);
×
128
    }
129
  }
130
}
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