Implemented working runner api (fixes #1)

This commit is contained in:
restitux 2023-01-09 00:43:34 -07:00
parent 433b827cdd
commit e20285fe6c
2 changed files with 249 additions and 23 deletions

View File

@ -10,6 +10,7 @@ message Register {
message RunCommand {
string command = 1;
repeated string args = 2;
}
message RunCommandPartialResponse {
@ -21,3 +22,16 @@ message RunCommandFinalResponse {
int64 return_code = 1;
RunCommandPartialResponse partial_response = 2;
}
message ServerToRunnerMsg {
oneof msg {
RunCommand RunCommandMsg = 1;
}
}
message RunnerToServerMsg {
oneof msg {
RunCommandPartialResponse RunCommandPartialResponseMsg = 1;
RunCommandFinalResponse RunCommandFinalResponseMsg = 2;
}
}

View File

@ -88,7 +88,8 @@ type RunCommand struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"`
Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"`
Args []string `protobuf:"bytes,2,rep,name=args,proto3" json:"args,omitempty"`
}
func (x *RunCommand) Reset() {
@ -130,6 +131,13 @@ func (x *RunCommand) GetCommand() string {
return ""
}
func (x *RunCommand) GetArgs() []string {
if x != nil {
return x.Args
}
return nil
}
type RunCommandPartialResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -240,6 +248,154 @@ func (x *RunCommandFinalResponse) GetPartialResponse() *RunCommandPartialRespons
return nil
}
type ServerToRunnerMsg struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Types that are assignable to Msg:
//
// *ServerToRunnerMsg_RunCommandMsg
Msg isServerToRunnerMsg_Msg `protobuf_oneof:"msg"`
}
func (x *ServerToRunnerMsg) Reset() {
*x = ServerToRunnerMsg{}
if protoimpl.UnsafeEnabled {
mi := &file_api_v2_api_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ServerToRunnerMsg) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ServerToRunnerMsg) ProtoMessage() {}
func (x *ServerToRunnerMsg) ProtoReflect() protoreflect.Message {
mi := &file_api_v2_api_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ServerToRunnerMsg.ProtoReflect.Descriptor instead.
func (*ServerToRunnerMsg) Descriptor() ([]byte, []int) {
return file_api_v2_api_proto_rawDescGZIP(), []int{4}
}
func (m *ServerToRunnerMsg) GetMsg() isServerToRunnerMsg_Msg {
if m != nil {
return m.Msg
}
return nil
}
func (x *ServerToRunnerMsg) GetRunCommandMsg() *RunCommand {
if x, ok := x.GetMsg().(*ServerToRunnerMsg_RunCommandMsg); ok {
return x.RunCommandMsg
}
return nil
}
type isServerToRunnerMsg_Msg interface {
isServerToRunnerMsg_Msg()
}
type ServerToRunnerMsg_RunCommandMsg struct {
RunCommandMsg *RunCommand `protobuf:"bytes,1,opt,name=RunCommandMsg,proto3,oneof"`
}
func (*ServerToRunnerMsg_RunCommandMsg) isServerToRunnerMsg_Msg() {}
type RunnerToServerMsg struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Types that are assignable to Msg:
//
// *RunnerToServerMsg_RunCommandPartialResponseMsg
// *RunnerToServerMsg_RunCommandFinalResponseMsg
Msg isRunnerToServerMsg_Msg `protobuf_oneof:"msg"`
}
func (x *RunnerToServerMsg) Reset() {
*x = RunnerToServerMsg{}
if protoimpl.UnsafeEnabled {
mi := &file_api_v2_api_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RunnerToServerMsg) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RunnerToServerMsg) ProtoMessage() {}
func (x *RunnerToServerMsg) ProtoReflect() protoreflect.Message {
mi := &file_api_v2_api_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RunnerToServerMsg.ProtoReflect.Descriptor instead.
func (*RunnerToServerMsg) Descriptor() ([]byte, []int) {
return file_api_v2_api_proto_rawDescGZIP(), []int{5}
}
func (m *RunnerToServerMsg) GetMsg() isRunnerToServerMsg_Msg {
if m != nil {
return m.Msg
}
return nil
}
func (x *RunnerToServerMsg) GetRunCommandPartialResponseMsg() *RunCommandPartialResponse {
if x, ok := x.GetMsg().(*RunnerToServerMsg_RunCommandPartialResponseMsg); ok {
return x.RunCommandPartialResponseMsg
}
return nil
}
func (x *RunnerToServerMsg) GetRunCommandFinalResponseMsg() *RunCommandFinalResponse {
if x, ok := x.GetMsg().(*RunnerToServerMsg_RunCommandFinalResponseMsg); ok {
return x.RunCommandFinalResponseMsg
}
return nil
}
type isRunnerToServerMsg_Msg interface {
isRunnerToServerMsg_Msg()
}
type RunnerToServerMsg_RunCommandPartialResponseMsg struct {
RunCommandPartialResponseMsg *RunCommandPartialResponse `protobuf:"bytes,1,opt,name=RunCommandPartialResponseMsg,proto3,oneof"`
}
type RunnerToServerMsg_RunCommandFinalResponseMsg struct {
RunCommandFinalResponseMsg *RunCommandFinalResponse `protobuf:"bytes,2,opt,name=RunCommandFinalResponseMsg,proto3,oneof"`
}
func (*RunnerToServerMsg_RunCommandPartialResponseMsg) isRunnerToServerMsg_Msg() {}
func (*RunnerToServerMsg_RunCommandFinalResponseMsg) isRunnerToServerMsg_Msg() {}
var File_api_v2_api_proto protoreflect.FileDescriptor
var file_api_v2_api_proto_rawDesc = []byte{
@ -248,23 +404,43 @@ var file_api_v2_api_proto_rawDesc = []byte{
0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x03,
0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x22, 0x26, 0x0a, 0x0a, 0x52, 0x75,
0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x22, 0x3a, 0x0a, 0x0a, 0x52, 0x75,
0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d,
0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61,
0x6e, 0x64, 0x22, 0x4b, 0x0a, 0x19, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64,
0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x16, 0x0a, 0x06, 0x73, 0x74, 0x64, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x73, 0x74, 0x64, 0x6f, 0x75, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x64, 0x65, 0x72,
0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x64, 0x65, 0x72, 0x72, 0x22,
0x81, 0x01, 0x0a, 0x17, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x46, 0x69,
0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x72,
0x65, 0x74, 0x75, 0x72, 0x6e, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
0x52, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x45, 0x0a, 0x10,
0x70, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6d, 0x6d,
0x61, 0x6e, 0x64, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x52, 0x0f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x2e, 0x6f, 0x68, 0x65, 0x61, 0x2e,
0x6e, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x72, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09,
0x52, 0x04, 0x61, 0x72, 0x67, 0x73, 0x22, 0x4b, 0x0a, 0x19, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6d,
0x6d, 0x61, 0x6e, 0x64, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x64, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x64, 0x6f, 0x75, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73,
0x74, 0x64, 0x65, 0x72, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x64,
0x65, 0x72, 0x72, 0x22, 0x81, 0x01, 0x0a, 0x17, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x61,
0x6e, 0x64, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x43, 0x6f, 0x64, 0x65,
0x12, 0x45, 0x0a, 0x10, 0x70, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x52, 0x75, 0x6e,
0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x4f, 0x0a, 0x11, 0x53, 0x65, 0x72, 0x76, 0x65,
0x72, 0x54, 0x6f, 0x52, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x33, 0x0a, 0x0d,
0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4d, 0x73, 0x67, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64,
0x48, 0x00, 0x52, 0x0d, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4d, 0x73,
0x67, 0x42, 0x05, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x22, 0xd8, 0x01, 0x0a, 0x11, 0x52, 0x75, 0x6e,
0x6e, 0x65, 0x72, 0x54, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x60,
0x0a, 0x1c, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x61, 0x72, 0x74,
0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x73, 0x67, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
0x64, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x48, 0x00, 0x52, 0x1c, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x61,
0x72, 0x74, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x73, 0x67,
0x12, 0x5a, 0x0a, 0x1a, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x46, 0x69,
0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x73, 0x67, 0x18, 0x02,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
0x64, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00,
0x52, 0x1a, 0x52, 0x75, 0x6e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x46, 0x69, 0x6e, 0x61,
0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x73, 0x67, 0x42, 0x05, 0x0a, 0x03,
0x6d, 0x73, 0x67, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x2e, 0x6f, 0x68, 0x65, 0x61, 0x2e,
0x78, 0x79, 0x7a, 0x2f, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x69, 0x75, 0x73, 0x2f, 0x72, 0x75,
0x6e, 0x6e, 0x65, 0x72, 0x2d, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f,
0x76, 0x32, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
@ -282,20 +458,25 @@ func file_api_v2_api_proto_rawDescGZIP() []byte {
return file_api_v2_api_proto_rawDescData
}
var file_api_v2_api_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_api_v2_api_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_api_v2_api_proto_goTypes = []interface{}{
(*Register)(nil), // 0: Register
(*RunCommand)(nil), // 1: RunCommand
(*RunCommandPartialResponse)(nil), // 2: RunCommandPartialResponse
(*RunCommandFinalResponse)(nil), // 3: RunCommandFinalResponse
(*ServerToRunnerMsg)(nil), // 4: ServerToRunnerMsg
(*RunnerToServerMsg)(nil), // 5: RunnerToServerMsg
}
var file_api_v2_api_proto_depIdxs = []int32{
2, // 0: RunCommandFinalResponse.partial_response:type_name -> RunCommandPartialResponse
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
1, // 1: ServerToRunnerMsg.RunCommandMsg:type_name -> RunCommand
2, // 2: RunnerToServerMsg.RunCommandPartialResponseMsg:type_name -> RunCommandPartialResponse
3, // 3: RunnerToServerMsg.RunCommandFinalResponseMsg:type_name -> RunCommandFinalResponse
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_api_v2_api_proto_init() }
@ -352,6 +533,37 @@ func file_api_v2_api_proto_init() {
return nil
}
}
file_api_v2_api_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ServerToRunnerMsg); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_v2_api_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RunnerToServerMsg); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_api_v2_api_proto_msgTypes[4].OneofWrappers = []interface{}{
(*ServerToRunnerMsg_RunCommandMsg)(nil),
}
file_api_v2_api_proto_msgTypes[5].OneofWrappers = []interface{}{
(*RunnerToServerMsg_RunCommandPartialResponseMsg)(nil),
(*RunnerToServerMsg_RunCommandFinalResponseMsg)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -359,7 +571,7 @@ func file_api_v2_api_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_api_v2_api_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumMessages: 6,
NumExtensions: 0,
NumServices: 0,
},