diff --git a/.gitignore b/.gitignore index 5ccc268..a201400 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ # Generated files /bin /docs/book +/include diff --git a/Makefile b/Makefile index b3695d6..cac656f 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,15 @@ BIN_DIR := $(shell pwd)/bin # Tool versions MDBOOK_VERSION = 0.4.27 +PROTOC_VERSION = 24.2 +PROTOC_GEN_GO_VERSION = 1.31.0 +PROTOC_GEN_GO_GRPC_VERSION = 1.3.0 +PROTOC_GEN_DOC_VERSION = 1.5.1 MDBOOK := $(BIN_DIR)/mdbook # Test tools +PROTOC := PATH=$(PWD)/bin:'$(PATH)' $(PWD)/bin/protoc -I=$(PWD)/include:. +PROTOC_OUTPUTS = pkg/rpc/necoperf.pb.go pkg/rpc/necoperf_grpc.pb.go docs/necoperf-grpc.md STATICCHECK = $(BIN_DIR)/staticcheck .PHONY: all @@ -30,9 +36,30 @@ test-go: test-tools go test -race -v ./... go vet ./... +.PHONY: generate +generate: + $(MAKE) $(PROTOC_OUTPUTS) + +pkg/rpc/necoperf.pb.go: pkg/rpc/necoperf.proto + $(PROTOC) --go_out=. $< + +pkg/rpc/necoperf_grpc.pb.go: pkg/rpc/necoperf.proto + $(PROTOC) --go-grpc_out=. $< + +docs/necoperf-grpc.md: pkg/rpc/necoperf.proto + $(PROTOC) --doc_out=docs --doc_opt=markdown,$@ $< ##@ Tools +.PHONY: setup +setup: + curl -sfL -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOC_VERSION)/protoc-$(PROTOC_VERSION)-linux-x86_64.zip + unzip -o protoc.zip bin/protoc 'include/*' + rm -f protoc.zip + GOBIN=$(PWD)/bin go install google.golang.org/protobuf/cmd/protoc-gen-go@v$(PROTOC_GEN_GO_VERSION) + GOBIN=$(PWD)/bin go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v$(PROTOC_GEN_GO_GRPC_VERSION) + GOBIN=$(PWD)/bin go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@v$(PROTOC_GEN_DOC_VERSION) + $(MDBOOK): mkdir -p bin curl -fsL https://github.com/rust-lang/mdBook/releases/download/v$(MDBOOK_VERSION)/mdbook-v$(MDBOOK_VERSION)-x86_64-unknown-linux-gnu.tar.gz | tar -C bin -xzf - diff --git a/docs/necoperf-grpc.md b/docs/necoperf-grpc.md new file mode 100644 index 0000000..65ef695 --- /dev/null +++ b/docs/necoperf-grpc.md @@ -0,0 +1,161 @@ +# Protocol Documentation + + +## Table of Contents + +- [pkg/rpc/necoperf.proto](#pkg_rpc_necoperf-proto) + - [PerfProfileRequest](#necoperf-PerfProfileRequest) + - [PerfProfileResponse](#necoperf-PerfProfileResponse) + - [PerfRecordRequest](#necoperf-PerfRecordRequest) + - [PerfRecordResponse](#necoperf-PerfRecordResponse) + - [PerfScriptRequest](#necoperf-PerfScriptRequest) + - [PerfScriptResponse](#necoperf-PerfScriptResponse) + + - [NecoPerf](#necoperf-NecoPerf) + +- [Scalar Value Types](#scalar-value-types) + + + + +

Top

