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

temporalio / sdk-java / #174

pending completion
#174

push

github-actions

web-flow
Add schedules API (#1776)

Add schedules API

1143 of 1143 new or added lines in 35 files covered. (100.0%)

18101 of 23284 relevant lines covered (77.74%)

0.78 hits per line

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

0.0
/temporal-sdk/src/main/java/io/temporal/client/schedules/ScheduleClientImpl.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 static io.temporal.internal.WorkflowThreadMarker.enforceNonWorkflowThread;
24

25
import com.uber.m3.tally.Scope;
26
import io.temporal.common.interceptors.ScheduleClientCallsInterceptor;
27
import io.temporal.internal.WorkflowThreadMarker;
28
import io.temporal.internal.client.RootScheduleClientInvoker;
29
import io.temporal.internal.client.external.GenericWorkflowClient;
30
import io.temporal.internal.client.external.GenericWorkflowClientImpl;
31
import io.temporal.serviceclient.MetricsTag;
32
import io.temporal.serviceclient.WorkflowServiceStubs;
33
import java.util.stream.Stream;
34
import javax.annotation.Nullable;
35

36
final class ScheduleClientImpl implements ScheduleClient {
37
  private final WorkflowServiceStubs workflowServiceStubs;
38
  private final ScheduleClientOptions options;
39
  private final GenericWorkflowClient genericClient;
40
  private final Scope metricsScope;
41
  private final ScheduleClientCallsInterceptor scheduleClientCallsInvoker;
42

43
  /**
44
   * Creates client that connects to an instance of the Temporal Service. Cannot be used from within
45
   * workflow code.
46
   *
47
   * @param service client to the Temporal Service endpoint.
48
   * @param options Options (like {@link io.temporal.common.converter.DataConverter} override) for
49
   *     configuring client.
50
   * @return client to interact with schedules
51
   */
52
  public static ScheduleClient newInstance(
53
      WorkflowServiceStubs service, ScheduleClientOptions options) {
54
    enforceNonWorkflowThread();
×
55
    return WorkflowThreadMarker.protectFromWorkflowThread(
×
56
        new ScheduleClientImpl(service, options), ScheduleClient.class);
57
  }
58

59
  ScheduleClientImpl(WorkflowServiceStubs workflowServiceStubs, ScheduleClientOptions options) {
×
60
    this.workflowServiceStubs = workflowServiceStubs;
×
61
    this.options = options;
×
62
    this.metricsScope =
×
63
        workflowServiceStubs
64
            .getOptions()
×
65
            .getMetricsScope()
×
66
            .tagged(MetricsTag.defaultTags(options.getNamespace()));
×
67
    this.genericClient = new GenericWorkflowClientImpl(workflowServiceStubs, metricsScope);
×
68
    this.scheduleClientCallsInvoker = new RootScheduleClientInvoker(genericClient, options);
×
69
  }
×
70

71
  @Override
72
  public ScheduleHandle createSchedule(
73
      String scheduleID, Schedule schedule, ScheduleOptions options) {
74
    scheduleClientCallsInvoker.createSchedule(
×
75
        new ScheduleClientCallsInterceptor.CreateScheduleInput(scheduleID, schedule, options));
76
    return new ScheduleHandleImpl(scheduleClientCallsInvoker, scheduleID);
×
77
  }
78

79
  @Override
80
  public ScheduleHandle getHandle(String scheduleID) {
81
    return new ScheduleHandleImpl(scheduleClientCallsInvoker, scheduleID);
×
82
  }
83

84
  @Override
85
  public Stream<ScheduleListDescription> listSchedules() {
86
    return this.listSchedules(null);
×
87
  }
88

89
  @Override
90
  public Stream<ScheduleListDescription> listSchedules(@Nullable Integer pageSize) {
91
    return scheduleClientCallsInvoker
×
92
        .listSchedules(
×
93
            new ScheduleClientCallsInterceptor.ListSchedulesInput(
94
                pageSize == null ? 100 : pageSize))
×
95
        .getStream();
×
96
  }
97
}
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