syntax = "proto3";

package golem.worker;

import "golem/common/account_id.proto";
import "golem/common/project_id.proto";
import "golem/common/plugin_installation_id.proto";
import "golem/worker/worker_id.proto";
import "golem/worker/worker_status.proto";
import "google/protobuf/timestamp.proto";

message WorkerMetadata {
  WorkerId worker_id = 1;
  golem.common.AccountId created_by = 2;
  repeated string args = 3;
  map<string, string> env = 4;
  WorkerStatus status = 5;
  uint64 component_version = 6;
  uint64 retry_count = 7;
  uint64 pending_invocation_count = 8;
  repeated UpdateRecord updates = 9;
  google.protobuf.Timestamp created_at = 10;
  optional string last_error = 11;
  uint64 component_size = 12;
  uint64 total_linear_memory_size = 13;
  map<uint64, ResourceMetadata> owned_resources = 14;
  repeated golem.common.PluginInstallationId active_plugins = 15;
  repeated OplogRegion skipped_regions = 16;
  repeated OplogRegion deleted_regions = 17;
  golem.common.ProjectId project_id = 18;
}

message UpdateRecord {
  google.protobuf.Timestamp timestamp = 1;
  uint64 target_version = 2;
  oneof update {
    PendingUpdate pending = 3;
    FailedUpdate failed = 4;
    SuccessfulUpdate successful = 5;
  }
}

message PendingUpdate {
}

message FailedUpdate {
  optional string details = 3;
}

message SuccessfulUpdate {
}

message ResourceMetadata {
  google.protobuf.Timestamp created_at = 1;
  optional IndexedResourceMetadata indexed = 2;
}

message IndexedResourceMetadata {
  string resource_name = 1;
  repeated string resource_params = 2;
}

message OplogRegion {
  uint64 start = 1;
  uint64 end = 2;
}