syntax = "proto3";

package golem.worker.v1;

import "golem/worker/promise_id.proto";
import "golem/shardmanager/shard_id.proto";
import "golem/component/component_id.proto";
import "golem/worker/worker_id.proto";
import "golem/worker/worker_error.proto";

message WorkerExecutionError {
  oneof error {
    InvalidRequest invalid_request = 1;
    WorkerAlreadyExists worker_already_exists = 2;
    WorkerCreationFailed worker_creation_failed = 3;
    FailedToResumeWorker failed_to_resume_worker = 4;
    ComponentDownloadFailed component_download_failed = 5;
    ComponentParseFailed component_parse_failed = 6;
    GetLatestVersionOfComponentFailed get_latest_version_of_component_failed = 7;
    PromiseNotFound promise_not_found = 8;
    PromiseDropped promise_dropped = 9;
    PromiseAlreadyCompleted promise_already_completed = 10;
    Interrupted interrupted = 11;
    ParamTypeMismatch param_type_mismatch = 12;
    NoValueInMessage no_value_in_message = 13;
    ValueMismatch value_mismatch = 14;
    UnexpectedOplogEntry unexpected_oplog_entry = 15;
    RuntimeError runtime_error = 16;
    InvalidShardId invalid_shard_id = 17;
    PreviousInvocationFailed previous_invocation_failed = 18;
    UnknownError unknown = 19;
    PreviousInvocationExited previous_invocation_exited = 20;
    InvalidAccount invalid_account = 21;
    WorkerNotFound worker_not_found = 22;
    ShardingNotReady sharding_not_ready = 23;
    InitialComponentFileDownloadFailed initial_component_file_download_failed = 24;
    FileSystemError file_system_error = 25;
    InvocationFailed invocation_failed = 26;
  }
}

message InvalidRequest {
  string details = 1;
}

message WorkerAlreadyExists {
  WorkerId worker_id = 1;
}

message WorkerCreationFailed {
  WorkerId worker_id = 1;
  string details = 2;
}

message FailedToResumeWorker {
  WorkerId worker_id = 1;
  WorkerExecutionError reason = 2;
}

message ComponentDownloadFailed {
  golem.component.ComponentId component_id = 1;
  uint64 component_version = 2;
  string reason = 3;
}

message ComponentParseFailed {
  golem.component.ComponentId component_id = 1;
  uint64 component_version = 2;
  string reason = 3;
}

message GetLatestVersionOfComponentFailed {
  golem.component.ComponentId component_id = 1;
  string reason = 2;
}

message PromiseNotFound {
  PromiseId promise_id = 1;
}

message PromiseDropped {
  PromiseId promise_id = 1;
}

message PromiseAlreadyCompleted {
  PromiseId promise_id = 1;
}

message Interrupted {
  bool recover_immediately = 1;
}

message ParamTypeMismatch {
  string details = 1;
}

message NoValueInMessage {}

message ValueMismatch {
  string details = 1;
}

message UnexpectedOplogEntry {
  string expected = 1;
  string got = 2;
}

message RuntimeError {
  string details = 1;
}

message InvalidShardId {
  golem.shardmanager.ShardId shard_id = 1;
  repeated golem.shardmanager.ShardId shard_ids = 2;
}

message PreviousInvocationFailed {
  WorkerError error = 1;
  string stderr = 2;
}

message PreviousInvocationExited {}

message InvalidAccount {}

message UnknownError {
  string details = 1;
}

message WorkerNotFound {
  WorkerId worker_id = 1;
}

message ShardingNotReady {}

message InitialComponentFileDownloadFailed {
  string path = 1;
  string reason = 2;
}

message FileSystemError {
  string path = 1;
  string reason = 2;
}

message InvocationFailed {
  WorkerError error = 1;
  string stderr = 2;
}
