what-the-bank/sources/io/grpc/internal/ServiceConfigState.java

74 lines
2.6 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package io.grpc.internal;
import com.google.common.base.Preconditions;
import io.grpc.NameResolver;
/* loaded from: classes6.dex */
final class ServiceConfigState {
static final boolean $assertionsDisabled = false;
private NameResolver.ConfigOrError currentServiceConfigOrError;
private final NameResolver.ConfigOrError defaultServiceConfig;
private final boolean lookUpServiceConfig;
private boolean updated;
ServiceConfigState(ManagedChannelServiceConfig managedChannelServiceConfig, boolean z) {
if (managedChannelServiceConfig == null) {
this.defaultServiceConfig = null;
} else {
this.defaultServiceConfig = NameResolver.ConfigOrError.fromConfig(managedChannelServiceConfig);
}
this.lookUpServiceConfig = z;
if (z) {
return;
}
this.currentServiceConfigOrError = this.defaultServiceConfig;
}
final boolean shouldWaitOnServiceConfig() {
return !this.updated && expectUpdates();
}
final NameResolver.ConfigOrError getCurrent() {
Preconditions.checkState(!shouldWaitOnServiceConfig(), "still waiting on service config");
return this.currentServiceConfigOrError;
}
final void update(NameResolver.ConfigOrError configOrError) {
NameResolver.ConfigOrError configOrError2;
Preconditions.checkState(expectUpdates(), "unexpected service config update");
boolean z = this.updated;
this.updated = true;
if (!(!z)) {
if (configOrError == null) {
configOrError = this.defaultServiceConfig;
if (configOrError == null) {
this.currentServiceConfigOrError = null;
return;
}
} else if (configOrError.getError() != null && ((configOrError2 = this.currentServiceConfigOrError) == null || configOrError2.getError() == null)) {
return;
}
this.currentServiceConfigOrError = configOrError;
return;
}
if (configOrError == null) {
this.currentServiceConfigOrError = this.defaultServiceConfig;
return;
}
if (configOrError.getError() == null) {
this.currentServiceConfigOrError = configOrError;
return;
}
NameResolver.ConfigOrError configOrError3 = this.defaultServiceConfig;
if (configOrError3 != null) {
this.currentServiceConfigOrError = configOrError3;
} else {
this.currentServiceConfigOrError = configOrError;
}
}
final boolean expectUpdates() {
return this.lookUpServiceConfig;
}
}