1 /*
2  * Copyright 2016 The gRPC Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package io.grpc.netty;
18 
19 import io.grpc.Internal;
20 import io.grpc.internal.ClientTransportFactory;
21 
22 /**
23  * Internal {@link NettyChannelBuilder} accessor.  This is intended for usage internal to the gRPC
24  * team.  If you *really* think you need to use this, contact the gRPC team first.
25  */
26 @Internal
27 public final class InternalNettyChannelBuilder {
28 
29   /**
30    * Checks authority upon channel construction.  The purpose of this interface is to raise the
31    * visibility of {@link NettyChannelBuilder.OverrideAuthorityChecker}.
32    */
33   public interface OverrideAuthorityChecker extends NettyChannelBuilder.OverrideAuthorityChecker {}
34 
overrideAuthorityChecker( NettyChannelBuilder channelBuilder, OverrideAuthorityChecker authorityChecker)35   public static void overrideAuthorityChecker(
36       NettyChannelBuilder channelBuilder, OverrideAuthorityChecker authorityChecker) {
37     channelBuilder.overrideAuthorityChecker(authorityChecker);
38   }
39 
40   /** A class that provides a Netty handler to control protocol negotiation. */
41   public interface ProtocolNegotiatorFactory
42       extends NettyChannelBuilder.ProtocolNegotiatorFactory {}
43 
44   /**
45    * Sets the {@link ProtocolNegotiatorFactory} to be used. Overrides any specified negotiation type
46    * and {@code SslContext}.
47    */
setProtocolNegotiatorFactory( NettyChannelBuilder builder, ProtocolNegotiatorFactory protocolNegotiator)48   public static void setProtocolNegotiatorFactory(
49       NettyChannelBuilder builder, ProtocolNegotiatorFactory protocolNegotiator) {
50     builder.protocolNegotiatorFactory(protocolNegotiator);
51   }
52 
setStatsEnabled(NettyChannelBuilder builder, boolean value)53   public static void setStatsEnabled(NettyChannelBuilder builder, boolean value) {
54     builder.setStatsEnabled(value);
55   }
56 
setTracingEnabled(NettyChannelBuilder builder, boolean value)57   public static void setTracingEnabled(NettyChannelBuilder builder, boolean value) {
58     builder.setTracingEnabled(value);
59   }
60 
setStatsRecordStartedRpcs(NettyChannelBuilder builder, boolean value)61   public static void setStatsRecordStartedRpcs(NettyChannelBuilder builder, boolean value) {
62     builder.setStatsRecordStartedRpcs(value);
63   }
64 
buildTransportFactory(NettyChannelBuilder builder)65   public static ClientTransportFactory buildTransportFactory(NettyChannelBuilder builder) {
66     return builder.buildTransportFactory();
67   }
68 
InternalNettyChannelBuilder()69   private InternalNettyChannelBuilder() {}
70 }
71