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.grpclb; 18 19 import io.grpc.Attributes; 20 import io.grpc.EquivalentAddressGroup; 21 import io.grpc.ExperimentalApi; 22 import io.grpc.Metadata; 23 import java.util.List; 24 25 /** 26 * Constants for the GRPCLB load-balancer. 27 */ 28 @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1782") 29 public final class GrpclbConstants { 30 31 /** 32 * The opaque token given by the remote balancer for each returned server address. The client 33 * will send this token with any requests sent to the associated server. 34 */ 35 public static final Metadata.Key<String> TOKEN_METADATA_KEY = 36 Metadata.Key.of("lb-token", Metadata.ASCII_STRING_MARSHALLER); 37 38 /** 39 * For passing LB tokens via the EAG attributes. 40 */ 41 @EquivalentAddressGroup.Attr 42 static final Attributes.Key<String> TOKEN_ATTRIBUTE_KEY = 43 Attributes.Key.create("lb-token"); 44 45 /** 46 * Attribute key for gRPC LB server addresses. 47 */ 48 public static final Attributes.Key<List<EquivalentAddressGroup>> ATTR_LB_ADDRS = 49 Attributes.Key.create("io.grpc.grpclb.GrpclbConstants.ATTR_LB_ADDRS"); 50 51 /** 52 * The naming authority of a gRPC LB server address. It is an address-group-level attribute, 53 * present when the address group is a LoadBalancer. 54 */ 55 @EquivalentAddressGroup.Attr 56 public static final Attributes.Key<String> ATTR_LB_ADDR_AUTHORITY = 57 Attributes.Key.create("io.grpc.grpclb.GrpclbConstants.ATTR_LB_ADDR_AUTHORITY"); 58 59 /** 60 * Whether this EquivalentAddressGroup was provided by a GRPCLB server. It would be rare for this 61 * value to be {@code false}; generally it would be better to not have the key present at all. 62 */ 63 @EquivalentAddressGroup.Attr 64 public static final Attributes.Key<Boolean> ATTR_LB_PROVIDED_BACKEND = 65 Attributes.Key.create("io.grpc.grpclb.GrpclbConstants.ATTR_LB_PROVIDED_BACKEND"); 66 GrpclbConstants()67 private GrpclbConstants() { } 68 } 69