From 044f0e4d420766f2ba10b22df6ecf0c546c7a6ee Mon Sep 17 00:00:00 2001 From: Godopu Date: Fri, 17 Jul 2026 16:37:06 +0900 Subject: [PATCH] refactor: relocate protoapi stub files to examples/grpcentity/protoapi --- README.md | 4 +- docs/GRPC.md | 8 +- examples/grpcentity/client.go | 2 +- examples/grpcentity/protoapi/protoapi.pb.go | 405 ++++++++++++++++++ .../grpcentity/protoapi/protoapi_grpc.pb.go | 197 +++++++++ examples/grpcentity/server.go | 2 +- 6 files changed, 611 insertions(+), 7 deletions(-) create mode 100644 examples/grpcentity/protoapi/protoapi.pb.go create mode 100644 examples/grpcentity/protoapi/protoapi_grpc.pb.go diff --git a/README.md b/README.md index f3c8758..0ae4a14 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,13 @@ grpccanary/ ├── README.md # 본 프로젝트 종합 소개 및 실행 가이드 (교육용) ├── go.mod / go.sum # Go 모듈 의존성 정의 (Go 1.25.4+) -├── protoapi/ # protoc로 컴파일 생성된 Go Stub 코드 ├── examples/ │ ├── main.go # 학습 예제 통합 실행 진입점 (수동 전환) │ ├── jsonexample/ # 1단계: JSON 데이터 다루기 실습 예제 │ ├── httpentity/ # 2단계: HTTP & Gin 웹 서버 실습 예제 (WIP) │ └── grpcentity/ # 3단계: gRPC 통신 구현 실습 예제 (서버/클라이언트 데모) -│ └── protoapi.proto # gRPC 인터페이스 정의서 (IDL) +│ ├── protoapi.proto # gRPC 인터페이스 정의서 (IDL) +│ └── protoapi/ # protoc로 컴파일 생성된 Go Stub 코드 └── docs/ ├── MANUSCRIPT.md # 학습 로드맵 및 각 단계별 심화 가이드로의 안내서 ├── JSON.md # 1단계: JSON 데이터 다루기 상세 가이드 diff --git a/docs/GRPC.md b/docs/GRPC.md index c2821be..c1d7846 100644 --- a/docs/GRPC.md +++ b/docs/GRPC.md @@ -166,11 +166,13 @@ gRPC 개발 환경을 구축하기 위해 설치하는 세 가지 프로그램 ``` ### 4.3 실제로 번역하기 (컴파일 명령어) -아래 명령어는 컴퓨터에게 **"내가 작성한 `protoapi.proto` 약속 장부를 Go 언어로 번역해서 `protoapi/` 폴더에 가지런히 넣어줘!"** 하고 지시하는 마법의 명령어입니다: +아래 명령어는 컴퓨터에게 **"내가 작성한 `protoapi.proto` 약속 장부를 Go 언어로 번역해서 현재 실습 디렉터리 내부의 `protoapi/` 폴더에 가지런히 넣어줘!"** 하고 지시하는 마법의 명령어입니다: ```bash -protoc --go_out=. --go-grpc_out=. examples/grpcentity/protoapi.proto +# 실습 디렉터리로 이동한 후 컴파일 실행 +cd examples/grpcentity +protoc --go_out=. --go-grpc_out=. protoapi.proto ``` -명령을 실행하고 나면 `protoapi/` 폴더 하위에 다음 두 파일이 기분 좋게 생성됩니다: +명령을 실행하고 나면 해당 폴더 내의 `protoapi/` 폴더 하위에 다음 두 파일이 기분 좋게 생성됩니다: * `protoapi.pb.go`: 약속 문서에 적은 데이터(Message) 규격들을 Go 구조체로 변환해 놓은 파일입니다. * `protoapi_grpc.pb.go`: 기기와 서버가 실제로 요청을 주고받을 수 있게 하는 통신 창구(Service) 함수가 자동 완성된 파일입니다. diff --git a/examples/grpcentity/client.go b/examples/grpcentity/client.go index 7db93d2..c92098e 100644 --- a/examples/grpcentity/client.go +++ b/examples/grpcentity/client.go @@ -3,7 +3,7 @@ package entity import ( "context" "fmt" - "grpccanary/protoapi" + "grpccanary/examples/grpcentity/protoapi" "math/rand" "time" diff --git a/examples/grpcentity/protoapi/protoapi.pb.go b/examples/grpcentity/protoapi/protoapi.pb.go new file mode 100644 index 0000000..a01ae6d --- /dev/null +++ b/examples/grpcentity/protoapi/protoapi.pb.go @@ -0,0 +1,405 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc v3.21.12 +// source: protoapi.proto + +package protoapi + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +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 SensingData struct { + state protoimpl.MessageState `protogen:"open.v1"` + DeviceId string `protobuf:"bytes,1,opt,name=DeviceId,proto3" json:"DeviceId,omitempty"` + Temperature float64 `protobuf:"fixed64,2,opt,name=Temperature,proto3" json:"Temperature,omitempty"` + Humidity float64 `protobuf:"fixed64,3,opt,name=Humidity,proto3" json:"Humidity,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SensingData) Reset() { + *x = SensingData{} + mi := &file_protoapi_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SensingData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SensingData) ProtoMessage() {} + +func (x *SensingData) ProtoReflect() protoreflect.Message { + mi := &file_protoapi_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SensingData.ProtoReflect.Descriptor instead. +func (*SensingData) Descriptor() ([]byte, []int) { + return file_protoapi_proto_rawDescGZIP(), []int{0} +} + +func (x *SensingData) GetDeviceId() string { + if x != nil { + return x.DeviceId + } + return "" +} + +func (x *SensingData) GetTemperature() float64 { + if x != nil { + return x.Temperature + } + return 0 +} + +func (x *SensingData) GetHumidity() float64 { + if x != nil { + return x.Humidity + } + return 0 +} + +type SensingResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=Success,proto3" json:"Success,omitempty"` + Message string `protobuf:"bytes,2,opt,name=Message,proto3" json:"Message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SensingResponse) Reset() { + *x = SensingResponse{} + mi := &file_protoapi_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SensingResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SensingResponse) ProtoMessage() {} + +func (x *SensingResponse) ProtoReflect() protoreflect.Message { + mi := &file_protoapi_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SensingResponse.ProtoReflect.Descriptor instead. +func (*SensingResponse) Descriptor() ([]byte, []int) { + return file_protoapi_proto_rawDescGZIP(), []int{1} +} + +func (x *SensingResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *SensingResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type DateTime struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value string `protobuf:"bytes,1,opt,name=Value,proto3" json:"Value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DateTime) Reset() { + *x = DateTime{} + mi := &file_protoapi_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DateTime) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DateTime) ProtoMessage() {} + +func (x *DateTime) ProtoReflect() protoreflect.Message { + mi := &file_protoapi_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DateTime.ProtoReflect.Descriptor instead. +func (*DateTime) Descriptor() ([]byte, []int) { + return file_protoapi_proto_rawDescGZIP(), []int{2} +} + +func (x *DateTime) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +type RequestDateTime struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value string `protobuf:"bytes,2,opt,name=Value,proto3" json:"Value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RequestDateTime) Reset() { + *x = RequestDateTime{} + mi := &file_protoapi_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RequestDateTime) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestDateTime) ProtoMessage() {} + +func (x *RequestDateTime) ProtoReflect() protoreflect.Message { + mi := &file_protoapi_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RequestDateTime.ProtoReflect.Descriptor instead. +func (*RequestDateTime) Descriptor() ([]byte, []int) { + return file_protoapi_proto_rawDescGZIP(), []int{3} +} + +func (x *RequestDateTime) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +type RequestPass struct { + state protoimpl.MessageState `protogen:"open.v1"` + Seed int64 `protobuf:"varint,1,opt,name=Seed,proto3" json:"Seed,omitempty"` + Length int64 `protobuf:"varint,8,opt,name=Length,proto3" json:"Length,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RequestPass) Reset() { + *x = RequestPass{} + mi := &file_protoapi_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RequestPass) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestPass) ProtoMessage() {} + +func (x *RequestPass) ProtoReflect() protoreflect.Message { + mi := &file_protoapi_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RequestPass.ProtoReflect.Descriptor instead. +func (*RequestPass) Descriptor() ([]byte, []int) { + return file_protoapi_proto_rawDescGZIP(), []int{4} +} + +func (x *RequestPass) GetSeed() int64 { + if x != nil { + return x.Seed + } + return 0 +} + +func (x *RequestPass) GetLength() int64 { + if x != nil { + return x.Length + } + return 0 +} + +type RandomPass struct { + state protoimpl.MessageState `protogen:"open.v1"` + Password string `protobuf:"bytes,1,opt,name=Password,proto3" json:"Password,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RandomPass) Reset() { + *x = RandomPass{} + mi := &file_protoapi_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RandomPass) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RandomPass) ProtoMessage() {} + +func (x *RandomPass) ProtoReflect() protoreflect.Message { + mi := &file_protoapi_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RandomPass.ProtoReflect.Descriptor instead. +func (*RandomPass) Descriptor() ([]byte, []int) { + return file_protoapi_proto_rawDescGZIP(), []int{5} +} + +func (x *RandomPass) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +var File_protoapi_proto protoreflect.FileDescriptor + +const file_protoapi_proto_rawDesc = "" + + "\n" + + "\x0eprotoapi.proto\"g\n" + + "\vSensingData\x12\x1a\n" + + "\bDeviceId\x18\x01 \x01(\tR\bDeviceId\x12 \n" + + "\vTemperature\x18\x02 \x01(\x01R\vTemperature\x12\x1a\n" + + "\bHumidity\x18\x03 \x01(\x01R\bHumidity\"E\n" + + "\x0fSensingResponse\x12\x18\n" + + "\aSuccess\x18\x01 \x01(\bR\aSuccess\x12\x18\n" + + "\aMessage\x18\x02 \x01(\tR\aMessage\" \n" + + "\bDateTime\x12\x14\n" + + "\x05Value\x18\x01 \x01(\tR\x05Value\"'\n" + + "\x0fRequestDateTime\x12\x14\n" + + "\x05Value\x18\x02 \x01(\tR\x05Value\"9\n" + + "\vRequestPass\x12\x12\n" + + "\x04Seed\x18\x01 \x01(\x03R\x04Seed\x12\x16\n" + + "\x06Length\x18\b \x01(\x03R\x06Length\"(\n" + + "\n" + + "RandomPass\x12\x1a\n" + + "\bPassword\x18\x01 \x01(\tR\bPassword2\x95\x01\n" + + "\n" + + "IoTService\x12&\n" + + "\aGetDate\x12\x10.RequestDateTime\x1a\t.DateTime\x123\n" + + "\x11UpdateSensingData\x12\f.SensingData\x1a\x10.SensingResponse\x12*\n" + + "\rGetRandomPass\x12\f.RequestPass\x1a\v.RandomPassB\x16Z\x14./protoapi/;protoapib\x06proto3" + +var ( + file_protoapi_proto_rawDescOnce sync.Once + file_protoapi_proto_rawDescData []byte +) + +func file_protoapi_proto_rawDescGZIP() []byte { + file_protoapi_proto_rawDescOnce.Do(func() { + file_protoapi_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_protoapi_proto_rawDesc), len(file_protoapi_proto_rawDesc))) + }) + return file_protoapi_proto_rawDescData +} + +var file_protoapi_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_protoapi_proto_goTypes = []any{ + (*SensingData)(nil), // 0: SensingData + (*SensingResponse)(nil), // 1: SensingResponse + (*DateTime)(nil), // 2: DateTime + (*RequestDateTime)(nil), // 3: RequestDateTime + (*RequestPass)(nil), // 4: RequestPass + (*RandomPass)(nil), // 5: RandomPass +} +var file_protoapi_proto_depIdxs = []int32{ + 3, // 0: IoTService.GetDate:input_type -> RequestDateTime + 0, // 1: IoTService.UpdateSensingData:input_type -> SensingData + 4, // 2: IoTService.GetRandomPass:input_type -> RequestPass + 2, // 3: IoTService.GetDate:output_type -> DateTime + 1, // 4: IoTService.UpdateSensingData:output_type -> SensingResponse + 5, // 5: IoTService.GetRandomPass:output_type -> RandomPass + 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_protoapi_proto_init() } +func file_protoapi_proto_init() { + if File_protoapi_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_protoapi_proto_rawDesc), len(file_protoapi_proto_rawDesc)), + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_protoapi_proto_goTypes, + DependencyIndexes: file_protoapi_proto_depIdxs, + MessageInfos: file_protoapi_proto_msgTypes, + }.Build() + File_protoapi_proto = out.File + file_protoapi_proto_goTypes = nil + file_protoapi_proto_depIdxs = nil +} diff --git a/examples/grpcentity/protoapi/protoapi_grpc.pb.go b/examples/grpcentity/protoapi/protoapi_grpc.pb.go new file mode 100644 index 0000000..8db0d84 --- /dev/null +++ b/examples/grpcentity/protoapi/protoapi_grpc.pb.go @@ -0,0 +1,197 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.6.2 +// - protoc v3.21.12 +// source: protoapi.proto + +package protoapi + +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 ( + IoTService_GetDate_FullMethodName = "/IoTService/GetDate" + IoTService_UpdateSensingData_FullMethodName = "/IoTService/UpdateSensingData" + IoTService_GetRandomPass_FullMethodName = "/IoTService/GetRandomPass" +) + +// IoTServiceClient is the client API for IoTService 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 IoTServiceClient interface { + GetDate(ctx context.Context, in *RequestDateTime, opts ...grpc.CallOption) (*DateTime, error) + UpdateSensingData(ctx context.Context, in *SensingData, opts ...grpc.CallOption) (*SensingResponse, error) + GetRandomPass(ctx context.Context, in *RequestPass, opts ...grpc.CallOption) (*RandomPass, error) +} + +type ioTServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewIoTServiceClient(cc grpc.ClientConnInterface) IoTServiceClient { + return &ioTServiceClient{cc} +} + +func (c *ioTServiceClient) GetDate(ctx context.Context, in *RequestDateTime, opts ...grpc.CallOption) (*DateTime, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DateTime) + err := c.cc.Invoke(ctx, IoTService_GetDate_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *ioTServiceClient) UpdateSensingData(ctx context.Context, in *SensingData, opts ...grpc.CallOption) (*SensingResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(SensingResponse) + err := c.cc.Invoke(ctx, IoTService_UpdateSensingData_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *ioTServiceClient) GetRandomPass(ctx context.Context, in *RequestPass, opts ...grpc.CallOption) (*RandomPass, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(RandomPass) + err := c.cc.Invoke(ctx, IoTService_GetRandomPass_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// IoTServiceServer is the server API for IoTService service. +// All implementations must embed UnimplementedIoTServiceServer +// for forward compatibility. +type IoTServiceServer interface { + GetDate(context.Context, *RequestDateTime) (*DateTime, error) + UpdateSensingData(context.Context, *SensingData) (*SensingResponse, error) + GetRandomPass(context.Context, *RequestPass) (*RandomPass, error) + mustEmbedUnimplementedIoTServiceServer() +} + +// UnimplementedIoTServiceServer 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 UnimplementedIoTServiceServer struct{} + +func (UnimplementedIoTServiceServer) GetDate(context.Context, *RequestDateTime) (*DateTime, error) { + return nil, status.Error(codes.Unimplemented, "method GetDate not implemented") +} +func (UnimplementedIoTServiceServer) UpdateSensingData(context.Context, *SensingData) (*SensingResponse, error) { + return nil, status.Error(codes.Unimplemented, "method UpdateSensingData not implemented") +} +func (UnimplementedIoTServiceServer) GetRandomPass(context.Context, *RequestPass) (*RandomPass, error) { + return nil, status.Error(codes.Unimplemented, "method GetRandomPass not implemented") +} +func (UnimplementedIoTServiceServer) mustEmbedUnimplementedIoTServiceServer() {} +func (UnimplementedIoTServiceServer) testEmbeddedByValue() {} + +// UnsafeIoTServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to IoTServiceServer will +// result in compilation errors. +type UnsafeIoTServiceServer interface { + mustEmbedUnimplementedIoTServiceServer() +} + +func RegisterIoTServiceServer(s grpc.ServiceRegistrar, srv IoTServiceServer) { + // If the following call panics, it indicates UnimplementedIoTServiceServer 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(&IoTService_ServiceDesc, srv) +} + +func _IoTService_GetDate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RequestDateTime) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(IoTServiceServer).GetDate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: IoTService_GetDate_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(IoTServiceServer).GetDate(ctx, req.(*RequestDateTime)) + } + return interceptor(ctx, in, info, handler) +} + +func _IoTService_UpdateSensingData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SensingData) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(IoTServiceServer).UpdateSensingData(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: IoTService_UpdateSensingData_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(IoTServiceServer).UpdateSensingData(ctx, req.(*SensingData)) + } + return interceptor(ctx, in, info, handler) +} + +func _IoTService_GetRandomPass_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RequestPass) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(IoTServiceServer).GetRandomPass(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: IoTService_GetRandomPass_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(IoTServiceServer).GetRandomPass(ctx, req.(*RequestPass)) + } + return interceptor(ctx, in, info, handler) +} + +// IoTService_ServiceDesc is the grpc.ServiceDesc for IoTService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var IoTService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "IoTService", + HandlerType: (*IoTServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetDate", + Handler: _IoTService_GetDate_Handler, + }, + { + MethodName: "UpdateSensingData", + Handler: _IoTService_UpdateSensingData_Handler, + }, + { + MethodName: "GetRandomPass", + Handler: _IoTService_GetRandomPass_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "protoapi.proto", +} diff --git a/examples/grpcentity/server.go b/examples/grpcentity/server.go index e8540b5..d12be11 100644 --- a/examples/grpcentity/server.go +++ b/examples/grpcentity/server.go @@ -3,7 +3,7 @@ package entity import ( "context" "fmt" - "grpccanary/protoapi" + "grpccanary/examples/grpcentity/protoapi" "math/rand" "net" "time"