Skip to content

Commit

Permalink
alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
sgbalogh committed Jan 31, 2025
1 parent 42ba2fa commit 23dc436
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion s2/src/main/java/s2/config/BasinEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Objects;

public abstract sealed class BasinEndpoint permits ParentZone, Direct {
final Address address;
public final Address address;

BasinEndpoint(Address address) {
this.address = address;
Expand Down
68 changes: 34 additions & 34 deletions s2/src/main/java/s2/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@

public class Config {
public final String token;
public final AppendRetryPolicy appendRetryPolicy;
public final Endpoints endpoints;
public final String userAgent;
public final Integer maxAppendInflightBytes;
public final Integer maxRetries;
public final Duration retryDelay;
public final Duration requestTimeout;
public final AppendRetryPolicy appendRetryPolicy;
public final Integer maxAppendInflightBytes;
public final Duration retryDelay;
public final String userAgent;

private Config(
String token,
AppendRetryPolicy appendRetryPolicy,
Endpoints endpoints,
String userAgent,
Integer maxAppendInflightBytes,
Integer maxRetries,
Duration retryDelay,
Duration requestTimeout,
AppendRetryPolicy appendRetryPolicy,
Integer maxAppendInflightBytes) {
Duration retryDelay,
String userAgent) {
this.token = token;
this.appendRetryPolicy = appendRetryPolicy;
this.endpoints = endpoints;
this.userAgent = userAgent;
this.maxAppendInflightBytes = maxAppendInflightBytes;
this.maxRetries = maxRetries;
this.retryDelay = retryDelay;
this.requestTimeout = requestTimeout;
this.appendRetryPolicy = appendRetryPolicy;
this.maxAppendInflightBytes = maxAppendInflightBytes;
this.retryDelay = retryDelay;
this.userAgent = userAgent;
}

public static ConfigBuilder newBuilder(String token) {
Expand All @@ -39,64 +39,64 @@ public static ConfigBuilder newBuilder(String token) {

public static final class ConfigBuilder {
private final String token;
private Optional<String> userAgent = Optional.empty();
private Optional<AppendRetryPolicy> appendRetryPolicy = Optional.empty();
private Optional<Endpoints> endpoints = Optional.empty();
private Optional<Duration> requestTimeout = Optional.empty();
private Optional<Integer> maxAppendInflightBytes = Optional.empty();
private Optional<Integer> maxRetries = Optional.empty();
private Optional<Duration> requestTimeout = Optional.empty();
private Optional<Duration> retryDelay = Optional.empty();
private Optional<AppendRetryPolicy> appendRetryPolicy = Optional.empty();
private Optional<Integer> maxAppendInflightBytes = Optional.empty();
private Optional<String> userAgent = Optional.empty();

ConfigBuilder(String token) {
this.token = token;
}

public ConfigBuilder withUserAgent(String userAgent) {
this.userAgent = Optional.of(userAgent);
public ConfigBuilder withAppendRetryPolicy(AppendRetryPolicy appendRetryPolicy) {
this.appendRetryPolicy = Optional.of(appendRetryPolicy);
return this;
}

public ConfigBuilder withRequestTimeout(long timeout, TemporalUnit unit) {
this.requestTimeout = Optional.of(Duration.of(timeout, unit));
public ConfigBuilder withEndpoints(Endpoints endpoints) {
this.endpoints = Optional.of(endpoints);
return this;
}

public ConfigBuilder withMaxRetries(int retries) {
this.maxRetries = Optional.of(retries);
public ConfigBuilder withMaxAppendInflightBytes(int maxAppendInflightBytes) {
this.maxAppendInflightBytes = Optional.of(maxAppendInflightBytes);
return this;
}

public ConfigBuilder withRetryDelay(Duration delay) {
this.retryDelay = Optional.of(delay);
public ConfigBuilder withMaxRetries(int retries) {
this.maxRetries = Optional.of(retries);
return this;
}

public ConfigBuilder withEndpoints(Endpoints endpoints) {
this.endpoints = Optional.of(endpoints);
public ConfigBuilder withRequestTimeout(long timeout, TemporalUnit unit) {
this.requestTimeout = Optional.of(Duration.of(timeout, unit));
return this;
}

public ConfigBuilder withAppendRetryPolicy(AppendRetryPolicy appendRetryPolicy) {
this.appendRetryPolicy = Optional.of(appendRetryPolicy);
public ConfigBuilder withRetryDelay(Duration delay) {
this.retryDelay = Optional.of(delay);
return this;
}

public ConfigBuilder withMaxAppendInflightBytes(int maxAppendInflightBytes) {
this.maxAppendInflightBytes = Optional.of(maxAppendInflightBytes);
public ConfigBuilder withUserAgent(String userAgent) {
this.userAgent = Optional.of(userAgent);
return this;
}

public Config build() {
validate();
return new Config(
this.token,
this.appendRetryPolicy.orElse(AppendRetryPolicy.ALL),
this.endpoints.orElse(Endpoints.forCloud(Cloud.AWS)),
this.userAgent.orElse("s2-sdk-java"),
this.maxAppendInflightBytes.orElse(Integer.MAX_VALUE),
this.maxRetries.orElse(3),
this.retryDelay.orElse(Duration.ofMillis(50)),
this.requestTimeout.orElse(Duration.ofSeconds(10)),
this.appendRetryPolicy.orElse(AppendRetryPolicy.ALL),
this.maxAppendInflightBytes.orElse(Integer.MAX_VALUE));
this.retryDelay.orElse(Duration.ofMillis(50)),
this.userAgent.orElse("s2-sdk-java"));
}

private void validate() {
Expand Down

0 comments on commit 23dc436

Please sign in to comment.