+ +## pkg/rpc/necoperf.proto + + + + + +### PerfProfileRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| container_id | [string](#string) | | | +| timeout_seconds | [int64](#int64) | | | + + + + + + + + +### PerfProfileResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| data | [bytes](#bytes) | | | + + + + + + + + +### PerfRecordRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| container_id | [string](#string) | | | +| timeout | [int64](#int64) | | | + + + + + + + + +### PerfRecordResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| message | [string](#string) | | | +| data | [bytes](#bytes) | | | + + + + + + + + +### PerfScriptRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| scriptFileName | [string](#string) | | | + + + + + + + + +### PerfScriptResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| message | [string](#string) | | | +| data | [bytes](#bytes) | | | + + + + + + + + + + + + + + +### NecoPerf + + +| Method Name | Request Type | Response Type | Description | +| ----------- | ------------ | ------------- | ------------| +| Profile | [PerfProfileRequest](#necoperf-PerfProfileRequest) | [PerfProfileResponse](#necoperf-PerfProfileResponse) stream | | +| Record | [PerfRecordRequest](#necoperf-PerfRecordRequest) | [PerfRecordResponse](#necoperf-PerfRecordResponse) | | +| Script | [PerfScriptRequest](#necoperf-PerfScriptRequest) | [PerfScriptResponse](#necoperf-PerfScriptResponse) stream | | + + + + + +## Scalar Value Types + +| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | +| ----------- | ----- | --- | ---- | ------ | -- | -- | --- | ---- | +| double | | double | double | float | float64 | double | float | Float | +| float | | float | float | float | float32 | float | float | Float | +| int32 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | +| int64 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. | int64 | long | int/long | int64 | long | integer/string | Bignum | +| uint32 | Uses variable-length encoding. | uint32 | int | int/long | uint32 | uint | integer | Bignum or Fixnum (as required) | +| uint64 | Uses variable-length encoding. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum or Fixnum (as required) | +| sint32 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | +| sint64 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. | int64 | long | int/long | int64 | long | integer/string | Bignum | +| fixed32 | Always four bytes. More efficient than uint32 if values are often greater than 2^28. | uint32 | int | int | uint32 | uint | integer | Bignum or Fixnum (as required) | +| fixed64 | Always eight bytes. More efficient than uint64 if values are often greater than 2^56. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum | +| sfixed32 | Always four bytes. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | +| sfixed64 | Always eight bytes. | int64 | long | int/long | int64 | long | integer/string | Bignum | +| bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass | +| string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) | +| bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) | + diff --git a/pkg/rpc/necoperf.pb.go b/pkg/rpc/necoperf.pb.go new file mode 100644 index 0000000..e272ee9 --- /dev/null +++ b/pkg/rpc/necoperf.pb.go @@ -0,0 +1,518 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.24.2 +// source: pkg/rpc/necoperf.proto + +package rpc + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type PerfProfileRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ContainerId string `protobuf:"bytes,1,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` + TimeoutSeconds int64 `protobuf:"varint,2,opt,name=timeout_seconds,json=timeoutSeconds,proto3" json:"timeout_seconds,omitempty"` +} + +func (x *PerfProfileRequest) Reset() { + *x = PerfProfileRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_rpc_necoperf_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PerfProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PerfProfileRequest) ProtoMessage() {} + +func (x *PerfProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_pkg_rpc_necoperf_proto_msgTypes[0] + 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 PerfProfileRequest.ProtoReflect.Descriptor instead. +func (*PerfProfileRequest) Descriptor() ([]byte, []int) { + return file_pkg_rpc_necoperf_proto_rawDescGZIP(), []int{0} +} + +func (x *PerfProfileRequest) GetContainerId() string { + if x != nil { + return x.ContainerId + } + return "" +} + +func (x *PerfProfileRequest) GetTimeoutSeconds() int64 { + if x != nil { + return x.TimeoutSeconds + } + return 0 +} + +type PerfProfileResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *PerfProfileResponse) Reset() { + *x = PerfProfileResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_rpc_necoperf_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PerfProfileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PerfProfileResponse) ProtoMessage() {} + +func (x *PerfProfileResponse) ProtoReflect() protoreflect.Message { + mi := &file_pkg_rpc_necoperf_proto_msgTypes[1] + 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 PerfProfileResponse.ProtoReflect.Descriptor instead. +func (*PerfProfileResponse) Descriptor() ([]byte, []int) { + return file_pkg_rpc_necoperf_proto_rawDescGZIP(), []int{1} +} + +func (x *PerfProfileResponse) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +type PerfRecordRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ContainerId string `protobuf:"bytes,1,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` + Timeout int64 `protobuf:"varint,2,opt,name=timeout,proto3" json:"timeout,omitempty"` +} + +func (x *PerfRecordRequest) Reset() { + *x = PerfRecordRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_rpc_necoperf_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PerfRecordRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PerfRecordRequest) ProtoMessage() {} + +func (x *PerfRecordRequest) ProtoReflect() protoreflect.Message { + mi := &file_pkg_rpc_necoperf_proto_msgTypes[2] + 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 PerfRecordRequest.ProtoReflect.Descriptor instead. +func (*PerfRecordRequest) Descriptor() ([]byte, []int) { + return file_pkg_rpc_necoperf_proto_rawDescGZIP(), []int{2} +} + +func (x *PerfRecordRequest) GetContainerId() string { + if x != nil { + return x.ContainerId + } + return "" +} + +func (x *PerfRecordRequest) GetTimeout() int64 { + if x != nil { + return x.Timeout + } + return 0 +} + +type PerfRecordResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *PerfRecordResponse) Reset() { + *x = PerfRecordResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_rpc_necoperf_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PerfRecordResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PerfRecordResponse) ProtoMessage() {} + +func (x *PerfRecordResponse) ProtoReflect() protoreflect.Message { + mi := &file_pkg_rpc_necoperf_proto_msgTypes[3] + 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 PerfRecordResponse.ProtoReflect.Descriptor instead. +func (*PerfRecordResponse) Descriptor() ([]byte, []int) { + return file_pkg_rpc_necoperf_proto_rawDescGZIP(), []int{3} +} + +func (x *PerfRecordResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *PerfRecordResponse) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +type PerfScriptRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ScriptFileName string `protobuf:"bytes,1,opt,name=scriptFileName,proto3" json:"scriptFileName,omitempty"` +} + +func (x *PerfScriptRequest) Reset() { + *x = PerfScriptRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_rpc_necoperf_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PerfScriptRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PerfScriptRequest) ProtoMessage() {} + +func (x *PerfScriptRequest) ProtoReflect() protoreflect.Message { + mi := &file_pkg_rpc_necoperf_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 PerfScriptRequest.ProtoReflect.Descriptor instead. +func (*PerfScriptRequest) Descriptor() ([]byte, []int) { + return file_pkg_rpc_necoperf_proto_rawDescGZIP(), []int{4} +} + +func (x *PerfScriptRequest) GetScriptFileName() string { + if x != nil { + return x.ScriptFileName + } + return "" +} + +type PerfScriptResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *PerfScriptResponse) Reset() { + *x = PerfScriptResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_rpc_necoperf_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PerfScriptResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PerfScriptResponse) ProtoMessage() {} + +func (x *PerfScriptResponse) ProtoReflect() protoreflect.Message { + mi := &file_pkg_rpc_necoperf_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 PerfScriptResponse.ProtoReflect.Descriptor instead. +func (*PerfScriptResponse) Descriptor() ([]byte, []int) { + return file_pkg_rpc_necoperf_proto_rawDescGZIP(), []int{5} +} + +func (x *PerfScriptResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *PerfScriptResponse) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +var File_pkg_rpc_necoperf_proto protoreflect.FileDescriptor + +var file_pkg_rpc_necoperf_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x6e, 0x65, 0x63, 0x6f, 0x70, 0x65, + 0x72, 0x66, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x6e, 0x65, 0x63, 0x6f, 0x70, 0x65, + 0x72, 0x66, 0x22, 0x60, 0x0a, 0x12, 0x50, 0x65, 0x72, 0x66, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, + 0x61, 0x69, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x74, + 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x5f, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x53, 0x65, 0x63, + 0x6f, 0x6e, 0x64, 0x73, 0x22, 0x29, 0x0a, 0x13, 0x50, 0x65, 0x72, 0x66, 0x50, 0x72, 0x6f, 0x66, + 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, + 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, + 0x50, 0x0a, 0x11, 0x50, 0x65, 0x72, 0x66, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, + 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, + 0x61, 0x69, 0x6e, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, + 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, + 0x74, 0x22, 0x42, 0x0a, 0x12, 0x50, 0x65, 0x72, 0x66, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x3b, 0x0a, 0x11, 0x50, 0x65, 0x72, 0x66, 0x53, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0e, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x4e, 0x61, + 0x6d, 0x65, 0x22, 0x42, 0x0a, 0x12, 0x50, 0x65, 0x72, 0x66, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0xe0, 0x01, 0x0a, 0x08, 0x4e, 0x65, 0x63, 0x6f, 0x50, + 0x65, 0x72, 0x66, 0x12, 0x48, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x1c, + 0x2e, 0x6e, 0x65, 0x63, 0x6f, 0x70, 0x65, 0x72, 0x66, 0x2e, 0x50, 0x65, 0x72, 0x66, 0x50, 0x72, + 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6e, + 0x65, 0x63, 0x6f, 0x70, 0x65, 0x72, 0x66, 0x2e, 0x50, 0x65, 0x72, 0x66, 0x50, 0x72, 0x6f, 0x66, + 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x43, 0x0a, + 0x06, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x1b, 0x2e, 0x6e, 0x65, 0x63, 0x6f, 0x70, 0x65, + 0x72, 0x66, 0x2e, 0x50, 0x65, 0x72, 0x66, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x6e, 0x65, 0x63, 0x6f, 0x70, 0x65, 0x72, 0x66, 0x2e, + 0x50, 0x65, 0x72, 0x66, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x45, 0x0a, 0x06, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, 0x1b, 0x2e, 0x6e, + 0x65, 0x63, 0x6f, 0x70, 0x65, 0x72, 0x66, 0x2e, 0x50, 0x65, 0x72, 0x66, 0x53, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x6e, 0x65, 0x63, 0x6f, + 0x70, 0x65, 0x72, 0x66, 0x2e, 0x50, 0x65, 0x72, 0x66, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x09, 0x5a, 0x07, 0x70, 0x6b, 0x67, + 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_pkg_rpc_necoperf_proto_rawDescOnce sync.Once + file_pkg_rpc_necoperf_proto_rawDescData = file_pkg_rpc_necoperf_proto_rawDesc +) + +func file_pkg_rpc_necoperf_proto_rawDescGZIP() []byte { + file_pkg_rpc_necoperf_proto_rawDescOnce.Do(func() { + file_pkg_rpc_necoperf_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_rpc_necoperf_proto_rawDescData) + }) + return file_pkg_rpc_necoperf_proto_rawDescData +} + +var file_pkg_rpc_necoperf_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_pkg_rpc_necoperf_proto_goTypes = []interface{}{ + (*PerfProfileRequest)(nil), // 0: necoperf.PerfProfileRequest + (*PerfProfileResponse)(nil), // 1: necoperf.PerfProfileResponse + (*PerfRecordRequest)(nil), // 2: necoperf.PerfRecordRequest + (*PerfRecordResponse)(nil), // 3: necoperf.PerfRecordResponse + (*PerfScriptRequest)(nil), // 4: necoperf.PerfScriptRequest + (*PerfScriptResponse)(nil), // 5: necoperf.PerfScriptResponse +} +var file_pkg_rpc_necoperf_proto_depIdxs = []int32{ + 0, // 0: necoperf.NecoPerf.Profile:input_type -> necoperf.PerfProfileRequest + 2, // 1: necoperf.NecoPerf.Record:input_type -> necoperf.PerfRecordRequest + 4, // 2: necoperf.NecoPerf.Script:input_type -> necoperf.PerfScriptRequest + 1, // 3: necoperf.NecoPerf.Profile:output_type -> necoperf.PerfProfileResponse + 3, // 4: necoperf.NecoPerf.Record:output_type -> necoperf.PerfRecordResponse + 5, // 5: necoperf.NecoPerf.Script:output_type -> necoperf.PerfScriptResponse + 3, // [3:6] is the sub-list for method output_type + 0, // [0:3] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_pkg_rpc_necoperf_proto_init() } +func file_pkg_rpc_necoperf_proto_init() { + if File_pkg_rpc_necoperf_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_pkg_rpc_necoperf_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PerfProfileRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_rpc_necoperf_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PerfProfileResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_rpc_necoperf_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PerfRecordRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_rpc_necoperf_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PerfRecordResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_rpc_necoperf_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PerfScriptRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_rpc_necoperf_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PerfScriptResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_pkg_rpc_necoperf_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_pkg_rpc_necoperf_proto_goTypes, + DependencyIndexes: file_pkg_rpc_necoperf_proto_depIdxs, + MessageInfos: file_pkg_rpc_necoperf_proto_msgTypes, + }.Build() + File_pkg_rpc_necoperf_proto = out.File + file_pkg_rpc_necoperf_proto_rawDesc = nil + file_pkg_rpc_necoperf_proto_goTypes = nil + file_pkg_rpc_necoperf_proto_depIdxs = nil +} diff --git a/pkg/rpc/necoperf.proto b/pkg/rpc/necoperf.proto new file mode 100644 index 0000000..3058428 --- /dev/null +++ b/pkg/rpc/necoperf.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; + +option go_package = "pkg/rpc"; + +package necoperf; + +service NecoPerf { + rpc Profile(PerfProfileRequest) returns (stream PerfProfileResponse); + rpc Record(PerfRecordRequest) returns (PerfRecordResponse); + rpc Script(PerfScriptRequest) returns (stream PerfScriptResponse); +} + +message PerfProfileRequest { + string container_id = 1; + int64 timeout_seconds = 2; +} + +message PerfProfileResponse { + bytes data = 1; +} + +message PerfRecordRequest { + string container_id = 1; + int64 timeout = 2; +} + +message PerfRecordResponse { + string message = 1; + bytes data = 2; +} + +message PerfScriptRequest { + string scriptFileName = 1; +} + +message PerfScriptResponse { + string message = 1; + bytes data = 2; +} diff --git a/pkg/rpc/necoperf_grpc.pb.go b/pkg/rpc/necoperf_grpc.pb.go new file mode 100644 index 0000000..f8ed793 --- /dev/null +++ b/pkg/rpc/necoperf_grpc.pb.go @@ -0,0 +1,238 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.24.2 +// source: pkg/rpc/necoperf.proto + +package rpc + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + NecoPerf_Profile_FullMethodName = "/necoperf.NecoPerf/Profile" + NecoPerf_Record_FullMethodName = "/necoperf.NecoPerf/Record" + NecoPerf_Script_FullMethodName = "/necoperf.NecoPerf/Script" +) + +// NecoPerfClient is the client API for NecoPerf service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type NecoPerfClient interface { + Profile(ctx context.Context, in *PerfProfileRequest, opts ...grpc.CallOption) (NecoPerf_ProfileClient, error) + Record(ctx context.Context, in *PerfRecordRequest, opts ...grpc.CallOption) (*PerfRecordResponse, error) + Script(ctx context.Context, in *PerfScriptRequest, opts ...grpc.CallOption) (NecoPerf_ScriptClient, error) +} + +type necoPerfClient struct { + cc grpc.ClientConnInterface +} + +func NewNecoPerfClient(cc grpc.ClientConnInterface) NecoPerfClient { + return &necoPerfClient{cc} +} + +func (c *necoPerfClient) Profile(ctx context.Context, in *PerfProfileRequest, opts ...grpc.CallOption) (NecoPerf_ProfileClient, error) { + stream, err := c.cc.NewStream(ctx, &NecoPerf_ServiceDesc.Streams[0], NecoPerf_Profile_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &necoPerfProfileClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type NecoPerf_ProfileClient interface { + Recv() (*PerfProfileResponse, error) + grpc.ClientStream +} + +type necoPerfProfileClient struct { + grpc.ClientStream +} + +func (x *necoPerfProfileClient) Recv() (*PerfProfileResponse, error) { + m := new(PerfProfileResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *necoPerfClient) Record(ctx context.Context, in *PerfRecordRequest, opts ...grpc.CallOption) (*PerfRecordResponse, error) { + out := new(PerfRecordResponse) + err := c.cc.Invoke(ctx, NecoPerf_Record_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *necoPerfClient) Script(ctx context.Context, in *PerfScriptRequest, opts ...grpc.CallOption) (NecoPerf_ScriptClient, error) { + stream, err := c.cc.NewStream(ctx, &NecoPerf_ServiceDesc.Streams[1], NecoPerf_Script_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &necoPerfScriptClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type NecoPerf_ScriptClient interface { + Recv() (*PerfScriptResponse, error) + grpc.ClientStream +} + +type necoPerfScriptClient struct { + grpc.ClientStream +} + +func (x *necoPerfScriptClient) Recv() (*PerfScriptResponse, error) { + m := new(PerfScriptResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// NecoPerfServer is the server API for NecoPerf service. +// All implementations must embed UnimplementedNecoPerfServer +// for forward compatibility +type NecoPerfServer interface { + Profile(*PerfProfileRequest, NecoPerf_ProfileServer) error + Record(context.Context, *PerfRecordRequest) (*PerfRecordResponse, error) + Script(*PerfScriptRequest, NecoPerf_ScriptServer) error + mustEmbedUnimplementedNecoPerfServer() +} + +// UnimplementedNecoPerfServer must be embedded to have forward compatible implementations. +type UnimplementedNecoPerfServer struct { +} + +func (UnimplementedNecoPerfServer) Profile(*PerfProfileRequest, NecoPerf_ProfileServer) error { + return status.Errorf(codes.Unimplemented, "method Profile not implemented") +} +func (UnimplementedNecoPerfServer) Record(context.Context, *PerfRecordRequest) (*PerfRecordResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Record not implemented") +} +func (UnimplementedNecoPerfServer) Script(*PerfScriptRequest, NecoPerf_ScriptServer) error { + return status.Errorf(codes.Unimplemented, "method Script not implemented") +} +func (UnimplementedNecoPerfServer) mustEmbedUnimplementedNecoPerfServer() {} + +// UnsafeNecoPerfServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to NecoPerfServer will +// result in compilation errors. +type UnsafeNecoPerfServer interface { + mustEmbedUnimplementedNecoPerfServer() +} + +func RegisterNecoPerfServer(s grpc.ServiceRegistrar, srv NecoPerfServer) { + s.RegisterService(&NecoPerf_ServiceDesc, srv) +} + +func _NecoPerf_Profile_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(PerfProfileRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(NecoPerfServer).Profile(m, &necoPerfProfileServer{stream}) +} + +type NecoPerf_ProfileServer interface { + Send(*PerfProfileResponse) error + grpc.ServerStream +} + +type necoPerfProfileServer struct { + grpc.ServerStream +} + +func (x *necoPerfProfileServer) Send(m *PerfProfileResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _NecoPerf_Record_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PerfRecordRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NecoPerfServer).Record(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: NecoPerf_Record_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NecoPerfServer).Record(ctx, req.(*PerfRecordRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _NecoPerf_Script_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(PerfScriptRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(NecoPerfServer).Script(m, &necoPerfScriptServer{stream}) +} + +type NecoPerf_ScriptServer interface { + Send(*PerfScriptResponse) error + grpc.ServerStream +} + +type necoPerfScriptServer struct { + grpc.ServerStream +} + +func (x *necoPerfScriptServer) Send(m *PerfScriptResponse) error { + return x.ServerStream.SendMsg(m) +} + +// NecoPerf_ServiceDesc is the grpc.ServiceDesc for NecoPerf service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var NecoPerf_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "necoperf.NecoPerf", + HandlerType: (*NecoPerfServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Record", + Handler: _NecoPerf_Record_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "Profile", + Handler: _NecoPerf_Profile_Handler, + ServerStreams: true, + }, + { + StreamName: "Script", + Handler: _NecoPerf_Script_Handler, + ServerStreams: true, + }, + }, + Metadata: "pkg/rpc/necoperf.proto", +}