Skip to content

Commit

Permalink
core: change service config to ConfigOrError
Browse files Browse the repository at this point in the history
Both the config and the error need to be passed to the managed channel so it can decide to keep or reject the config. Passing only the parsed object means the managed channel cannot implement the error handling gRFC.
  • Loading branch information
carl-mastrangelo committed Apr 8, 2019
1 parent c8a0af5 commit 483697f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions core/src/main/java/io/grpc/NameResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import io.grpc.NameResolver.Helper.ConfigOrError;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down Expand Up @@ -419,12 +420,12 @@ public static final class ResolutionResult {
@ResolutionResultAttr
private final Attributes attributes;
@Nullable
private final Object serviceConfig;
private final ConfigOrError serviceConfig;

ResolutionResult(
List<EquivalentAddressGroup> servers,
@ResolutionResultAttr Attributes attributes,
Object serviceConfig) {
ConfigOrError serviceConfig) {
this.servers = Collections.unmodifiableList(new ArrayList<>(servers));
this.attributes = checkNotNull(attributes, "attributes");
this.serviceConfig = serviceConfig;
Expand Down Expand Up @@ -477,7 +478,7 @@ public Attributes getAttributes() {
* @since 1.21.0
*/
@Nullable
public Object getServiceConfig() {
public ConfigOrError getServiceConfig() {
return serviceConfig;
}

Expand Down Expand Up @@ -515,7 +516,7 @@ public static final class Builder {
private List<EquivalentAddressGroup> servers = Collections.emptyList();
private Attributes attributes = Attributes.EMPTY;
@Nullable
private Object serviceConfig;
private ConfigOrError serviceConfig;
// Make sure to update #toBuilder above!

Builder() {}
Expand Down Expand Up @@ -547,7 +548,7 @@ public Builder setAttributes(Attributes attributes) {
*
* @since 1.21.0
*/
public Builder setServiceConfig(@Nullable Object serviceConfig) {
public Builder setServiceConfig(@Nullable ConfigOrError serviceConfig) {
this.serviceConfig = serviceConfig;
return this;
}
Expand Down

0 comments on commit 483697f

Please sign in to comment.