ya-runtime-api 0.7.0

Communication API between the Runtime and ExeUnit Supervisor. Provides server implementation for Runtime and client implementation for Supervisor.
Documentation
syntax = "proto3";
package ya_runtime_api;

message Request {
    uint64 id = 1;

    oneof command {
        Hello hello = 2;
        RunProcess run = 10;
        KillProcess kill = 11;
        Shutdown shutdown = 12;
        CreateNetwork network = 30;
    }

    message Hello {
        string version = 1;
    }

    message RunProcess {
        string bin = 1;
        repeated string args = 2;
        string work_dir = 3;
        Output stdout = 4;
        Output stderr = 5;
    }

    message KillProcess {
        uint64 pid = 1;
        int32 signal = 2;
    }

    message CreateNetwork {
        repeated Network networks = 1;
        map<string, string> hosts = 2;
        NetworkInterface interface = 3;
    }

    message Shutdown {}
}

message Response {
    // if false then id represents correlation id for response message.
    bool event = 1;
    uint64 id = 2;

    oneof command {
        Error error = 3;
        Hello hello = 4;
        RunProcess run = 10;
        KillProcess kill = 11;
        Shutdown shutdown = 12;

        // Events
        ProcessStatus status = 20;
        RuntimeStatus rt_status = 21;

        // Network ctl
        CreateNetwork network = 30;
    }

    message Hello {
        string version = 1;
    }

    enum ErrorCode {
        INTERNAL = 0;
        NOT_FOUND = 1;
        BAD_REQUEST = 2;
    }

    message Error {
        ErrorCode code = 1;
        string message = 2;
        map<string, string> context = 3;
    }

    message RunProcess {
        uint64 pid = 1;
    }

    message KillProcess {}

    message ProcessStatus {
        uint64 pid = 1;
        bool running = 2;
        int32 return_code = 3;
        bytes stdout = 4;
        bytes stderr = 5;
    }

    message RuntimeStatus {
        message State {
            string name = 1;
            bytes value = 2;
        }

        message Counter {
            string name = 1;
            double value = 2;
        }

        oneof kind {
            State state = 1;
            Counter counter = 2;
        }
    }

    message CreateNetwork {
        oneof endpoint {
            string unix_stream = 1;
            string unix_datagram = 2;
            string udp_datagram = 3;
            string tcp_listener = 4;
            string tcp_stream = 5;
        }
    }

    message Shutdown {}
}

message Network {
    string addr = 1;
    string gateway = 2;
    string mask = 3;
    string if_addr = 4;
}

enum NetworkInterface {
    VPN = 0;
    INET = 1;
}

message Output {
    // No-type = /dev/null
    // at_end(buffer size) = last n bytes are returned.
    oneof type {
        uint32 at_end = 2;
    }
}