mirror of
https://github.com/criyle/go-judge.git
synced 2025-09-26 22:39:12 +08:00
shell: support cancel with double ctrl-c
This commit is contained in:
parent
010c30f85e
commit
cb1256f4bf
@ -12,7 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/criyle/go-judge/pb"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
)
|
||||
@ -107,11 +107,11 @@ func run(sc pb.Executor_ExecStreamClient, args []string) (*pb.Response, error) {
|
||||
}
|
||||
|
||||
// Set stdin in raw mode.
|
||||
oldState, err := terminal.MakeRaw(int(os.Stdin.Fd()))
|
||||
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer func() { _ = terminal.Restore(int(os.Stdin.Fd()), oldState) }() // Best effort.
|
||||
defer func() { _ = term.Restore(int(os.Stdin.Fd()), oldState) }() // Best effort.
|
||||
|
||||
// pump msg
|
||||
sendCh := make(chan *pb.StreamRequest, 64)
|
||||
@ -127,6 +127,7 @@ func run(sc pb.Executor_ExecStreamClient, args []string) (*pb.Response, error) {
|
||||
}()
|
||||
|
||||
// pump stdin
|
||||
forceQuit := false
|
||||
go func() {
|
||||
buf := make([]byte, 4096)
|
||||
for {
|
||||
@ -142,6 +143,17 @@ func run(sc pb.Executor_ExecStreamClient, args []string) (*pb.Response, error) {
|
||||
}
|
||||
continue
|
||||
}
|
||||
if n == 1 && buf[0] == 3 {
|
||||
if forceQuit {
|
||||
sendCh <- &pb.StreamRequest{
|
||||
Request: &pb.StreamRequest_ExecCancel{},
|
||||
}
|
||||
}
|
||||
forceQuit = true
|
||||
} else {
|
||||
forceQuit = false
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Println("stdin", err)
|
||||
return
|
||||
|
@ -55,6 +55,8 @@ func (sw *streamWrapper) Recv() (*stream.StreamRequest, error) {
|
||||
X: int(i.ExecResize.X),
|
||||
Y: int(i.ExecResize.Y),
|
||||
}}, nil
|
||||
case *pb.StreamRequest_ExecCancel:
|
||||
return &stream.StreamRequest{Cancel: &struct{}{}}, nil
|
||||
}
|
||||
return nil, errors.ErrUnsupported
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ type StreamRequest struct {
|
||||
Request *model.Request
|
||||
Resize *ResizeRequest
|
||||
Input *InputRequest
|
||||
Cancel *bool
|
||||
Cancel *struct{}
|
||||
}
|
||||
|
||||
type StreamResponse struct {
|
||||
|
4
go.mod
4
go.mod
@ -19,10 +19,10 @@ require (
|
||||
github.com/prometheus/client_golang v1.18.0
|
||||
github.com/zsais/go-gin-prometheus v0.1.0
|
||||
go.uber.org/zap v1.26.0
|
||||
golang.org/x/crypto v0.18.0
|
||||
golang.org/x/net v0.20.0
|
||||
golang.org/x/sync v0.6.0
|
||||
golang.org/x/sys v0.16.0
|
||||
golang.org/x/term v0.16.0
|
||||
google.golang.org/grpc v1.61.0
|
||||
google.golang.org/protobuf v1.32.0
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
@ -59,7 +59,7 @@ require (
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/arch v0.7.0 // indirect
|
||||
golang.org/x/term v0.16.0 // indirect
|
||||
golang.org/x/crypto v0.18.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
251
pb/judge.pb.go
251
pb/judge.pb.go
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc v3.21.12
|
||||
// source: judge.proto
|
||||
|
||||
@ -458,6 +458,7 @@ type StreamRequest struct {
|
||||
// *StreamRequest_ExecRequest
|
||||
// *StreamRequest_ExecInput
|
||||
// *StreamRequest_ExecResize
|
||||
// *StreamRequest_ExecCancel
|
||||
Request isStreamRequest_Request `protobuf_oneof:"request"`
|
||||
}
|
||||
|
||||
@ -521,6 +522,13 @@ func (x *StreamRequest) GetExecResize() *StreamRequest_Resize {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *StreamRequest) GetExecCancel() *StreamRequest_Cancel {
|
||||
if x, ok := x.GetRequest().(*StreamRequest_ExecCancel); ok {
|
||||
return x.ExecCancel
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isStreamRequest_Request interface {
|
||||
isStreamRequest_Request()
|
||||
}
|
||||
@ -537,12 +545,18 @@ type StreamRequest_ExecResize struct {
|
||||
ExecResize *StreamRequest_Resize `protobuf:"bytes,3,opt,name=execResize,proto3,oneof"`
|
||||
}
|
||||
|
||||
type StreamRequest_ExecCancel struct {
|
||||
ExecCancel *StreamRequest_Cancel `protobuf:"bytes,4,opt,name=execCancel,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*StreamRequest_ExecRequest) isStreamRequest_Request() {}
|
||||
|
||||
func (*StreamRequest_ExecInput) isStreamRequest_Request() {}
|
||||
|
||||
func (*StreamRequest_ExecResize) isStreamRequest_Request() {}
|
||||
|
||||
func (*StreamRequest_ExecCancel) isStreamRequest_Request() {}
|
||||
|
||||
type StreamResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@ -1749,6 +1763,44 @@ func (x *StreamRequest_Resize) GetY() uint32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
type StreamRequest_Cancel struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *StreamRequest_Cancel) Reset() {
|
||||
*x = StreamRequest_Cancel{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_judge_proto_msgTypes[27]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *StreamRequest_Cancel) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*StreamRequest_Cancel) ProtoMessage() {}
|
||||
|
||||
func (x *StreamRequest_Cancel) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_judge_proto_msgTypes[27]
|
||||
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 StreamRequest_Cancel.ProtoReflect.Descriptor instead.
|
||||
func (*StreamRequest_Cancel) Descriptor() ([]byte, []int) {
|
||||
return file_judge_proto_rawDescGZIP(), []int{5, 2}
|
||||
}
|
||||
|
||||
type StreamResponse_Output struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@ -1761,7 +1813,7 @@ type StreamResponse_Output struct {
|
||||
func (x *StreamResponse_Output) Reset() {
|
||||
*x = StreamResponse_Output{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_judge_proto_msgTypes[27]
|
||||
mi := &file_judge_proto_msgTypes[28]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1774,7 +1826,7 @@ func (x *StreamResponse_Output) String() string {
|
||||
func (*StreamResponse_Output) ProtoMessage() {}
|
||||
|
||||
func (x *StreamResponse_Output) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_judge_proto_msgTypes[27]
|
||||
mi := &file_judge_proto_msgTypes[28]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -2018,7 +2070,7 @@ var file_judge_proto_rawDesc = []byte{
|
||||
0x4a, 0x75, 0x64, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x10,
|
||||
0x0b, 0x12, 0x16, 0x0a, 0x12, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x49, 0x6e, 0x74, 0x65,
|
||||
0x72, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x0c, 0x12, 0x11, 0x0a, 0x0d, 0x49, 0x6e, 0x74,
|
||||
0x65, 0x72, 0x6e, 0x61, 0x6c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x0d, 0x22, 0xd9, 0x02, 0x0a,
|
||||
0x65, 0x72, 0x6e, 0x61, 0x6c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x0d, 0x22, 0x9f, 0x03, 0x0a,
|
||||
0x0d, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2f,
|
||||
0x0a, 0x0b, 0x65, 0x78, 0x65, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
@ -2030,50 +2082,54 @@ var file_judge_proto_rawDesc = []byte{
|
||||
0x52, 0x65, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70,
|
||||
0x62, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e,
|
||||
0x52, 0x65, 0x73, 0x69, 0x7a, 0x65, 0x48, 0x00, 0x52, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x52, 0x65,
|
||||
0x73, 0x69, 0x7a, 0x65, 0x1a, 0x35, 0x0a, 0x05, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d,
|
||||
0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x1a, 0x60, 0x0a, 0x06, 0x52,
|
||||
0x65, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x77,
|
||||
0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x63, 0x6f, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x63, 0x6f, 0x6c,
|
||||
0x73, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x01, 0x78, 0x12,
|
||||
0x0c, 0x0a, 0x01, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x01, 0x79, 0x42, 0x09, 0x0a,
|
||||
0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xc5, 0x01, 0x0a, 0x0e, 0x53, 0x74, 0x72,
|
||||
0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x0c, 0x65,
|
||||
0x78, 0x65, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48,
|
||||
0x00, 0x52, 0x0c, 0x65, 0x78, 0x65, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
|
||||
0x3b, 0x0a, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x48, 0x00,
|
||||
0x52, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x1a, 0x36, 0x0a, 0x06,
|
||||
0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f,
|
||||
0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e,
|
||||
0x74, 0x65, 0x6e, 0x74, 0x42, 0x0a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x32, 0x9e, 0x02, 0x0a, 0x08, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x12, 0x21, 0x0a,
|
||||
0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x0b, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x12, 0x37, 0x0a, 0x0a, 0x45, 0x78, 0x65, 0x63, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x11,
|
||||
0x2e, 0x70, 0x62, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x74, 0x1a, 0x12, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x12, 0x34, 0x0a, 0x08, 0x46, 0x69, 0x6c,
|
||||
0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x10, 0x2e,
|
||||
0x70, 0x62, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12,
|
||||
0x26, 0x0a, 0x07, 0x46, 0x69, 0x6c, 0x65, 0x47, 0x65, 0x74, 0x12, 0x0a, 0x2e, 0x70, 0x62, 0x2e,
|
||||
0x46, 0x69, 0x6c, 0x65, 0x49, 0x44, 0x1a, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6c, 0x65,
|
||||
0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x07, 0x46, 0x69, 0x6c, 0x65, 0x41,
|
||||
0x64, 0x64, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x74,
|
||||
0x65, 0x6e, 0x74, 0x1a, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x49, 0x44, 0x12,
|
||||
0x30, 0x0a, 0x0a, 0x46, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x0a, 0x2e,
|
||||
0x70, 0x62, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x49, 0x44, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
|
||||
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74,
|
||||
0x79, 0x42, 0x1f, 0x5a, 0x1d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
|
||||
0x63, 0x72, 0x69, 0x79, 0x6c, 0x65, 0x2f, 0x67, 0x6f, 0x2d, 0x6a, 0x75, 0x64, 0x67, 0x65, 0x2f,
|
||||
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x73, 0x69, 0x7a, 0x65, 0x12, 0x3a, 0x0a, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x43, 0x61, 0x6e, 0x63,
|
||||
0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x74,
|
||||
0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x43, 0x61, 0x6e, 0x63,
|
||||
0x65, 0x6c, 0x48, 0x00, 0x52, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c,
|
||||
0x1a, 0x35, 0x0a, 0x05, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d,
|
||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a,
|
||||
0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07,
|
||||
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x1a, 0x60, 0x0a, 0x06, 0x52, 0x65, 0x73, 0x69, 0x7a,
|
||||
0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x0d, 0x52, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x6c,
|
||||
0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x63, 0x6f, 0x6c, 0x73, 0x12, 0x0c, 0x0a,
|
||||
0x01, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79,
|
||||
0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x01, 0x79, 0x1a, 0x08, 0x0a, 0x06, 0x43, 0x61, 0x6e,
|
||||
0x63, 0x65, 0x6c, 0x42, 0x09, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xc5,
|
||||
0x01, 0x0a, 0x0e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x12, 0x32, 0x0a, 0x0c, 0x65, 0x78, 0x65, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x0c, 0x65, 0x78, 0x65, 0x63, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x4f, 0x75, 0x74,
|
||||
0x70, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x53,
|
||||
0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x4f, 0x75,
|
||||
0x74, 0x70, 0x75, 0x74, 0x48, 0x00, 0x52, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x4f, 0x75, 0x74, 0x70,
|
||||
0x75, 0x74, 0x1a, 0x36, 0x0a, 0x06, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65,
|
||||
0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x42, 0x0a, 0x0a, 0x08, 0x72, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x9e, 0x02, 0x0a, 0x08, 0x45, 0x78, 0x65, 0x63, 0x75,
|
||||
0x74, 0x6f, 0x72, 0x12, 0x21, 0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x0b, 0x2e, 0x70, 0x62,
|
||||
0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x0a, 0x45, 0x78, 0x65, 0x63, 0x53, 0x74,
|
||||
0x72, 0x65, 0x61, 0x6d, 0x12, 0x11, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x74, 0x72,
|
||||
0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x12,
|
||||
0x34, 0x0a, 0x08, 0x46, 0x69, 0x6c, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x6f,
|
||||
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d,
|
||||
0x70, 0x74, 0x79, 0x1a, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x4c, 0x69, 0x73,
|
||||
0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x26, 0x0a, 0x07, 0x46, 0x69, 0x6c, 0x65, 0x47, 0x65, 0x74,
|
||||
0x12, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x49, 0x44, 0x1a, 0x0f, 0x2e, 0x70,
|
||||
0x62, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x26, 0x0a,
|
||||
0x07, 0x46, 0x69, 0x6c, 0x65, 0x41, 0x64, 0x64, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69,
|
||||
0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x1a, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x46,
|
||||
0x69, 0x6c, 0x65, 0x49, 0x44, 0x12, 0x30, 0x0a, 0x0a, 0x46, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x6c,
|
||||
0x65, 0x74, 0x65, 0x12, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x49, 0x44, 0x1a,
|
||||
0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x1f, 0x5a, 0x1d, 0x67, 0x69, 0x74, 0x68, 0x75,
|
||||
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x72, 0x69, 0x79, 0x6c, 0x65, 0x2f, 0x67, 0x6f, 0x2d,
|
||||
0x6a, 0x75, 0x64, 0x67, 0x65, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -2089,7 +2145,7 @@ func file_judge_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_judge_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||
var file_judge_proto_msgTypes = make([]protoimpl.MessageInfo, 28)
|
||||
var file_judge_proto_msgTypes = make([]protoimpl.MessageInfo, 29)
|
||||
var file_judge_proto_goTypes = []interface{}{
|
||||
(Response_FileError_ErrorType)(0), // 0: pb.Response.FileError.ErrorType
|
||||
(Response_Result_StatusType)(0), // 1: pb.Response.Result.StatusType
|
||||
@ -2120,8 +2176,9 @@ var file_judge_proto_goTypes = []interface{}{
|
||||
nil, // 26: pb.Response.Result.FileIDsEntry
|
||||
(*StreamRequest_Input)(nil), // 27: pb.StreamRequest.Input
|
||||
(*StreamRequest_Resize)(nil), // 28: pb.StreamRequest.Resize
|
||||
(*StreamResponse_Output)(nil), // 29: pb.StreamResponse.Output
|
||||
(*emptypb.Empty)(nil), // 30: google.protobuf.Empty
|
||||
(*StreamRequest_Cancel)(nil), // 29: pb.StreamRequest.Cancel
|
||||
(*StreamResponse_Output)(nil), // 30: pb.StreamResponse.Output
|
||||
(*emptypb.Empty)(nil), // 31: google.protobuf.Empty
|
||||
}
|
||||
var file_judge_proto_depIdxs = []int32{
|
||||
9, // 0: pb.FileListType.fileIDs:type_name -> pb.FileListType.FileIDsEntry
|
||||
@ -2131,44 +2188,45 @@ var file_judge_proto_depIdxs = []int32{
|
||||
5, // 4: pb.StreamRequest.execRequest:type_name -> pb.Request
|
||||
27, // 5: pb.StreamRequest.execInput:type_name -> pb.StreamRequest.Input
|
||||
28, // 6: pb.StreamRequest.execResize:type_name -> pb.StreamRequest.Resize
|
||||
6, // 7: pb.StreamResponse.execResponse:type_name -> pb.Response
|
||||
29, // 8: pb.StreamResponse.execOutput:type_name -> pb.StreamResponse.Output
|
||||
10, // 9: pb.Request.File.local:type_name -> pb.Request.LocalFile
|
||||
11, // 10: pb.Request.File.memory:type_name -> pb.Request.MemoryFile
|
||||
12, // 11: pb.Request.File.cached:type_name -> pb.Request.CachedFile
|
||||
13, // 12: pb.Request.File.pipe:type_name -> pb.Request.PipeCollector
|
||||
14, // 13: pb.Request.File.streamIn:type_name -> pb.Request.StreamInput
|
||||
15, // 14: pb.Request.File.streamOut:type_name -> pb.Request.StreamOutput
|
||||
16, // 15: pb.Request.CmdType.files:type_name -> pb.Request.File
|
||||
20, // 16: pb.Request.CmdType.copyIn:type_name -> pb.Request.CmdType.CopyInEntry
|
||||
21, // 17: pb.Request.CmdType.symlinks:type_name -> pb.Request.CmdType.SymlinksEntry
|
||||
18, // 18: pb.Request.CmdType.copyOut:type_name -> pb.Request.CmdCopyOutFile
|
||||
18, // 19: pb.Request.CmdType.copyOutCached:type_name -> pb.Request.CmdCopyOutFile
|
||||
22, // 20: pb.Request.PipeMap.in:type_name -> pb.Request.PipeMap.PipeIndex
|
||||
22, // 21: pb.Request.PipeMap.out:type_name -> pb.Request.PipeMap.PipeIndex
|
||||
16, // 22: pb.Request.CmdType.CopyInEntry.value:type_name -> pb.Request.File
|
||||
0, // 23: pb.Response.FileError.type:type_name -> pb.Response.FileError.ErrorType
|
||||
1, // 24: pb.Response.Result.status:type_name -> pb.Response.Result.StatusType
|
||||
25, // 25: pb.Response.Result.files:type_name -> pb.Response.Result.FilesEntry
|
||||
26, // 26: pb.Response.Result.fileIDs:type_name -> pb.Response.Result.FileIDsEntry
|
||||
23, // 27: pb.Response.Result.fileError:type_name -> pb.Response.FileError
|
||||
5, // 28: pb.Executor.Exec:input_type -> pb.Request
|
||||
7, // 29: pb.Executor.ExecStream:input_type -> pb.StreamRequest
|
||||
30, // 30: pb.Executor.FileList:input_type -> google.protobuf.Empty
|
||||
2, // 31: pb.Executor.FileGet:input_type -> pb.FileID
|
||||
3, // 32: pb.Executor.FileAdd:input_type -> pb.FileContent
|
||||
2, // 33: pb.Executor.FileDelete:input_type -> pb.FileID
|
||||
6, // 34: pb.Executor.Exec:output_type -> pb.Response
|
||||
8, // 35: pb.Executor.ExecStream:output_type -> pb.StreamResponse
|
||||
4, // 36: pb.Executor.FileList:output_type -> pb.FileListType
|
||||
3, // 37: pb.Executor.FileGet:output_type -> pb.FileContent
|
||||
2, // 38: pb.Executor.FileAdd:output_type -> pb.FileID
|
||||
30, // 39: pb.Executor.FileDelete:output_type -> google.protobuf.Empty
|
||||
34, // [34:40] is the sub-list for method output_type
|
||||
28, // [28:34] is the sub-list for method input_type
|
||||
28, // [28:28] is the sub-list for extension type_name
|
||||
28, // [28:28] is the sub-list for extension extendee
|
||||
0, // [0:28] is the sub-list for field type_name
|
||||
29, // 7: pb.StreamRequest.execCancel:type_name -> pb.StreamRequest.Cancel
|
||||
6, // 8: pb.StreamResponse.execResponse:type_name -> pb.Response
|
||||
30, // 9: pb.StreamResponse.execOutput:type_name -> pb.StreamResponse.Output
|
||||
10, // 10: pb.Request.File.local:type_name -> pb.Request.LocalFile
|
||||
11, // 11: pb.Request.File.memory:type_name -> pb.Request.MemoryFile
|
||||
12, // 12: pb.Request.File.cached:type_name -> pb.Request.CachedFile
|
||||
13, // 13: pb.Request.File.pipe:type_name -> pb.Request.PipeCollector
|
||||
14, // 14: pb.Request.File.streamIn:type_name -> pb.Request.StreamInput
|
||||
15, // 15: pb.Request.File.streamOut:type_name -> pb.Request.StreamOutput
|
||||
16, // 16: pb.Request.CmdType.files:type_name -> pb.Request.File
|
||||
20, // 17: pb.Request.CmdType.copyIn:type_name -> pb.Request.CmdType.CopyInEntry
|
||||
21, // 18: pb.Request.CmdType.symlinks:type_name -> pb.Request.CmdType.SymlinksEntry
|
||||
18, // 19: pb.Request.CmdType.copyOut:type_name -> pb.Request.CmdCopyOutFile
|
||||
18, // 20: pb.Request.CmdType.copyOutCached:type_name -> pb.Request.CmdCopyOutFile
|
||||
22, // 21: pb.Request.PipeMap.in:type_name -> pb.Request.PipeMap.PipeIndex
|
||||
22, // 22: pb.Request.PipeMap.out:type_name -> pb.Request.PipeMap.PipeIndex
|
||||
16, // 23: pb.Request.CmdType.CopyInEntry.value:type_name -> pb.Request.File
|
||||
0, // 24: pb.Response.FileError.type:type_name -> pb.Response.FileError.ErrorType
|
||||
1, // 25: pb.Response.Result.status:type_name -> pb.Response.Result.StatusType
|
||||
25, // 26: pb.Response.Result.files:type_name -> pb.Response.Result.FilesEntry
|
||||
26, // 27: pb.Response.Result.fileIDs:type_name -> pb.Response.Result.FileIDsEntry
|
||||
23, // 28: pb.Response.Result.fileError:type_name -> pb.Response.FileError
|
||||
5, // 29: pb.Executor.Exec:input_type -> pb.Request
|
||||
7, // 30: pb.Executor.ExecStream:input_type -> pb.StreamRequest
|
||||
31, // 31: pb.Executor.FileList:input_type -> google.protobuf.Empty
|
||||
2, // 32: pb.Executor.FileGet:input_type -> pb.FileID
|
||||
3, // 33: pb.Executor.FileAdd:input_type -> pb.FileContent
|
||||
2, // 34: pb.Executor.FileDelete:input_type -> pb.FileID
|
||||
6, // 35: pb.Executor.Exec:output_type -> pb.Response
|
||||
8, // 36: pb.Executor.ExecStream:output_type -> pb.StreamResponse
|
||||
4, // 37: pb.Executor.FileList:output_type -> pb.FileListType
|
||||
3, // 38: pb.Executor.FileGet:output_type -> pb.FileContent
|
||||
2, // 39: pb.Executor.FileAdd:output_type -> pb.FileID
|
||||
31, // 40: pb.Executor.FileDelete:output_type -> google.protobuf.Empty
|
||||
35, // [35:41] is the sub-list for method output_type
|
||||
29, // [29:35] is the sub-list for method input_type
|
||||
29, // [29:29] is the sub-list for extension type_name
|
||||
29, // [29:29] is the sub-list for extension extendee
|
||||
0, // [0:29] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_judge_proto_init() }
|
||||
@ -2442,6 +2500,18 @@ func file_judge_proto_init() {
|
||||
}
|
||||
}
|
||||
file_judge_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*StreamRequest_Cancel); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_judge_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*StreamResponse_Output); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@ -2458,6 +2528,7 @@ func file_judge_proto_init() {
|
||||
(*StreamRequest_ExecRequest)(nil),
|
||||
(*StreamRequest_ExecInput)(nil),
|
||||
(*StreamRequest_ExecResize)(nil),
|
||||
(*StreamRequest_ExecCancel)(nil),
|
||||
}
|
||||
file_judge_proto_msgTypes[6].OneofWrappers = []interface{}{
|
||||
(*StreamResponse_ExecResponse)(nil),
|
||||
@ -2477,7 +2548,7 @@ func file_judge_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_judge_proto_rawDesc,
|
||||
NumEnums: 2,
|
||||
NumMessages: 28,
|
||||
NumMessages: 29,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
@ -188,10 +188,13 @@ message StreamRequest {
|
||||
uint32 y = 5;
|
||||
}
|
||||
|
||||
message Cancel {}
|
||||
|
||||
oneof request {
|
||||
Request execRequest = 1;
|
||||
Input execInput = 2;
|
||||
Resize execResize = 3;
|
||||
Cancel execCancel = 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user