syntax = "proto3";

package flyteidl.core;

option go_package = "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core";

import "flyteidl/core/identifier.proto";

// Indicates the status of CatalogCaching. The reason why this is not embedded in TaskNodeMetadata is, that we may use for other types of nodes as well in the future
enum CatalogCacheStatus {
  // Used to indicate that caching was disabled
  CACHE_DISABLED = 0;
  // Used to indicate that the cache lookup resulted in no matches
  CACHE_MISS = 1;
  // used to indicate that the associated artifact was a result of a previous execution
  CACHE_HIT = 2;
  // used to indicate that the resultant artifact was added to the cache
  CACHE_POPULATED = 3;
  // Used to indicate that cache lookup failed because of an error
  CACHE_LOOKUP_FAILURE = 4;
  // Used to indicate that cache lookup failed because of an error
  CACHE_PUT_FAILURE = 5;
  // Used to indicate the cache lookup was skipped
  CACHE_SKIPPED = 6;
  // Used to indicate that the cache was evicted
  CACHE_EVICTED = 7;
};

message CatalogArtifactTag {
     // Artifact ID is generated name
     string artifact_id = 1;
     // Flyte computes the tag automatically, as the hash of the values
     string name = 2;
};

// Catalog artifact information with specific metadata
message CatalogMetadata {
    // Dataset ID in the catalog
    Identifier dataset_id = 1;
    // Artifact tag in the catalog
    CatalogArtifactTag artifact_tag = 2;
    // Optional: Source Execution identifier, if this dataset was generated by another execution in Flyte. This is a one-of field and will depend on the caching context
    oneof source_execution {
       // Today we only support TaskExecutionIdentifier as a source, as catalog caching only works for task executions
       TaskExecutionIdentifier source_task_execution = 3;
    }
};

message CatalogReservation {
    // Indicates the status of a catalog reservation operation.
    enum Status {
      // Used to indicate that reservations are disabled
      RESERVATION_DISABLED = 0;
      // Used to indicate that a reservation was successfully acquired or extended
      RESERVATION_ACQUIRED = 1;
      // Used to indicate that an active reservation currently exists
      RESERVATION_EXISTS = 2;
      // Used to indicate that the reservation has been successfully released
      RESERVATION_RELEASED = 3;
      // Used to indicate that a reservation operation resulted in failure
      RESERVATION_FAILURE = 4;
    }
}
