Class GcpManagedChannelOptions.Builder (1.11.0)

public static class GcpManagedChannelOptions.Builder

Inheritance

java.lang.Object > GcpManagedChannelOptions.Builder

Constructors

Builder()

public Builder()

Builder(GcpManagedChannelOptions options)

public Builder(GcpManagedChannelOptions options)
Parameter
Name Description
options GcpManagedChannelOptions

Methods

build()

public GcpManagedChannelOptions build()
Returns
Type Description
GcpManagedChannelOptions

withChannelPoolOptions(GcpManagedChannelOptions.GcpChannelPoolOptions channelPoolOptions)

public GcpManagedChannelOptions.Builder withChannelPoolOptions(GcpManagedChannelOptions.GcpChannelPoolOptions channelPoolOptions)

Sets the channel pool configuration for the GcpManagedChannel.

Parameter
Name Description
channelPoolOptions GcpManagedChannelOptions.GcpChannelPoolOptions

a GcpChannelPoolOptions to use as a channel pool configuration.

Returns
Type Description
GcpManagedChannelOptions.Builder

withMetricsOptions(GcpManagedChannelOptions.GcpMetricsOptions metricsOptions)

public GcpManagedChannelOptions.Builder withMetricsOptions(GcpManagedChannelOptions.GcpMetricsOptions metricsOptions)

Sets the metrics configuration for the GcpManagedChannel.

If a MetricRegistry is provided in GcpMetricsOptions then the GcpManagedChannel will emit metrics using that registry. The metrics options also allow to set up labels (tags) and a prefix for metrics names. The GcpManagedChannel will add its own label "pool_index" with values "pool-0", "pool-1", etc. for each instance of GcpManagedChannel created.

Example usage (e. g. with export to Cloud Monitoring)

// Enable Cloud Monitoring exporter. StackdriverStatsExporter.createAndRegister();

// Configure metrics options. GcpMetricsOptions metricsOptions = GcpMetricsOptions.newBuilder(Metrics.getMetricRegistry()) .withNamePrefix("myapp/gcp-pool/") .build());

final GcpManagedChannel pool = (GcpManagedChannel) GcpManagedChannelBuilder.forDelegateBuilder(builder) .withOptions( GcpManagedChannelOptions.newBuilder() .withMetricsOptions(metricsOptions) .build()) .build();

// Use the pool that will emit metrics which will be exported to Cloud Monitoring.

Parameter
Name Description
metricsOptions GcpManagedChannelOptions.GcpMetricsOptions

a GcpMetricsOptions to use as metrics configuration.

Returns
Type Description
GcpManagedChannelOptions.Builder

withResiliencyOptions(GcpManagedChannelOptions.GcpResiliencyOptions resiliencyOptions)

public GcpManagedChannelOptions.Builder withResiliencyOptions(GcpManagedChannelOptions.GcpResiliencyOptions resiliencyOptions)

Sets the resiliency configuration for the GcpManagedChannel.

Parameter
Name Description
resiliencyOptions GcpManagedChannelOptions.GcpResiliencyOptions

a GcpResiliencyOptions to use as resiliency configuration.

Returns
Type Description
GcpManagedChannelOptions.Builder