• 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/SchedulePolicy.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.api.enums.v1.ScheduleOverlapPolicy;
24
import java.time.Duration;
25
import java.util.Objects;
26

27
/** Policies of a schedule. */
28
public final class SchedulePolicy {
29
  public static SchedulePolicy.Builder newBuilder() {
30
    return new SchedulePolicy.Builder();
×
31
  }
32

33
  public static SchedulePolicy.Builder newBuilder(SchedulePolicy options) {
34
    return new SchedulePolicy.Builder(options);
×
35
  }
36

37
  public static final class Builder {
38
    private ScheduleOverlapPolicy overlap;
39
    private Duration catchupWindow;
40
    private boolean pauseOnFailure;
41

42
    private Builder() {}
43

44
    private Builder(SchedulePolicy options) {
×
45
      if (options == null) {
×
46
        return;
×
47
      }
48
      this.overlap = options.overlap;
×
49
      this.catchupWindow = options.catchupWindow;
×
50
      this.pauseOnFailure = options.pauseOnFailure;
×
51
    }
×
52

53
    /** Set the policy for what happens when an action is started while another is still running. */
54
    public Builder setOverlap(ScheduleOverlapPolicy overlap) {
55
      this.overlap = overlap;
×
56
      return this;
×
57
    }
58

59
    /**
60
     * Set the amount of time in the past to execute missed actions after a Temporal server is
61
     * unavailable.
62
     */
63
    public Builder setCatchupWindow(Duration catchupWindow) {
64
      this.catchupWindow = catchupWindow;
×
65
      return this;
×
66
    }
67

68
    /** Set whether to pause the schedule if an action fails or times out. */
69
    public Builder setPauseOnFailure(boolean pauseOnFailure) {
70
      this.pauseOnFailure = pauseOnFailure;
×
71
      return this;
×
72
    }
73

74
    public SchedulePolicy build() {
75
      return new SchedulePolicy(
×
76
          overlap == null ? ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_SKIP : overlap,
×
77
          catchupWindow,
78
          pauseOnFailure);
79
    }
80
  }
81

82
  private final ScheduleOverlapPolicy overlap;
83
  private final Duration catchupWindow;
84
  private final boolean pauseOnFailure;
85

86
  private SchedulePolicy(
87
      ScheduleOverlapPolicy overlap, Duration catchupWindow, boolean pauseOnFailure) {
×
88
    this.overlap = overlap;
×
89
    this.catchupWindow = catchupWindow;
×
90
    this.pauseOnFailure = pauseOnFailure;
×
91
  }
×
92

93
  /**
94
   * Gets the policy for what happens when an action is started while another is still running.
95
   *
96
   * @return the schedules overlap policy
97
   */
98
  public ScheduleOverlapPolicy getOverlap() {
99
    return overlap;
×
100
  }
101

102
  /**
103
   * Gets the amount of time in the past to execute missed actions after a Temporal server is
104
   * unavailable.
105
   *
106
   * @return the schedules catchup window
107
   */
108
  public Duration getCatchupWindow() {
109
    return catchupWindow;
×
110
  }
111

112
  /**
113
   * Gets a value indicating whether to pause the schedule if an action fails or times out.
114
   *
115
   * @return if the schedule should pause on failure
116
   */
117
  public boolean isPauseOnFailure() {
118
    return pauseOnFailure;
×
119
  }
120

121
  @Override
122
  public boolean equals(Object o) {
123
    if (this == o) return true;
×
124
    if (o == null || getClass() != o.getClass()) return false;
×
125
    SchedulePolicy that = (SchedulePolicy) o;
×
126
    return pauseOnFailure == that.pauseOnFailure
×
127
        && overlap == that.overlap
128
        && Objects.equals(catchupWindow, that.catchupWindow);
×
129
  }
130

131
  @Override
132
  public int hashCode() {
133
    return Objects.hash(overlap, catchupWindow, pauseOnFailure);
×
134
  }
135

136
  @Override
137
  public String toString() {
138
    return "SchedulePolicy{"
×
139
        + "overlap="
140
        + overlap
141
        + ", catchupWindow="
142
        + catchupWindow
143
        + ", pauseOnFailure="
144
        + pauseOnFailure
145
        + '}';
146
  }
147
}
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