// Copyright 2025 Envoy Project Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package envoy.service.event_reporting.v3;

import "envoy/config/core/v3/base.proto";

import "google/protobuf/any.proto";

import "udpa/annotations/status.proto";
import "udpa/annotations/versioning.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.service.event_reporting.v3";
option java_outer_classname = "EventReportingServiceProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/service/event_reporting/v3;event_reportingv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: gRPC Event Reporting Service]

// [#not-implemented-hide:]
// Service for streaming different types of events from Envoy to a server. The examples of
// such events may be health check or outlier detection events.
service EventReportingService {
  // Envoy will connect and send StreamEventsRequest messages forever.
  // The management server may send StreamEventsResponse to configure event stream. See below.
  // This API is designed for high throughput with the expectation that it might be lossy.
  rpc StreamEvents(stream StreamEventsRequest) returns (stream StreamEventsResponse) {
  }
}

// [#not-implemented-hide:]
// An events envoy sends to the management server.
message StreamEventsRequest {
  option (udpa.annotations.versioning).previous_message_type =
      "envoy.service.event_reporting.v2alpha.StreamEventsRequest";

  message Identifier {
    option (udpa.annotations.versioning).previous_message_type =
        "envoy.service.event_reporting.v2alpha.StreamEventsRequest.Identifier";

    // The node sending the event messages over the stream.
    config.core.v3.Node node = 1 [(validate.rules).message = {required: true}];
  }

  // Identifier data that will only be sent in the first message on the stream. This is effectively
  // structured metadata and is a performance optimization.
  Identifier identifier = 1;

  // Batch of events. When the stream is already active, it will be the events occurred
  // since the last message had been sent. If the server receives unknown event type, it should
  // silently ignore it.
  //
  // The following events are supported:
  //
  // * :ref:`HealthCheckEvent <envoy_v3_api_msg_data.core.v3.HealthCheckEvent>`
  // * :ref:`OutlierDetectionEvent <envoy_v3_api_msg_data.cluster.v3.OutlierDetectionEvent>`
  repeated google.protobuf.Any events = 2 [(validate.rules).repeated = {min_items: 1}];
}

// [#not-implemented-hide:]
// The management server may send envoy a StreamEventsResponse to tell which events the server
// is interested in. In future, with aggregated event reporting service, this message will
// contain, for example, clusters the envoy should send events for, or event types the server
// wants to process.
message StreamEventsResponse {
  option (udpa.annotations.versioning).previous_message_type =
      "envoy.service.event_reporting.v2alpha.StreamEventsResponse";
}
