io.deephaven.proto.DeephavenChannelWithCallCredentials Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-proto-backplane-grpc Show documentation
Show all versions of deephaven-proto-backplane-grpc Show documentation
The Deephaven proto-backplane-grpc
The newest version!
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.proto;
import io.grpc.CallCredentials;
import io.grpc.CallOptions;
import io.grpc.Channel;
import io.grpc.ClientCall;
import io.grpc.MethodDescriptor;
import io.grpc.stub.AbstractStub;
import java.util.Objects;
final class DeephavenChannelWithCallCredentials extends DeephavenChannelMixin {
private final CallCredentials callCredentials;
public DeephavenChannelWithCallCredentials(DeephavenChannel delegate, CallCredentials callCredentials) {
super(delegate);
this.callCredentials = Objects.requireNonNull(callCredentials);
}
@Override
protected > S mixin(S stub) {
return stub.withCallCredentials(callCredentials);
}
@Override
protected Channel mixinChannel(Channel channel) {
return new CallCredentialsChannel(channel);
}
private final class CallCredentialsChannel extends Channel {
private final Channel delegate;
public CallCredentialsChannel(Channel delegate) {
this.delegate = Objects.requireNonNull(delegate);
}
@Override
public ClientCall newCall(
MethodDescriptor methodDescriptor, CallOptions callOptions) {
return delegate.newCall(methodDescriptor, callOptions.withCallCredentials(callCredentials));
}
@Override
public String authority() {
return delegate.authority();
}
}
}