Create scaffolding of ddl-simulator
Implement global server as control plane Implement device to get their info from global server and connect each others
This commit is contained in:
@@ -0,0 +1,492 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v3.21.12
|
||||
// source: proto/device.proto
|
||||
|
||||
package proto
|
||||
|
||||
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 RegisterRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Role string `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"`
|
||||
Capacity *float32 `protobuf:"fixed32,3,opt,name=capacity,proto3,oneof" json:"capacity,omitempty"`
|
||||
ChildrenIds []string `protobuf:"bytes,4,rep,name=children_ids,json=childrenIds,proto3" json:"children_ids,omitempty"`
|
||||
Ip string `protobuf:"bytes,5,opt,name=ip,proto3" json:"ip,omitempty"`
|
||||
Port int32 `protobuf:"varint,6,opt,name=port,proto3" json:"port,omitempty"`
|
||||
}
|
||||
|
||||
func (x *RegisterRequest) Reset() {
|
||||
*x = RegisterRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_device_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *RegisterRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RegisterRequest) ProtoMessage() {}
|
||||
|
||||
func (x *RegisterRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_device_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 RegisterRequest.ProtoReflect.Descriptor instead.
|
||||
func (*RegisterRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_device_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *RegisterRequest) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RegisterRequest) GetRole() string {
|
||||
if x != nil {
|
||||
return x.Role
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RegisterRequest) GetCapacity() float32 {
|
||||
if x != nil && x.Capacity != nil {
|
||||
return *x.Capacity
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *RegisterRequest) GetChildrenIds() []string {
|
||||
if x != nil {
|
||||
return x.ChildrenIds
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *RegisterRequest) GetIp() string {
|
||||
if x != nil {
|
||||
return x.Ip
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RegisterRequest) GetPort() int32 {
|
||||
if x != nil {
|
||||
return x.Port
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type RegisterResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ParentId string `protobuf:"bytes,1,opt,name=parent_id,json=parentId,proto3" json:"parent_id,omitempty"`
|
||||
}
|
||||
|
||||
func (x *RegisterResponse) Reset() {
|
||||
*x = RegisterResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_device_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *RegisterResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RegisterResponse) ProtoMessage() {}
|
||||
|
||||
func (x *RegisterResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_device_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 RegisterResponse.ProtoReflect.Descriptor instead.
|
||||
func (*RegisterResponse) Descriptor() ([]byte, []int) {
|
||||
return file_proto_device_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *RegisterResponse) GetParentId() string {
|
||||
if x != nil {
|
||||
return x.ParentId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ReleaseRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *ReleaseRequest) Reset() {
|
||||
*x = ReleaseRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_device_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ReleaseRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReleaseRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ReleaseRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_device_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 ReleaseRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ReleaseRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_device_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
type ReleaseResposne struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *ReleaseResposne) Reset() {
|
||||
*x = ReleaseResposne{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_device_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ReleaseResposne) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReleaseResposne) ProtoMessage() {}
|
||||
|
||||
func (x *ReleaseResposne) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_device_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 ReleaseResposne.ProtoReflect.Descriptor instead.
|
||||
func (*ReleaseResposne) Descriptor() ([]byte, []int) {
|
||||
return file_proto_device_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
type AssignJobRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
DataSize int32 `protobuf:"varint,1,opt,name=data_size,json=dataSize,proto3" json:"data_size,omitempty"`
|
||||
}
|
||||
|
||||
func (x *AssignJobRequest) Reset() {
|
||||
*x = AssignJobRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_device_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *AssignJobRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*AssignJobRequest) ProtoMessage() {}
|
||||
|
||||
func (x *AssignJobRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_device_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 AssignJobRequest.ProtoReflect.Descriptor instead.
|
||||
func (*AssignJobRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_device_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *AssignJobRequest) GetDataSize() int32 {
|
||||
if x != nil {
|
||||
return x.DataSize
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type AssignJobResposne struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *AssignJobResposne) Reset() {
|
||||
*x = AssignJobResposne{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_device_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *AssignJobResposne) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*AssignJobResposne) ProtoMessage() {}
|
||||
|
||||
func (x *AssignJobResposne) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_device_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 AssignJobResposne.ProtoReflect.Descriptor instead.
|
||||
func (*AssignJobResposne) Descriptor() ([]byte, []int) {
|
||||
return file_proto_device_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
var File_proto_device_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_proto_device_proto_rawDesc = []byte{
|
||||
0x0a, 0x12, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x22, 0xaa, 0x01, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65,
|
||||
0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x1f, 0x0a, 0x08,
|
||||
0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x48, 0x00,
|
||||
0x52, 0x08, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, 0x12, 0x21, 0x0a,
|
||||
0x0c, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x04, 0x20,
|
||||
0x03, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x49, 0x64, 0x73,
|
||||
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04,
|
||||
0x70, 0x6f, 0x72, 0x74, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74,
|
||||
0x79, 0x22, 0x2f, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f,
|
||||
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74,
|
||||
0x49, 0x64, 0x22, 0x10, 0x0a, 0x0e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x22, 0x11, 0x0a, 0x0f, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x73, 0x6e, 0x65, 0x22, 0x2f, 0x0a, 0x10, 0x41, 0x73, 0x73, 0x69, 0x67,
|
||||
0x6e, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x64,
|
||||
0x61, 0x74, 0x61, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08,
|
||||
0x64, 0x61, 0x74, 0x61, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x13, 0x0a, 0x11, 0x41, 0x73, 0x73, 0x69,
|
||||
0x67, 0x6e, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x73, 0x6e, 0x65, 0x32, 0xa1, 0x01,
|
||||
0x0a, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x12, 0x31, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69,
|
||||
0x73, 0x74, 0x65, 0x72, 0x12, 0x10, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65,
|
||||
0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x2e, 0x0a, 0x07, 0x52,
|
||||
0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x0f, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73,
|
||||
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x73, 0x6e, 0x65, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x09, 0x41,
|
||||
0x73, 0x73, 0x69, 0x67, 0x6e, 0x4a, 0x6f, 0x62, 0x12, 0x11, 0x2e, 0x41, 0x73, 0x73, 0x69, 0x67,
|
||||
0x6e, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x41, 0x73,
|
||||
0x73, 0x69, 0x67, 0x6e, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x73, 0x6e, 0x65, 0x22,
|
||||
0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x2e, 0x70, 0x65, 0x6e, 0x67, 0x7a, 0x68, 0x61,
|
||||
0x6e, 0x2e, 0x64, 0x65, 0x76, 0x2f, 0x64, 0x64, 0x70, 0x2d, 0x73, 0x69, 0x6d, 0x75, 0x6c, 0x61,
|
||||
0x74, 0x6f, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_proto_device_proto_rawDescOnce sync.Once
|
||||
file_proto_device_proto_rawDescData = file_proto_device_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_proto_device_proto_rawDescGZIP() []byte {
|
||||
file_proto_device_proto_rawDescOnce.Do(func() {
|
||||
file_proto_device_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_device_proto_rawDescData)
|
||||
})
|
||||
return file_proto_device_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_proto_device_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_proto_device_proto_goTypes = []any{
|
||||
(*RegisterRequest)(nil), // 0: RegisterRequest
|
||||
(*RegisterResponse)(nil), // 1: RegisterResponse
|
||||
(*ReleaseRequest)(nil), // 2: ReleaseRequest
|
||||
(*ReleaseResposne)(nil), // 3: ReleaseResposne
|
||||
(*AssignJobRequest)(nil), // 4: AssignJobRequest
|
||||
(*AssignJobResposne)(nil), // 5: AssignJobResposne
|
||||
}
|
||||
var file_proto_device_proto_depIdxs = []int32{
|
||||
0, // 0: device.Register:input_type -> RegisterRequest
|
||||
2, // 1: device.Release:input_type -> ReleaseRequest
|
||||
4, // 2: device.AssignJob:input_type -> AssignJobRequest
|
||||
1, // 3: device.Register:output_type -> RegisterResponse
|
||||
3, // 4: device.Release:output_type -> ReleaseResposne
|
||||
5, // 5: device.AssignJob:output_type -> AssignJobResposne
|
||||
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_proto_device_proto_init() }
|
||||
func file_proto_device_proto_init() {
|
||||
if File_proto_device_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proto_device_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RegisterRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_device_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RegisterResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_device_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ReleaseRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_device_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ReleaseResposne); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_device_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AssignJobRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_device_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AssignJobResposne); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
file_proto_device_proto_msgTypes[0].OneofWrappers = []any{}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_proto_device_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 6,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_proto_device_proto_goTypes,
|
||||
DependencyIndexes: file_proto_device_proto_depIdxs,
|
||||
MessageInfos: file_proto_device_proto_msgTypes,
|
||||
}.Build()
|
||||
File_proto_device_proto = out.File
|
||||
file_proto_device_proto_rawDesc = nil
|
||||
file_proto_device_proto_goTypes = nil
|
||||
file_proto_device_proto_depIdxs = nil
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package = "git.pengzhan.dev/ddp-simulator/proto";
|
||||
|
||||
service device {
|
||||
rpc Register(RegisterRequest) returns (RegisterResponse) {}
|
||||
rpc Release(ReleaseRequest) returns (ReleaseResposne) {}
|
||||
rpc AssignJob(AssignJobRequest) returns (AssignJobResposne) {}
|
||||
}
|
||||
|
||||
message RegisterRequest {
|
||||
string id = 1;
|
||||
string role = 2;
|
||||
optional float capacity = 3;
|
||||
repeated string children_ids = 4;
|
||||
string ip = 5;
|
||||
int32 port = 6;
|
||||
}
|
||||
|
||||
message RegisterResponse {
|
||||
string parent_id = 1;
|
||||
}
|
||||
|
||||
message ReleaseRequest{}
|
||||
|
||||
message ReleaseResposne{}
|
||||
|
||||
message AssignJobRequest { int32 data_size = 1; }
|
||||
|
||||
message AssignJobResposne {}
|
||||
@@ -0,0 +1,197 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v3.21.12
|
||||
// source: proto/device.proto
|
||||
|
||||
package proto
|
||||
|
||||
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.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
Device_Register_FullMethodName = "/device/Register"
|
||||
Device_Release_FullMethodName = "/device/Release"
|
||||
Device_AssignJob_FullMethodName = "/device/AssignJob"
|
||||
)
|
||||
|
||||
// DeviceClient is the client API for Device 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 DeviceClient interface {
|
||||
Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error)
|
||||
Release(ctx context.Context, in *ReleaseRequest, opts ...grpc.CallOption) (*ReleaseResposne, error)
|
||||
AssignJob(ctx context.Context, in *AssignJobRequest, opts ...grpc.CallOption) (*AssignJobResposne, error)
|
||||
}
|
||||
|
||||
type deviceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewDeviceClient(cc grpc.ClientConnInterface) DeviceClient {
|
||||
return &deviceClient{cc}
|
||||
}
|
||||
|
||||
func (c *deviceClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RegisterResponse)
|
||||
err := c.cc.Invoke(ctx, Device_Register_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *deviceClient) Release(ctx context.Context, in *ReleaseRequest, opts ...grpc.CallOption) (*ReleaseResposne, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ReleaseResposne)
|
||||
err := c.cc.Invoke(ctx, Device_Release_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *deviceClient) AssignJob(ctx context.Context, in *AssignJobRequest, opts ...grpc.CallOption) (*AssignJobResposne, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(AssignJobResposne)
|
||||
err := c.cc.Invoke(ctx, Device_AssignJob_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// DeviceServer is the server API for Device service.
|
||||
// All implementations must embed UnimplementedDeviceServer
|
||||
// for forward compatibility.
|
||||
type DeviceServer interface {
|
||||
Register(context.Context, *RegisterRequest) (*RegisterResponse, error)
|
||||
Release(context.Context, *ReleaseRequest) (*ReleaseResposne, error)
|
||||
AssignJob(context.Context, *AssignJobRequest) (*AssignJobResposne, error)
|
||||
mustEmbedUnimplementedDeviceServer()
|
||||
}
|
||||
|
||||
// UnimplementedDeviceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedDeviceServer struct{}
|
||||
|
||||
func (UnimplementedDeviceServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Register not implemented")
|
||||
}
|
||||
func (UnimplementedDeviceServer) Release(context.Context, *ReleaseRequest) (*ReleaseResposne, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Release not implemented")
|
||||
}
|
||||
func (UnimplementedDeviceServer) AssignJob(context.Context, *AssignJobRequest) (*AssignJobResposne, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AssignJob not implemented")
|
||||
}
|
||||
func (UnimplementedDeviceServer) mustEmbedUnimplementedDeviceServer() {}
|
||||
func (UnimplementedDeviceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeDeviceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to DeviceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeDeviceServer interface {
|
||||
mustEmbedUnimplementedDeviceServer()
|
||||
}
|
||||
|
||||
func RegisterDeviceServer(s grpc.ServiceRegistrar, srv DeviceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedDeviceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&Device_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Device_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(RegisterRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DeviceServer).Register(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Device_Register_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DeviceServer).Register(ctx, req.(*RegisterRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Device_Release_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ReleaseRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DeviceServer).Release(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Device_Release_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DeviceServer).Release(ctx, req.(*ReleaseRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Device_AssignJob_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AssignJobRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DeviceServer).AssignJob(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Device_AssignJob_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DeviceServer).AssignJob(ctx, req.(*AssignJobRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Device_ServiceDesc is the grpc.ServiceDesc for Device service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Device_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "device",
|
||||
HandlerType: (*DeviceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Register",
|
||||
Handler: _Device_Register_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Release",
|
||||
Handler: _Device_Release_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "AssignJob",
|
||||
Handler: _Device_AssignJob_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "proto/device.proto",
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v3.21.12
|
||||
// source: proto/global.proto
|
||||
|
||||
package proto
|
||||
|
||||
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 InitRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
}
|
||||
|
||||
func (x *InitRequest) Reset() {
|
||||
*x = InitRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_global_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *InitRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*InitRequest) ProtoMessage() {}
|
||||
|
||||
func (x *InitRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_global_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 InitRequest.ProtoReflect.Descriptor instead.
|
||||
func (*InitRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_global_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *InitRequest) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type InitResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
|
||||
Capacity *float32 `protobuf:"fixed32,2,opt,name=capacity,proto3,oneof" json:"capacity,omitempty"`
|
||||
Ip string `protobuf:"bytes,3,opt,name=ip,proto3" json:"ip,omitempty"`
|
||||
Port int32 `protobuf:"varint,4,opt,name=port,proto3" json:"port,omitempty"`
|
||||
ParentId *string `protobuf:"bytes,5,opt,name=parent_id,json=parentId,proto3,oneof" json:"parent_id,omitempty"`
|
||||
Pip *string `protobuf:"bytes,6,opt,name=pip,proto3,oneof" json:"pip,omitempty"`
|
||||
Pport *int32 `protobuf:"varint,7,opt,name=pport,proto3,oneof" json:"pport,omitempty"`
|
||||
}
|
||||
|
||||
func (x *InitResponse) Reset() {
|
||||
*x = InitResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_global_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *InitResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*InitResponse) ProtoMessage() {}
|
||||
|
||||
func (x *InitResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_global_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 InitResponse.ProtoReflect.Descriptor instead.
|
||||
func (*InitResponse) Descriptor() ([]byte, []int) {
|
||||
return file_proto_global_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *InitResponse) GetRole() string {
|
||||
if x != nil {
|
||||
return x.Role
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *InitResponse) GetCapacity() float32 {
|
||||
if x != nil && x.Capacity != nil {
|
||||
return *x.Capacity
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *InitResponse) GetIp() string {
|
||||
if x != nil {
|
||||
return x.Ip
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *InitResponse) GetPort() int32 {
|
||||
if x != nil {
|
||||
return x.Port
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *InitResponse) GetParentId() string {
|
||||
if x != nil && x.ParentId != nil {
|
||||
return *x.ParentId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *InitResponse) GetPip() string {
|
||||
if x != nil && x.Pip != nil {
|
||||
return *x.Pip
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *InitResponse) GetPport() int32 {
|
||||
if x != nil && x.Pport != nil {
|
||||
return *x.Pport
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_proto_global_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_proto_global_proto_rawDesc = []byte{
|
||||
0x0a, 0x12, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1d, 0x0a, 0x0b, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x02, 0x69, 0x64, 0x22, 0xe8, 0x01, 0x0a, 0x0c, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x1f, 0x0a, 0x08, 0x63, 0x61, 0x70, 0x61,
|
||||
0x63, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x02, 0x48, 0x00, 0x52, 0x08, 0x63, 0x61,
|
||||
0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18,
|
||||
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72,
|
||||
0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x20, 0x0a,
|
||||
0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
|
||||
0x48, 0x01, 0x52, 0x08, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12,
|
||||
0x15, 0x0a, 0x03, 0x70, 0x69, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x03,
|
||||
0x70, 0x69, 0x70, 0x88, 0x01, 0x01, 0x12, 0x19, 0x0a, 0x05, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x18,
|
||||
0x07, 0x20, 0x01, 0x28, 0x05, 0x48, 0x03, 0x52, 0x05, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x88, 0x01,
|
||||
0x01, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x63, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x42, 0x0c,
|
||||
0x0a, 0x0a, 0x5f, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x42, 0x06, 0x0a, 0x04,
|
||||
0x5f, 0x70, 0x69, 0x70, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x32, 0x36,
|
||||
0x0a, 0x0d, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,
|
||||
0x25, 0x0a, 0x04, 0x49, 0x6e, 0x69, 0x74, 0x12, 0x0c, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x2e, 0x70, 0x65,
|
||||
0x6e, 0x67, 0x7a, 0x68, 0x61, 0x6e, 0x2e, 0x64, 0x65, 0x76, 0x2f, 0x64, 0x64, 0x70, 0x2d, 0x73,
|
||||
0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_proto_global_proto_rawDescOnce sync.Once
|
||||
file_proto_global_proto_rawDescData = file_proto_global_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_proto_global_proto_rawDescGZIP() []byte {
|
||||
file_proto_global_proto_rawDescOnce.Do(func() {
|
||||
file_proto_global_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_global_proto_rawDescData)
|
||||
})
|
||||
return file_proto_global_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_proto_global_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_proto_global_proto_goTypes = []any{
|
||||
(*InitRequest)(nil), // 0: InitRequest
|
||||
(*InitResponse)(nil), // 1: InitResponse
|
||||
}
|
||||
var file_proto_global_proto_depIdxs = []int32{
|
||||
0, // 0: globalService.Init:input_type -> InitRequest
|
||||
1, // 1: globalService.Init:output_type -> InitResponse
|
||||
1, // [1:2] is the sub-list for method output_type
|
||||
0, // [0:1] 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_proto_global_proto_init() }
|
||||
func file_proto_global_proto_init() {
|
||||
if File_proto_global_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proto_global_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*InitRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_global_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*InitResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
file_proto_global_proto_msgTypes[1].OneofWrappers = []any{}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_proto_global_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_proto_global_proto_goTypes,
|
||||
DependencyIndexes: file_proto_global_proto_depIdxs,
|
||||
MessageInfos: file_proto_global_proto_msgTypes,
|
||||
}.Build()
|
||||
File_proto_global_proto = out.File
|
||||
file_proto_global_proto_rawDesc = nil
|
||||
file_proto_global_proto_goTypes = nil
|
||||
file_proto_global_proto_depIdxs = nil
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package = "git.pengzhan.dev/ddp-simulator/proto";
|
||||
|
||||
service globalService {
|
||||
rpc Init(InitRequest) returns (InitResponse) {}
|
||||
}
|
||||
|
||||
message InitRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message InitResponse {
|
||||
string role = 1;
|
||||
optional float capacity = 2;
|
||||
string ip = 3;
|
||||
int32 port = 4;
|
||||
optional string parent_id = 5;
|
||||
optional string pip = 6;
|
||||
optional int32 pport = 7;
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v3.21.12
|
||||
// source: proto/global.proto
|
||||
|
||||
package proto
|
||||
|
||||
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.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
GlobalService_Init_FullMethodName = "/globalService/Init"
|
||||
)
|
||||
|
||||
// GlobalServiceClient is the client API for GlobalService 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 GlobalServiceClient interface {
|
||||
Init(ctx context.Context, in *InitRequest, opts ...grpc.CallOption) (*InitResponse, error)
|
||||
}
|
||||
|
||||
type globalServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewGlobalServiceClient(cc grpc.ClientConnInterface) GlobalServiceClient {
|
||||
return &globalServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *globalServiceClient) Init(ctx context.Context, in *InitRequest, opts ...grpc.CallOption) (*InitResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(InitResponse)
|
||||
err := c.cc.Invoke(ctx, GlobalService_Init_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// GlobalServiceServer is the server API for GlobalService service.
|
||||
// All implementations must embed UnimplementedGlobalServiceServer
|
||||
// for forward compatibility.
|
||||
type GlobalServiceServer interface {
|
||||
Init(context.Context, *InitRequest) (*InitResponse, error)
|
||||
mustEmbedUnimplementedGlobalServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedGlobalServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedGlobalServiceServer struct{}
|
||||
|
||||
func (UnimplementedGlobalServiceServer) Init(context.Context, *InitRequest) (*InitResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Init not implemented")
|
||||
}
|
||||
func (UnimplementedGlobalServiceServer) mustEmbedUnimplementedGlobalServiceServer() {}
|
||||
func (UnimplementedGlobalServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeGlobalServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to GlobalServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeGlobalServiceServer interface {
|
||||
mustEmbedUnimplementedGlobalServiceServer()
|
||||
}
|
||||
|
||||
func RegisterGlobalServiceServer(s grpc.ServiceRegistrar, srv GlobalServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedGlobalServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&GlobalService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _GlobalService_Init_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(InitRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(GlobalServiceServer).Init(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: GlobalService_Init_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(GlobalServiceServer).Init(ctx, req.(*InitRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// GlobalService_ServiceDesc is the grpc.ServiceDesc for GlobalService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var GlobalService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "globalService",
|
||||
HandlerType: (*GlobalServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Init",
|
||||
Handler: _GlobalService_Init_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "proto/global.proto",
|
||||
}
|
||||
Reference in New Issue
Block a user