Skip to content

Commit d068648

Browse files
authored
Merge branch 'main' into divyansh-vijayvergia_data/update_release_workflow
2 parents 625019e + eee4632 commit d068648

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package com.databricks.sdk.service.common.lro;
2+
3+
import java.time.Duration;
4+
import java.util.Objects;
5+
import java.util.Optional;
6+
7+
/**
8+
* Options for configuring long-running operation behavior. This class is not ready for use and can
9+
* be changed in backward incompatible ways.
10+
*
11+
* <p>This class provides configuration options for long-running operations, such as timeouts and
12+
* other behavioral settings.
13+
*/
14+
public class LroOptions {
15+
16+
/**
17+
* The maximum duration to wait for the operation to complete. If empty, the default timeout will
18+
* be used (typically 20 minutes).
19+
*/
20+
private final Optional<Duration> timeout;
21+
22+
/** Private constructor for builder pattern. */
23+
private LroOptions(Builder builder) {
24+
this.timeout = Optional.ofNullable(builder.timeout);
25+
}
26+
27+
/**
28+
* Gets the timeout for the operation.
29+
*
30+
* @return the timeout duration, or empty if using the default
31+
*/
32+
public Optional<Duration> getTimeout() {
33+
return timeout;
34+
}
35+
36+
/**
37+
* Creates a new builder for LroOptions.
38+
*
39+
* @return a new Builder instance
40+
*/
41+
public static Builder newBuilder() {
42+
return new Builder();
43+
}
44+
45+
/**
46+
* Creates LroOptions with the specified timeout. Convenience method for simple timeout
47+
* configuration.
48+
*
49+
* @param timeout the maximum duration to wait for operation completion
50+
* @return a new LroOptions instance
51+
*/
52+
public static LroOptions withTimeout(Duration timeout) {
53+
return newBuilder().setTimeout(timeout).build();
54+
}
55+
56+
/** Builder for LroOptions. */
57+
public static class Builder {
58+
private Duration timeout;
59+
60+
/**
61+
* Sets the timeout for the operation.
62+
*
63+
* @param timeout the maximum duration to wait for operation completion
64+
* @return this Builder instance for method chaining
65+
*/
66+
public Builder setTimeout(Duration timeout) {
67+
this.timeout = timeout;
68+
return this;
69+
}
70+
71+
/**
72+
* Builds the LroOptions instance.
73+
*
74+
* @return a new LroOptions instance
75+
*/
76+
public LroOptions build() {
77+
return new LroOptions(this);
78+
}
79+
}
80+
81+
@Override
82+
public boolean equals(Object o) {
83+
if (this == o) return true;
84+
if (o == null || getClass() != o.getClass()) return false;
85+
LroOptions that = (LroOptions) o;
86+
return Objects.equals(timeout, that.timeout);
87+
}
88+
89+
@Override
90+
public int hashCode() {
91+
return Objects.hash(timeout);
92+
}
93+
94+
@Override
95+
public String toString() {
96+
return "LroOptions{ timeout= " + timeout + " }";
97+
}
98+
}

scripts/cleanup-services.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ EXCLUDES=(
1515
"sharing/SharesExtService.java"
1616
"sharing/SharesExtImpl.java"
1717
"sharing/SharesExtAPI.java"
18+
"common/lro/LroOptions.java"
1819
)
1920

2021
echo "🧹 Cleaning service directory: $SERVICE_DIR"

0 commit comments

Comments
 (0)