Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PerHostTarget builder #2195

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@

package com.palantir.dialogue.clients;

import com.google.errorprone.annotations.CheckReturnValue;
import com.palantir.dialogue.core.TargetUri;
import com.palantir.logsafe.Preconditions;
import javax.annotation.Nullable;

public final class PerHostTarget {

private final TargetUri targetUri;

PerHostTarget(TargetUri targetUri) {
private PerHostTarget(TargetUri targetUri) {
this.targetUri = targetUri;
}

Expand Down Expand Up @@ -51,4 +54,26 @@ public boolean equals(Object other) {
public int hashCode() {
return targetUri.hashCode();
}

public static Builder builder() {
return new Builder();
}

public static final class Builder {

@Nullable
private TargetUri targetUri;

private Builder() {}

public Builder targetUri(TargetUri value) {
this.targetUri = Preconditions.checkNotNull(value, "targetUri");
return this;
}

@CheckReturnValue
public PerHostTarget build() {
return new PerHostTarget(Preconditions.checkNotNull(targetUri, "targetUri"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public PerHostClientFactory perHost(String serviceName) {
// subtle gotcha here is that every single one of these has the same channelName,
// which means metrics like the QueuedChannel counter will end up being the sum of all of them.
map.put(
new PerHostTarget(targetUri),
PerHostTarget.builder().targetUri(targetUri).build(),
cache.getNonReloadingChannel(
params,
singleUriServiceConf,
Expand Down
Loading