Skip to content

Commit

Permalink
Add get system info timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns committed Sep 25, 2024
1 parent 0e58687 commit 94a56b9
Showing 1 changed file with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public final class WorkflowServiceStubsOptions extends ServiceStubsOptions {
/** Default RPC timeout for workflow queries */
public static final Duration DEFAULT_QUERY_RPC_TIMEOUT = Duration.ofSeconds(10);

public static final Duration DEFAULT_SYSTEM_INFO_TIMEOUT = Duration.ofSeconds(5);

private static final WorkflowServiceStubsOptions DEFAULT_INSTANCE =
newBuilder().validateAndBuildWithDefaults();

Expand All @@ -54,6 +56,8 @@ public final class WorkflowServiceStubsOptions extends ServiceStubsOptions {

/** Retry options for outgoing RPC calls */
private final RpcRetryOptions rpcRetryOptions;
/** Timeout for the RPC made by the client to fetch server capabilities. */
private final Duration systemInfoTimeout;

public static Builder newBuilder() {
return new Builder();
Expand All @@ -72,11 +76,13 @@ private WorkflowServiceStubsOptions(
boolean disableHealthCheck,
Duration rpcLongPollTimeout,
Duration rpcQueryTimeout,
Duration systemInfoTimeout,
RpcRetryOptions rpcRetryOptions) {
super(serviceStubsOptions);
this.disableHealthCheck = disableHealthCheck;
this.rpcLongPollTimeout = rpcLongPollTimeout;
this.rpcQueryTimeout = rpcQueryTimeout;
this.systemInfoTimeout = systemInfoTimeout;
this.rpcRetryOptions = rpcRetryOptions;
}

Expand Down Expand Up @@ -115,6 +121,13 @@ public RpcRetryOptions getRpcRetryOptions() {
return rpcRetryOptions;
}

/**
* SystemInfoTimeout is the timeout for the RPC made by the client to fetch server capabilities.
*/
public Duration getSystemInfoTimeout() {
return systemInfoTimeout;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -123,12 +136,18 @@ public boolean equals(Object o) {
return disableHealthCheck == that.disableHealthCheck
&& Objects.equals(rpcLongPollTimeout, that.rpcLongPollTimeout)
&& Objects.equals(rpcQueryTimeout, that.rpcQueryTimeout)
&& Objects.equals(systemInfoTimeout, that.systemInfoTimeout)
&& Objects.equals(rpcRetryOptions, that.rpcRetryOptions);
}

@Override
public int hashCode() {
return Objects.hash(disableHealthCheck, rpcLongPollTimeout, rpcQueryTimeout, rpcRetryOptions);
return Objects.hash(
disableHealthCheck,
rpcLongPollTimeout,
rpcQueryTimeout,
systemInfoTimeout,
rpcRetryOptions);
}

@Override
Expand All @@ -140,6 +159,8 @@ public String toString() {
+ rpcLongPollTimeout
+ ", rpcQueryTimeout="
+ rpcQueryTimeout
+ ", systemInfoTimeout="
+ systemInfoTimeout
+ ", rpcRetryOptions="
+ rpcRetryOptions
+ '}';
Expand All @@ -150,6 +171,7 @@ public static class Builder extends ServiceStubsOptions.Builder<Builder> {
private boolean disableHealthCheck = true;
private Duration rpcLongPollTimeout = DEFAULT_POLL_RPC_TIMEOUT;
private Duration rpcQueryTimeout = DEFAULT_QUERY_RPC_TIMEOUT;
private Duration systemInfoTimeout = DEFAULT_SYSTEM_INFO_TIMEOUT;
private RpcRetryOptions rpcRetryOptions = DefaultStubServiceOperationRpcRetryOptions.INSTANCE;

private Builder() {}
Expand All @@ -160,6 +182,7 @@ private Builder(ServiceStubsOptions options) {
WorkflowServiceStubsOptions castedOptions = (WorkflowServiceStubsOptions) options;
this.rpcLongPollTimeout = castedOptions.rpcLongPollTimeout;
this.rpcQueryTimeout = castedOptions.rpcQueryTimeout;
this.systemInfoTimeout = castedOptions.systemInfoTimeout;
this.rpcRetryOptions = castedOptions.rpcRetryOptions;
}
}
Expand Down Expand Up @@ -233,6 +256,16 @@ public Builder setRpcQueryTimeout(Duration rpcQueryTimeout) {
return this;
}

/**
* Sets the rpc timeout value RPC call to fetch server capabilities.
*
* @param timeout timeout.
*/
public Builder setSystemInfoTimeout(Duration timeout) {
this.systemInfoTimeout = Objects.requireNonNull(timeout);
return this;
}

/**
* Allows customization of retry options for the outgoing RPC calls to temporal service.
*
Expand Down Expand Up @@ -280,6 +313,7 @@ public WorkflowServiceStubsOptions build() {
this.disableHealthCheck,
this.rpcLongPollTimeout,
this.rpcQueryTimeout,
this.systemInfoTimeout,
this.rpcRetryOptions);
}

Expand All @@ -292,6 +326,7 @@ public WorkflowServiceStubsOptions validateAndBuildWithDefaults() {
this.disableHealthCheck,
this.rpcLongPollTimeout,
this.rpcQueryTimeout,
this.systemInfoTimeout,
retryOptions);
}
}
Expand Down

0 comments on commit 94a56b9

Please sign in to comment.