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

temporalio / sdk-java / #249

03 May 2024 04:51PM UTC coverage: 77.486% (+0.006%) from 77.48%
#249

push

github

web-flow
Add ScheduleClientInterceptor APIs (fixes #2048) (#2050)

Signed-off-by: Dan O'Reilly <oreilldf@gmail.com>

13 of 21 new or added lines in 3 files covered. (61.9%)

2 existing lines in 2 files now uncovered.

19143 of 24705 relevant lines covered (77.49%)

0.77 hits per line

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

52.17
/temporal-sdk/src/main/java/io/temporal/client/schedules/ScheduleClientOptions.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.client.schedules;
22

23
import io.temporal.common.context.ContextPropagator;
24
import io.temporal.common.converter.DataConverter;
25
import io.temporal.common.converter.GlobalDataConverter;
26
import io.temporal.common.interceptors.ScheduleClientInterceptor;
27
import java.lang.management.ManagementFactory;
28
import java.util.Collections;
29
import java.util.List;
30

31
/** Options for ScheduleClient configuration. */
32
public final class ScheduleClientOptions {
33

34
  public static ScheduleClientOptions.Builder newBuilder() {
35
    return new ScheduleClientOptions.Builder();
1✔
36
  }
37

38
  public static ScheduleClientOptions.Builder newBuilder(ScheduleClientOptions options) {
39
    return new ScheduleClientOptions.Builder(options);
×
40
  }
41

42
  public static ScheduleClientOptions getDefaultInstance() {
43
    return DEFAULT_INSTANCE;
1✔
44
  }
45

46
  public ScheduleClientOptions.Builder toBuilder() {
47
    return new ScheduleClientOptions.Builder(this);
×
48
  }
49

50
  private static final ScheduleClientOptions DEFAULT_INSTANCE;
51

52
  static {
53
    DEFAULT_INSTANCE = ScheduleClientOptions.newBuilder().build();
1✔
54
  }
1✔
55

56
  public static final class Builder {
57
    private static final String DEFAULT_NAMESPACE = "default";
58
    private static final List<ContextPropagator> EMPTY_CONTEXT_PROPAGATORS =
59
        Collections.emptyList();
1✔
60
    private static final List<ScheduleClientInterceptor> EMPTY_INTERCEPTORS =
1✔
61
        Collections.emptyList();
1✔
62

63
    private String namespace;
64
    private DataConverter dataConverter;
65
    private String identity;
66
    private List<ContextPropagator> contextPropagators;
67
    private List<ScheduleClientInterceptor> interceptors;
68

69
    private Builder() {}
70

71
    private Builder(ScheduleClientOptions options) {
×
72
      if (options == null) {
×
73
        return;
×
74
      }
75
      namespace = options.namespace;
×
76
      dataConverter = options.dataConverter;
×
77
      identity = options.identity;
×
78
      contextPropagators = options.contextPropagators;
×
NEW
79
      interceptors = options.interceptors;
×
UNCOV
80
    }
×
81

82
    /** Set the namespace this client will operate on. */
83
    public Builder setNamespace(String namespace) {
84
      this.namespace = namespace;
1✔
85
      return this;
1✔
86
    }
87

88
    /**
89
     * Overrides a data converter implementation used serialize workflow arguments and results.
90
     *
91
     * <p>Default is {@link DataConverter#getDefaultInstance()}.
92
     */
93
    public Builder setDataConverter(DataConverter dataConverter) {
94
      this.dataConverter = dataConverter;
×
95
      return this;
×
96
    }
97

98
    /** Override human-readable identity of the client. */
99
    public Builder setIdentity(String identity) {
100
      this.identity = identity;
×
101
      return this;
×
102
    }
103

104
    /**
105
     * Set the context propagators for this client.
106
     *
107
     * @param contextPropagators specifies the list of context propagators to use with the client.
108
     */
109
    public Builder setContextPropagators(List<ContextPropagator> contextPropagators) {
110
      this.contextPropagators = contextPropagators;
×
111
      return this;
×
112
    }
113

114
    /**
115
     * Set the interceptors for this client.
116
     *
117
     * @param interceptors specifies the list of interceptors to use with the client.
118
     */
119
    public Builder setInterceptors(List<ScheduleClientInterceptor> interceptors) {
NEW
120
      this.interceptors = interceptors;
×
NEW
121
      return this;
×
122
    }
123

124
    public ScheduleClientOptions build() {
125
      String name = identity == null ? ManagementFactory.getRuntimeMXBean().getName() : identity;
1✔
126
      return new ScheduleClientOptions(
1✔
127
          namespace == null ? DEFAULT_NAMESPACE : namespace,
1✔
128
          dataConverter == null ? GlobalDataConverter.get() : dataConverter,
1✔
129
          name,
130
          contextPropagators == null ? EMPTY_CONTEXT_PROPAGATORS : contextPropagators,
1✔
131
          interceptors == null ? EMPTY_INTERCEPTORS : interceptors);
1✔
132
    }
133
  }
134

135
  private final String namespace;
136
  private final DataConverter dataConverter;
137
  private final String identity;
138
  private final List<ContextPropagator> contextPropagators;
139
  private final List<ScheduleClientInterceptor> interceptors;
140

141
  private ScheduleClientOptions(
142
      String namespace,
143
      DataConverter dataConverter,
144
      String identity,
145
      List<ContextPropagator> contextPropagators,
146
      List<ScheduleClientInterceptor> interceptors) {
1✔
147
    this.namespace = namespace;
1✔
148
    this.dataConverter = dataConverter;
1✔
149
    this.identity = identity;
1✔
150
    this.contextPropagators = contextPropagators;
1✔
151
    this.interceptors = interceptors;
1✔
152
  }
1✔
153

154
  /**
155
   * Get the namespace this client will operate on.
156
   *
157
   * @return Client namespace
158
   */
159
  public String getNamespace() {
160
    return namespace;
1✔
161
  }
162

163
  /**
164
   * Get the data converters of this client
165
   *
166
   * @return The list of data converters to use with the client.
167
   */
168
  public DataConverter getDataConverter() {
169
    return dataConverter;
×
170
  }
171

172
  /**
173
   * Get the human-readable identity of the client.
174
   *
175
   * @return The identity of the client used on some requests.
176
   */
177
  public String getIdentity() {
178
    return identity;
×
179
  }
180

181
  /**
182
   * Get the context propagators of this client
183
   *
184
   * @return The list of context propagators to use with the client.
185
   */
186
  public List<ContextPropagator> getContextPropagators() {
187
    return contextPropagators;
×
188
  }
189

190
  /**
191
   * Get the interceptors of this client
192
   *
193
   * @return The list of interceptors to use with the client.
194
   */
195
  public List<ScheduleClientInterceptor> getInterceptors() {
196
    return interceptors;
1✔
197
  }
198
}
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