1 // 2 // 3 // Copyright 2023 gRPC authors. 4 // 5 // Licensed under the Apache License, Version 2.0 (the "License"); 6 // you may not use this file except in compliance with the License. 7 // You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 // 17 // 18 19 #include <grpc/grpc.h> 20 #include <grpc/impl/channel_arg_names.h> 21 #include <grpcpp/server_builder.h> 22 #include <grpcpp/support/channel_arguments.h> 23 #include <grpcpp/xds_server_builder.h> 24 25 #include "src/core/ext/xds/xds_enabled_server.h" 26 27 namespace grpc { 28 BuildChannelArgs()29ChannelArguments XdsServerBuilder::BuildChannelArgs() { 30 ChannelArguments args = ServerBuilder::BuildChannelArgs(); 31 if (drain_grace_time_ms_ >= 0) { 32 args.SetInt(GRPC_ARG_SERVER_CONFIG_CHANGE_DRAIN_GRACE_TIME_MS, 33 drain_grace_time_ms_); 34 } 35 args.SetInt(GRPC_ARG_XDS_ENABLED_SERVER, 1); 36 grpc_channel_args c_channel_args = args.c_channel_args(); 37 grpc_server_config_fetcher* fetcher = grpc_server_config_fetcher_xds_create( 38 {OnServingStatusUpdate, notifier_}, &c_channel_args); 39 if (fetcher != nullptr) set_fetcher(fetcher); 40 return args; 41 } 42 43 } // namespace grpc 44