
org.glowroot.agent.shaded.grpc.ManagedChannelBuilder Maven / Gradle / Ivy
/*
* Copyright 2015, Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.glowroot.agent.shaded.grpc;
import java.util.List;
import java.util.concurrent.Executor;
/**
* A builder for {@link ManagedChannel} instances.
*
* @param The concrete type of this builder.
*/
public abstract class ManagedChannelBuilder> {
public static ManagedChannelBuilder> forAddress(String name, int port) {
return ManagedChannelProvider.provider().builderForAddress(name, port);
}
/**
* Provides a custom executor.
*
* It's an optional parameter. If the user has not provided an executor when the channel is
* built, the builder will use a static cached thread pool.
*
*
The channel won't take ownership of the given executor. It's caller's responsibility to
* shut down the executor when it's desired.
*/
public abstract T executor(Executor executor);
/**
* Adds interceptors that will be called before the channel performs its real work. This is
* functionally equivalent to using {@link ClientInterceptors#intercept(Channel, List)}, but while
* still having access to the original {@code ManagedChannel}.
*/
public abstract T intercept(List interceptors);
/**
* Adds interceptors that will be called before the channel performs its real work. This is
* functionally equivalent to using {@link ClientInterceptors#intercept(Channel,
* ClientInterceptor...)}, but while still having access to the original {@code ManagedChannel}.
*/
public abstract T intercept(ClientInterceptor... interceptors);
/**
* Provides a custom {@code User-Agent} for the application.
*
* It's an optional parameter. If provided, the given agent will be prepended by the
* grpc {@code User-Agent}.
*/
public abstract T userAgent(String userAgent);
/**
* Overrides the authority used with TLS and HTTP virtual hosting. It does not change what host is
* actually connected to. Is commonly in the form {@code host:port}.
*
*
Should only used by tests.
*/
@ExperimentalApi("primarily for testing")
public abstract T overrideAuthority(String authority);
/*
* Use of a plaintext connection to the server. By default a secure connection mechanism
* such as TLS will be used.
*
*
Should only be used for testing or for APIs where the use of such API or the data
* exchanged is not sensitive.
*
* @param skipNegotiation @{code true} if there is a priori knowledge that the endpoint supports
* plaintext, {@code false} if plaintext use must be negotiated.
*/
@ExperimentalApi("primarily for testing")
public abstract T usePlaintext(boolean skipNegotiation);
/**
* Builds a channel using the given parameters.
*/
public abstract ManagedChannel build();
}