syntax = "proto3";

package devvit.orchestrator;

option go_package = "github.snooguts.net/reddit/reddit-devplatform-monorepo/go-common/generated/protos/types/devvit/orchestrator";
option java_package = "com.reddit.devvit.orchestrator";

// ComputeCluster represents the compute infrastructure cluster where an app
// installation runs.
enum ComputeCluster {
  // Unspecified cluster. The orchestrator treats this as ELYSIUM_GCP.
  COMPUTE_CLUSTER_UNSPECIFIED = 0;
  // devvit-compute-go runtime.
  COMPUTE_GO = 1;
  // Elysium production runtime, apps on GCP.
  ELYSIUM_GCP = 2;
  // devvit-compute-go staging runtime.
  COMPUTE_GO_STAGING = 3;
  // Elysium staging runtime, apps on GCP.
  ELYSIUM_GCP_STAGING = 4;
}

message SetDeploymentRequest {
  string installation_id = 1;
  // The source code to deploy. Currently, we only support deploying a linked bundle from cloud storage,
  // but in the future we may support other sources like a Docker image.
  oneof source {
    // A URL to a linked bundle to deploy. This is typically an S3 or GCS URL.
    string linked_bundle_url = 2;
  }
  // The compute cluster that should receive this deployment.
  // Example: ELYSIUM_GCP.
  ComputeCluster compute_cluster = 3;
}

message SetDeploymentResponse {
  // Clients can access the deployed application at this URL.
  string url = 1;
}

message DeleteDeploymentRequest {
  string installation_id = 1;
  // The compute cluster where this deployment should be deleted.
  // Example: ELYSIUM_GCP_STAGING.
  ComputeCluster compute_cluster = 2;
}

message DeleteDeploymentResponse {}

// Orchestrator service is for preparing a Devvit app to serve requests for a given installation.
// Orchestrators should be one-to-one with hosting environments, and should manage what apps exist
// in that environment.
service Orchestrator {
  rpc SetDeployment(SetDeploymentRequest) returns (SetDeploymentResponse);
  rpc DeleteDeployment(DeleteDeploymentRequest) returns (DeleteDeploymentResponse);
}
