1 // 2 // Copyright 2018 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 #ifndef GRPC_SRC_CORE_LOAD_BALANCING_RING_HASH_RING_HASH_H 18 #define GRPC_SRC_CORE_LOAD_BALANCING_RING_HASH_RING_HASH_H 19 20 #include <grpc/support/port_platform.h> 21 #include <stdint.h> 22 23 #include "src/core/service_config/service_config_call_data.h" 24 #include "src/core/util/json/json.h" 25 #include "src/core/util/json/json_args.h" 26 #include "src/core/util/json/json_object_loader.h" 27 #include "src/core/util/unique_type_name.h" 28 #include "src/core/util/validation_errors.h" 29 30 // Optional endpoint attribute specifying the hash key. 31 #define GRPC_ARG_RING_HASH_ENDPOINT_HASH_KEY \ 32 GRPC_ARG_NO_SUBCHANNEL_PREFIX "hash_key" 33 34 namespace grpc_core { 35 36 class RequestHashAttribute final 37 : public ServiceConfigCallData::CallAttributeInterface { 38 public: 39 static UniqueTypeName TypeName(); 40 RequestHashAttribute(uint64_t request_hash)41 explicit RequestHashAttribute(uint64_t request_hash) 42 : request_hash_(request_hash) {} 43 request_hash()44 uint64_t request_hash() const { return request_hash_; } 45 46 private: type()47 UniqueTypeName type() const override { return TypeName(); } 48 49 uint64_t request_hash_; 50 }; 51 52 } // namespace grpc_core 53 54 #endif // GRPC_SRC_CORE_LOAD_BALANCING_RING_HASH_RING_HASH_H 55