syntax = "proto3";

option go_package = "github.com/kong/koko/internal/gen/wrpc/kong/model;model";

package kong.model;

import "kong/model/certificate.proto";

message Upstream {
  string id = 1;
  string name = 2;
  string host_header = 3;
  Certificate client_certificate = 4;
  string algorithm = 5;
  int32 slots = 6;
  Healthcheck healthchecks = 7;
  int32 created_at = 8;
  string hash_on = 9;
  string hash_fallback = 10;
  string hash_on_header = 11;
  string hash_fallback_header = 12;
  string hash_on_cookie = 13;
  string hash_on_cookie_path = 14;
  repeated string tags = 15;
}

message Healthcheck {
  ActiveHealthcheck active = 1;
  PassiveHealthcheck passive = 2;
  double threshold = 3;
}

message ActiveHealthcheck {
  int32 concurrency = 1;
  ActiveHealthy healthy = 2;
  string http_path = 3;
  string https_sni = 4;
  bool https_verify_certificate = 5;
  string type = 6;
  int32 timeout = 7;
  ActiveUnhealthy unhealthy = 8;
}

message PassiveHealthcheck {
  PassiveHealthy healthy = 1;
  string type = 2;
  PassiveUnhealthy unhealthy = 3;
}

message ActiveHealthy {
  repeated int32 http_statuses = 1;
  int32 interval = 2;
  int32 successes = 3;
}

message ActiveUnhealthy {
  int32 http_failures = 1;
  repeated int32 http_statuses = 2;
  int32 tcp_failures = 3;
  int32 timeouts = 4;
  int32 interval = 5;
}

message PassiveHealthy {
  repeated int32 http_statuses = 1;
  int32 successes = 2;
}

message PassiveUnhealthy {
  int32 http_failures = 1;
  repeated int32 http_statuses = 2;
  int32 tcp_failures = 3;
  int32 timeouts = 4;
}
