|
|
|
@ -28,6 +28,10 @@ namespace experimental { |
|
|
|
|
|
|
|
|
|
class XdsServerServingStatusNotifierInterface { |
|
|
|
|
public: |
|
|
|
|
struct ServingStatusUpdate { |
|
|
|
|
::grpc::Status status; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
virtual ~XdsServerServingStatusNotifierInterface() = default; |
|
|
|
|
|
|
|
|
|
// \a uri contains the listening target associated with the notification. Note
|
|
|
|
@ -37,7 +41,8 @@ class XdsServerServingStatusNotifierInterface { |
|
|
|
|
// The API does not provide any guarantees around duplicate updates.
|
|
|
|
|
// Status::OK signifies that the server is serving, while a non-OK status
|
|
|
|
|
// signifies that the server is not serving.
|
|
|
|
|
virtual void OnServingStatusUpdate(std::string uri, grpc::Status status) = 0; |
|
|
|
|
virtual void OnServingStatusUpdate(std::string uri, |
|
|
|
|
ServingStatusUpdate update) = 0; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class XdsServerBuilder : public ::grpc::ServerBuilder { |
|
|
|
@ -62,13 +67,13 @@ class XdsServerBuilder : public ::grpc::ServerBuilder { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void OnServingStatusUpdate(void* user_data, const char* uri, |
|
|
|
|
grpc_status_code code, |
|
|
|
|
const char* error_message) { |
|
|
|
|
grpc_serving_status_update update) { |
|
|
|
|
if (user_data == nullptr) return; |
|
|
|
|
XdsServerServingStatusNotifierInterface* notifier = |
|
|
|
|
static_cast<XdsServerServingStatusNotifierInterface*>(user_data); |
|
|
|
|
notifier->OnServingStatusUpdate( |
|
|
|
|
uri, grpc::Status(static_cast<StatusCode>(code), error_message)); |
|
|
|
|
uri, {grpc::Status(static_cast<StatusCode>(update.code), |
|
|
|
|
update.error_message)}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
XdsServerServingStatusNotifierInterface* notifier_ = nullptr; |
|
|
|
|