代码相对完善

This commit is contained in:
wyh 2022-01-20 17:07:00 +08:00
commit 9c0daee45d
11 changed files with 1329 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.sum

BIN
1.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

9
README.md Normal file
View File

@ -0,0 +1,9 @@
### grpc-client
- 获取组件
- go get -u google.golang.org/grpc
- 生成 pb 文件
- protoc --proto_path=./protos ./protos/\*.proto --go_out=plugins=grpc:./pb
- 客户端使用的证书需与服务端一致

29
cert.pem Normal file
View File

@ -0,0 +1,29 @@
-----BEGIN CERTIFICATE-----
MIIE4TCCAsmgAwIBAgIUJC8WZ7nPROEEwjUJwJpwsUkHQu0wDQYJKoZIhvcNAQEL
BQAwFDESMBAGA1UEAwwJbG9jYWxob3N0MB4XDTIyMDEyMDA4MTE0MFoXDTIzMDEy
MDA4MTE0MFowFDESMBAGA1UEAwwJbG9jYWxob3N0MIICIjANBgkqhkiG9w0BAQEF
AAOCAg8AMIICCgKCAgEAuNwDPBdmTlGrZgVEnYkj0/ajuN7l/9JuoquRpjjSzTUR
2bIDL/eFQRBUYXPFVuZGep02obpEgi4bjPwLf2eCeHZOz2CP7UU8OynKh4V5fIge
rUKIpVtZ+IKvhfztvn5ObNK5b4nZCcb20wmNnQjn5LpjoMTT4ENTyYFUQ08Y31XF
NgnK6UQml86BNMWN7N6g19LjOna2xK/PDroLilmhK162liHaw0S+WEE6XvlLtDRG
ojguB+3wEBBIFQJ4kvLB8y9ft13eh/UYACC7/4SrHH9UwTUKhTwM2+d9l4JAnPc7
rU103ORHu3kh4JOxC0/u6gJKFkpU1eFIQ/bhGAzS/cHL4M6+KF1+6IQoWrayNzPG
ghwf9udZhwkeVtAu+31IQmOECqnUYs/gzAsOj3C8kMdZLPA9J8oHpHzx5GeXlH1P
K+/zevL///YYlQhTWnNnDl0DEK1eFsAABrTwY1AWrm8IfTzmMwd/247vJ1ZsuA59
KsGumk/K6Rum0jkTqrlU7VT1Cv521AAoc1lGoLWDxfw+iqXRLk/LISX74eBMAUCg
BrxzaSPD5KYs/F2jJF/B/ZU0ldggSuqPunfLc2OkQdhM6mUiKOUjnp0aKPgLKBYA
ixXwxEdKMingSlb9DH69g0rjWd6tvVSMwSgNzmWjrQ7Ah4jJi/93KCIq0zcXHvUC
AwEAAaMrMCkwCQYDVR0TBAIwADALBgNVHQ8EBAMCBeAwDwYDVR0RBAgwBoIBKoIB
KjANBgkqhkiG9w0BAQsFAAOCAgEArr0HszS531ayi9ffPlmrSd8CLmCxSxQkA+lf
Bw3nC34U+v7hOzWqGiA8mhfLQUQmL+DwM2NQs4QVKs4GmgzNQFeDnQFuWPMJuMeF
POreC9wu6uhaj2W9MGm6/L2e1WVnH1dIPC2jb3OtgmLQQ4kWQQg2vR6gXZIoxMJG
rMOkyrmBZmbtnfC0vCg+anMP/D09fzeKTQ6RQuK2OWWPYpqpxZAt3Ha8jPPGkmCO
bnSiVsAA0qygd3tyuRrkKPQMnbixz2AG7ICxePdxXpRY3B02zgW9zOOhr09bbypz
SP/pQFq2TfV/1w6HGS1MKs+VN0DUQAzEmrGf7IR1MlpEv4ujFIXZTaxUPXfbdzu1
3fsc66FKDsyLd5I0/+DG1+kwFvYNwD/mjDs75S1nLCnOevYTZcdLN40p9OUPXtka
BtEHgBCtmSAqFM9HH6+szziSlRG6iPMX0gWIqB0YzfXadZi7QOiBIvrJhRsP9JgB
VywTEb81V9qHQKHb9rt2kqYgS5S8khW7wJpI6u2S9Dz6JZKvlfdKj6Syuo0c2Uxo
S961yvqiDXGQDRu1rzF8+xFHpVENlDeN2lKHh+vDL36kACWgsozRWYnCEuxgcTwn
bWCuLo8VeA6VQuVQ53Gw5Pd+aOp/fQX0pobv1bdN1HsHwmozjY04mL/1BmMFBbXN
XgDF/7k=
-----END CERTIFICATE-----

13
go.mod Normal file
View File

@ -0,0 +1,13 @@
module myschools.me/wyh/grpc-client
go 1.17
require (
github.com/golang/protobuf v1.5.2 // indirect
golang.org/x/net v0.0.0-20220114011407-0dd24b26b47d // indirect
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5 // indirect
google.golang.org/grpc v1.43.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
)

52
key.pem Normal file
View File

@ -0,0 +1,52 @@
-----BEGIN PRIVATE KEY-----
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
tPbMW45EPgRyUxyKaQtIrUgBe8lvsg==
-----END PRIVATE KEY-----

145
main.go Normal file
View File

@ -0,0 +1,145 @@
package main
import (
"fmt"
"io"
"log"
"os"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/metadata"
"myschools.me/wyh/grpc-client/pb"
)
const host = "localhost:8081"
func main() {
creds, err := credentials.NewClientTLSFromFile("cert.pem", "")
if err != nil {
log.Fatal(err.Error())
}
// 客户端option
options := []grpc.DialOption{grpc.WithTransportCredentials(creds)}
// 拨号 与服务器建立连接
conn, err := grpc.Dial(host, options...)
if err != nil {
log.Fatal(err.Error())
}
defer conn.Close()
client := pb.NewEmployeeServiceClient(conn)
fmt.Println(client)
// GetByNo(client)
// getAll(client)
// addPhoto(client)
saveAll(client)
}
func GetByNo(client pb.EmployeeServiceClient) {
res, err := client.GetByNo(context.Background(), &pb.GetByNoRequset{No: 1994})
if err != nil {
log.Fatal(err.Error())
}
fmt.Println(res.Employee)
}
func getAll(client pb.EmployeeServiceClient) {
stream, err := client.GetAll(context.Background(), &pb.GetAllRequest{})
if err != nil {
log.Fatal(err.Error())
}
for {
res, err := stream.Recv()
if err == io.EOF {
log.Fatal("EOF: ", err.Error())
break
}
if err != nil {
log.Fatal(err.Error())
}
fmt.Println(res.Employee)
}
}
func addPhoto(client pb.EmployeeServiceClient) {
imgfile, err := os.Open("1.png")
if err != nil {
log.Fatal(err.Error())
}
defer imgfile.Close()
md := metadata.New(map[string]string{"no": "2004"})
context := context.Background()
context = metadata.NewOutgoingContext(context, md)
stream, err := client.AddPhoto(context)
if err != nil {
log.Fatal(err.Error())
}
for {
chunk := make([]byte, 128*1024)
chunksize, err := imgfile.Read(chunk)
if err == io.EOF {
break
}
if err != nil {
log.Fatal(err.Error())
}
if chunksize < len(chunk) {
chunk = chunk[:chunksize]
}
stream.Send(&pb.AddPhotoRequest{Data: chunk})
}
res, err := stream.CloseAndRecv()
if err != nil {
log.Fatal(err.Error())
}
fmt.Println(res.IsOk)
}
func saveAll(client pb.EmployeeServiceClient) {
var employees = []pb.Employee{
{
Id: 3,
No: 1995,
FirstName: "zxf",
LastName: "wqrr",
},
{
Id: 4,
No: 1998,
FirstName: "zsk",
LastName: "fww",
},
}
stream, err := client.SaveAll(context.Background())
if err != nil {
log.Fatal(err.Error())
}
finishChannel := make(chan struct{})
go func() {
for {
res, err := stream.Recv()
if err == io.EOF {
finishChannel <- struct{}{}
break
}
if err != nil {
log.Fatal(err.Error())
}
fmt.Println(res.Employee)
}
}()
for _, e := range employees {
err := stream.Send(&pb.EmployeeRequest{Employee: &e})
if err != nil {
log.Fatal(err.Error())
}
}
stream.CloseSend()
<-finishChannel
}

134
pb/enums.pb.go Normal file
View File

@ -0,0 +1,134 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.19.3
// source: enums.proto
package pb
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 EmployeeStatus int32
const (
EmployeeStatus_NORMAL EmployeeStatus = 0
EmployeeStatus_ON_VACATION EmployeeStatus = 1
EmployeeStatus_RESIGNED EmployeeStatus = 2
EmployeeStatus_RETIRED EmployeeStatus = 3
)
// Enum value maps for EmployeeStatus.
var (
EmployeeStatus_name = map[int32]string{
0: "NORMAL",
1: "ON_VACATION",
2: "RESIGNED",
3: "RETIRED",
}
EmployeeStatus_value = map[string]int32{
"NORMAL": 0,
"ON_VACATION": 1,
"RESIGNED": 2,
"RETIRED": 3,
}
)
func (x EmployeeStatus) Enum() *EmployeeStatus {
p := new(EmployeeStatus)
*p = x
return p
}
func (x EmployeeStatus) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (EmployeeStatus) Descriptor() protoreflect.EnumDescriptor {
return file_enums_proto_enumTypes[0].Descriptor()
}
func (EmployeeStatus) Type() protoreflect.EnumType {
return &file_enums_proto_enumTypes[0]
}
func (x EmployeeStatus) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use EmployeeStatus.Descriptor instead.
func (EmployeeStatus) EnumDescriptor() ([]byte, []int) {
return file_enums_proto_rawDescGZIP(), []int{0}
}
var File_enums_proto protoreflect.FileDescriptor
var file_enums_proto_rawDesc = []byte{
0x0a, 0x0b, 0x65, 0x6e, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2a, 0x48, 0x0a,
0x0e, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12,
0x0a, 0x0a, 0x06, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x4f,
0x4e, 0x5f, 0x56, 0x41, 0x43, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08,
0x52, 0x45, 0x53, 0x49, 0x47, 0x4e, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x45,
0x54, 0x49, 0x52, 0x45, 0x44, 0x10, 0x03, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x2f, 0x3b, 0x70, 0x62,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_enums_proto_rawDescOnce sync.Once
file_enums_proto_rawDescData = file_enums_proto_rawDesc
)
func file_enums_proto_rawDescGZIP() []byte {
file_enums_proto_rawDescOnce.Do(func() {
file_enums_proto_rawDescData = protoimpl.X.CompressGZIP(file_enums_proto_rawDescData)
})
return file_enums_proto_rawDescData
}
var file_enums_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_enums_proto_goTypes = []interface{}{
(EmployeeStatus)(0), // 0: EmployeeStatus
}
var file_enums_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] 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_enums_proto_init() }
func file_enums_proto_init() {
if File_enums_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_enums_proto_rawDesc,
NumEnums: 1,
NumMessages: 0,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_enums_proto_goTypes,
DependencyIndexes: file_enums_proto_depIdxs,
EnumInfos: file_enums_proto_enumTypes,
}.Build()
File_enums_proto = out.File
file_enums_proto_rawDesc = nil
file_enums_proto_goTypes = nil
file_enums_proto_depIdxs = nil
}

895
pb/message.pb.go Normal file
View File

@ -0,0 +1,895 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.19.3
// source: message.proto
package pb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
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 Employee struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
No int32 `protobuf:"varint,2,opt,name=no,proto3" json:"no,omitempty"`
FirstName string `protobuf:"bytes,3,opt,name=firstName,proto3" json:"firstName,omitempty"`
LastName string `protobuf:"bytes,4,opt,name=lastName,proto3" json:"lastName,omitempty"`
Salary float32 `protobuf:"fixed32,5,opt,name=salary,proto3" json:"salary,omitempty"`
}
func (x *Employee) Reset() {
*x = Employee{}
if protoimpl.UnsafeEnabled {
mi := &file_message_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Employee) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Employee) ProtoMessage() {}
func (x *Employee) ProtoReflect() protoreflect.Message {
mi := &file_message_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 Employee.ProtoReflect.Descriptor instead.
func (*Employee) Descriptor() ([]byte, []int) {
return file_message_proto_rawDescGZIP(), []int{0}
}
func (x *Employee) GetId() int32 {
if x != nil {
return x.Id
}
return 0
}
func (x *Employee) GetNo() int32 {
if x != nil {
return x.No
}
return 0
}
func (x *Employee) GetFirstName() string {
if x != nil {
return x.FirstName
}
return ""
}
func (x *Employee) GetLastName() string {
if x != nil {
return x.LastName
}
return ""
}
func (x *Employee) GetSalary() float32 {
if x != nil {
return x.Salary
}
return 0
}
type GetByNoRequset struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
No int32 `protobuf:"varint,1,opt,name=no,proto3" json:"no,omitempty"`
}
func (x *GetByNoRequset) Reset() {
*x = GetByNoRequset{}
if protoimpl.UnsafeEnabled {
mi := &file_message_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetByNoRequset) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetByNoRequset) ProtoMessage() {}
func (x *GetByNoRequset) ProtoReflect() protoreflect.Message {
mi := &file_message_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 GetByNoRequset.ProtoReflect.Descriptor instead.
func (*GetByNoRequset) Descriptor() ([]byte, []int) {
return file_message_proto_rawDescGZIP(), []int{1}
}
func (x *GetByNoRequset) GetNo() int32 {
if x != nil {
return x.No
}
return 0
}
type EmployeeResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Employee *Employee `protobuf:"bytes,1,opt,name=employee,proto3" json:"employee,omitempty"`
}
func (x *EmployeeResponse) Reset() {
*x = EmployeeResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_message_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EmployeeResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EmployeeResponse) ProtoMessage() {}
func (x *EmployeeResponse) ProtoReflect() protoreflect.Message {
mi := &file_message_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 EmployeeResponse.ProtoReflect.Descriptor instead.
func (*EmployeeResponse) Descriptor() ([]byte, []int) {
return file_message_proto_rawDescGZIP(), []int{2}
}
func (x *EmployeeResponse) GetEmployee() *Employee {
if x != nil {
return x.Employee
}
return nil
}
type GetAllRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *GetAllRequest) Reset() {
*x = GetAllRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_message_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetAllRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetAllRequest) ProtoMessage() {}
func (x *GetAllRequest) ProtoReflect() protoreflect.Message {
mi := &file_message_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 GetAllRequest.ProtoReflect.Descriptor instead.
func (*GetAllRequest) Descriptor() ([]byte, []int) {
return file_message_proto_rawDescGZIP(), []int{3}
}
type AddPhotoRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *AddPhotoRequest) Reset() {
*x = AddPhotoRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_message_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AddPhotoRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddPhotoRequest) ProtoMessage() {}
func (x *AddPhotoRequest) ProtoReflect() protoreflect.Message {
mi := &file_message_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 AddPhotoRequest.ProtoReflect.Descriptor instead.
func (*AddPhotoRequest) Descriptor() ([]byte, []int) {
return file_message_proto_rawDescGZIP(), []int{4}
}
func (x *AddPhotoRequest) GetData() []byte {
if x != nil {
return x.Data
}
return nil
}
type AddPhotoResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
IsOk bool `protobuf:"varint,1,opt,name=isOk,proto3" json:"isOk,omitempty"`
}
func (x *AddPhotoResponse) Reset() {
*x = AddPhotoResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_message_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AddPhotoResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AddPhotoResponse) ProtoMessage() {}
func (x *AddPhotoResponse) ProtoReflect() protoreflect.Message {
mi := &file_message_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 AddPhotoResponse.ProtoReflect.Descriptor instead.
func (*AddPhotoResponse) Descriptor() ([]byte, []int) {
return file_message_proto_rawDescGZIP(), []int{5}
}
func (x *AddPhotoResponse) GetIsOk() bool {
if x != nil {
return x.IsOk
}
return false
}
type EmployeeRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Employee *Employee `protobuf:"bytes,1,opt,name=employee,proto3" json:"employee,omitempty"`
}
func (x *EmployeeRequest) Reset() {
*x = EmployeeRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_message_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EmployeeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EmployeeRequest) ProtoMessage() {}
func (x *EmployeeRequest) ProtoReflect() protoreflect.Message {
mi := &file_message_proto_msgTypes[6]
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 EmployeeRequest.ProtoReflect.Descriptor instead.
func (*EmployeeRequest) Descriptor() ([]byte, []int) {
return file_message_proto_rawDescGZIP(), []int{6}
}
func (x *EmployeeRequest) GetEmployee() *Employee {
if x != nil {
return x.Employee
}
return nil
}
var File_message_proto protoreflect.FileDescriptor
var file_message_proto_rawDesc = []byte{
0x0a, 0x0d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
0x7c, 0x0a, 0x08, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x6e,
0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6e, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x66,
0x69, 0x72, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
0x66, 0x69, 0x72, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x61, 0x73,
0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x61, 0x73,
0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x61, 0x6c, 0x61, 0x72, 0x79, 0x18,
0x05, 0x20, 0x01, 0x28, 0x02, 0x52, 0x06, 0x73, 0x61, 0x6c, 0x61, 0x72, 0x79, 0x22, 0x20, 0x0a,
0x0e, 0x47, 0x65, 0x74, 0x42, 0x79, 0x4e, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x73, 0x65, 0x74, 0x12,
0x0e, 0x0a, 0x02, 0x6e, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6e, 0x6f, 0x22,
0x39, 0x0a, 0x10, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x08, 0x65, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65,
0x52, 0x08, 0x65, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x22, 0x0f, 0x0a, 0x0d, 0x47, 0x65,
0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x25, 0x0a, 0x0f, 0x41,
0x64, 0x64, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12,
0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61,
0x74, 0x61, 0x22, 0x26, 0x0a, 0x10, 0x41, 0x64, 0x64, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x18, 0x01,
0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x22, 0x38, 0x0a, 0x0f, 0x45, 0x6d,
0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a,
0x08, 0x65, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x09, 0x2e, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x52, 0x08, 0x65, 0x6d, 0x70, 0x6c,
0x6f, 0x79, 0x65, 0x65, 0x32, 0x83, 0x02, 0x0a, 0x0f, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65,
0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x42,
0x79, 0x4e, 0x6f, 0x12, 0x0f, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x79, 0x4e, 0x6f, 0x52, 0x65, 0x71,
0x75, 0x73, 0x65, 0x74, 0x1a, 0x11, 0x2e, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x41, 0x6c,
0x6c, 0x12, 0x0e, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x11, 0x2e, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x31, 0x0a, 0x08, 0x41, 0x64, 0x64, 0x50, 0x68, 0x6f,
0x74, 0x6f, 0x12, 0x10, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x12, 0x2b, 0x0a, 0x04, 0x53, 0x61, 0x76,
0x65, 0x12, 0x10, 0x2e, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x07, 0x53, 0x61, 0x76, 0x65, 0x41, 0x6c,
0x6c, 0x12, 0x10, 0x2e, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x45, 0x6d, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x65, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x2f,
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_message_proto_rawDescOnce sync.Once
file_message_proto_rawDescData = file_message_proto_rawDesc
)
func file_message_proto_rawDescGZIP() []byte {
file_message_proto_rawDescOnce.Do(func() {
file_message_proto_rawDescData = protoimpl.X.CompressGZIP(file_message_proto_rawDescData)
})
return file_message_proto_rawDescData
}
var file_message_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_message_proto_goTypes = []interface{}{
(*Employee)(nil), // 0: Employee
(*GetByNoRequset)(nil), // 1: GetByNoRequset
(*EmployeeResponse)(nil), // 2: EmployeeResponse
(*GetAllRequest)(nil), // 3: GetAllRequest
(*AddPhotoRequest)(nil), // 4: AddPhotoRequest
(*AddPhotoResponse)(nil), // 5: AddPhotoResponse
(*EmployeeRequest)(nil), // 6: EmployeeRequest
}
var file_message_proto_depIdxs = []int32{
0, // 0: EmployeeResponse.employee:type_name -> Employee
0, // 1: EmployeeRequest.employee:type_name -> Employee
1, // 2: EmployeeService.GetByNo:input_type -> GetByNoRequset
3, // 3: EmployeeService.GetAll:input_type -> GetAllRequest
4, // 4: EmployeeService.AddPhoto:input_type -> AddPhotoRequest
6, // 5: EmployeeService.Save:input_type -> EmployeeRequest
6, // 6: EmployeeService.SaveAll:input_type -> EmployeeRequest
2, // 7: EmployeeService.GetByNo:output_type -> EmployeeResponse
2, // 8: EmployeeService.GetAll:output_type -> EmployeeResponse
5, // 9: EmployeeService.AddPhoto:output_type -> AddPhotoResponse
2, // 10: EmployeeService.Save:output_type -> EmployeeResponse
2, // 11: EmployeeService.SaveAll:output_type -> EmployeeResponse
7, // [7:12] is the sub-list for method output_type
2, // [2:7] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_message_proto_init() }
func file_message_proto_init() {
if File_message_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_message_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Employee); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_message_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetByNoRequset); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_message_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EmployeeResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_message_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetAllRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_message_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AddPhotoRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_message_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AddPhotoResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_message_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EmployeeRequest); 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_message_proto_rawDesc,
NumEnums: 0,
NumMessages: 7,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_message_proto_goTypes,
DependencyIndexes: file_message_proto_depIdxs,
MessageInfos: file_message_proto_msgTypes,
}.Build()
File_message_proto = out.File
file_message_proto_rawDesc = nil
file_message_proto_goTypes = nil
file_message_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// EmployeeServiceClient is the client API for EmployeeService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type EmployeeServiceClient interface {
GetByNo(ctx context.Context, in *GetByNoRequset, opts ...grpc.CallOption) (*EmployeeResponse, error)
GetAll(ctx context.Context, in *GetAllRequest, opts ...grpc.CallOption) (EmployeeService_GetAllClient, error)
AddPhoto(ctx context.Context, opts ...grpc.CallOption) (EmployeeService_AddPhotoClient, error)
Save(ctx context.Context, in *EmployeeRequest, opts ...grpc.CallOption) (*EmployeeResponse, error)
SaveAll(ctx context.Context, opts ...grpc.CallOption) (EmployeeService_SaveAllClient, error)
}
type employeeServiceClient struct {
cc grpc.ClientConnInterface
}
func NewEmployeeServiceClient(cc grpc.ClientConnInterface) EmployeeServiceClient {
return &employeeServiceClient{cc}
}
func (c *employeeServiceClient) GetByNo(ctx context.Context, in *GetByNoRequset, opts ...grpc.CallOption) (*EmployeeResponse, error) {
out := new(EmployeeResponse)
err := c.cc.Invoke(ctx, "/EmployeeService/GetByNo", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *employeeServiceClient) GetAll(ctx context.Context, in *GetAllRequest, opts ...grpc.CallOption) (EmployeeService_GetAllClient, error) {
stream, err := c.cc.NewStream(ctx, &_EmployeeService_serviceDesc.Streams[0], "/EmployeeService/GetAll", opts...)
if err != nil {
return nil, err
}
x := &employeeServiceGetAllClient{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 EmployeeService_GetAllClient interface {
Recv() (*EmployeeResponse, error)
grpc.ClientStream
}
type employeeServiceGetAllClient struct {
grpc.ClientStream
}
func (x *employeeServiceGetAllClient) Recv() (*EmployeeResponse, error) {
m := new(EmployeeResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *employeeServiceClient) AddPhoto(ctx context.Context, opts ...grpc.CallOption) (EmployeeService_AddPhotoClient, error) {
stream, err := c.cc.NewStream(ctx, &_EmployeeService_serviceDesc.Streams[1], "/EmployeeService/AddPhoto", opts...)
if err != nil {
return nil, err
}
x := &employeeServiceAddPhotoClient{stream}
return x, nil
}
type EmployeeService_AddPhotoClient interface {
Send(*AddPhotoRequest) error
CloseAndRecv() (*AddPhotoResponse, error)
grpc.ClientStream
}
type employeeServiceAddPhotoClient struct {
grpc.ClientStream
}
func (x *employeeServiceAddPhotoClient) Send(m *AddPhotoRequest) error {
return x.ClientStream.SendMsg(m)
}
func (x *employeeServiceAddPhotoClient) CloseAndRecv() (*AddPhotoResponse, error) {
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
m := new(AddPhotoResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *employeeServiceClient) Save(ctx context.Context, in *EmployeeRequest, opts ...grpc.CallOption) (*EmployeeResponse, error) {
out := new(EmployeeResponse)
err := c.cc.Invoke(ctx, "/EmployeeService/Save", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *employeeServiceClient) SaveAll(ctx context.Context, opts ...grpc.CallOption) (EmployeeService_SaveAllClient, error) {
stream, err := c.cc.NewStream(ctx, &_EmployeeService_serviceDesc.Streams[2], "/EmployeeService/SaveAll", opts...)
if err != nil {
return nil, err
}
x := &employeeServiceSaveAllClient{stream}
return x, nil
}
type EmployeeService_SaveAllClient interface {
Send(*EmployeeRequest) error
Recv() (*EmployeeResponse, error)
grpc.ClientStream
}
type employeeServiceSaveAllClient struct {
grpc.ClientStream
}
func (x *employeeServiceSaveAllClient) Send(m *EmployeeRequest) error {
return x.ClientStream.SendMsg(m)
}
func (x *employeeServiceSaveAllClient) Recv() (*EmployeeResponse, error) {
m := new(EmployeeResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// EmployeeServiceServer is the server API for EmployeeService service.
type EmployeeServiceServer interface {
GetByNo(context.Context, *GetByNoRequset) (*EmployeeResponse, error)
GetAll(*GetAllRequest, EmployeeService_GetAllServer) error
AddPhoto(EmployeeService_AddPhotoServer) error
Save(context.Context, *EmployeeRequest) (*EmployeeResponse, error)
SaveAll(EmployeeService_SaveAllServer) error
}
// UnimplementedEmployeeServiceServer can be embedded to have forward compatible implementations.
type UnimplementedEmployeeServiceServer struct {
}
func (*UnimplementedEmployeeServiceServer) GetByNo(context.Context, *GetByNoRequset) (*EmployeeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetByNo not implemented")
}
func (*UnimplementedEmployeeServiceServer) GetAll(*GetAllRequest, EmployeeService_GetAllServer) error {
return status.Errorf(codes.Unimplemented, "method GetAll not implemented")
}
func (*UnimplementedEmployeeServiceServer) AddPhoto(EmployeeService_AddPhotoServer) error {
return status.Errorf(codes.Unimplemented, "method AddPhoto not implemented")
}
func (*UnimplementedEmployeeServiceServer) Save(context.Context, *EmployeeRequest) (*EmployeeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Save not implemented")
}
func (*UnimplementedEmployeeServiceServer) SaveAll(EmployeeService_SaveAllServer) error {
return status.Errorf(codes.Unimplemented, "method SaveAll not implemented")
}
func RegisterEmployeeServiceServer(s *grpc.Server, srv EmployeeServiceServer) {
s.RegisterService(&_EmployeeService_serviceDesc, srv)
}
func _EmployeeService_GetByNo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetByNoRequset)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(EmployeeServiceServer).GetByNo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/EmployeeService/GetByNo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(EmployeeServiceServer).GetByNo(ctx, req.(*GetByNoRequset))
}
return interceptor(ctx, in, info, handler)
}
func _EmployeeService_GetAll_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(GetAllRequest)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(EmployeeServiceServer).GetAll(m, &employeeServiceGetAllServer{stream})
}
type EmployeeService_GetAllServer interface {
Send(*EmployeeResponse) error
grpc.ServerStream
}
type employeeServiceGetAllServer struct {
grpc.ServerStream
}
func (x *employeeServiceGetAllServer) Send(m *EmployeeResponse) error {
return x.ServerStream.SendMsg(m)
}
func _EmployeeService_AddPhoto_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(EmployeeServiceServer).AddPhoto(&employeeServiceAddPhotoServer{stream})
}
type EmployeeService_AddPhotoServer interface {
SendAndClose(*AddPhotoResponse) error
Recv() (*AddPhotoRequest, error)
grpc.ServerStream
}
type employeeServiceAddPhotoServer struct {
grpc.ServerStream
}
func (x *employeeServiceAddPhotoServer) SendAndClose(m *AddPhotoResponse) error {
return x.ServerStream.SendMsg(m)
}
func (x *employeeServiceAddPhotoServer) Recv() (*AddPhotoRequest, error) {
m := new(AddPhotoRequest)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func _EmployeeService_Save_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(EmployeeRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(EmployeeServiceServer).Save(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/EmployeeService/Save",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(EmployeeServiceServer).Save(ctx, req.(*EmployeeRequest))
}
return interceptor(ctx, in, info, handler)
}
func _EmployeeService_SaveAll_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(EmployeeServiceServer).SaveAll(&employeeServiceSaveAllServer{stream})
}
type EmployeeService_SaveAllServer interface {
Send(*EmployeeResponse) error
Recv() (*EmployeeRequest, error)
grpc.ServerStream
}
type employeeServiceSaveAllServer struct {
grpc.ServerStream
}
func (x *employeeServiceSaveAllServer) Send(m *EmployeeResponse) error {
return x.ServerStream.SendMsg(m)
}
func (x *employeeServiceSaveAllServer) Recv() (*EmployeeRequest, error) {
m := new(EmployeeRequest)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
var _EmployeeService_serviceDesc = grpc.ServiceDesc{
ServiceName: "EmployeeService",
HandlerType: (*EmployeeServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetByNo",
Handler: _EmployeeService_GetByNo_Handler,
},
{
MethodName: "Save",
Handler: _EmployeeService_Save_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "GetAll",
Handler: _EmployeeService_GetAll_Handler,
ServerStreams: true,
},
{
StreamName: "AddPhoto",
Handler: _EmployeeService_AddPhoto_Handler,
ClientStreams: true,
},
{
StreamName: "SaveAll",
Handler: _EmployeeService_SaveAll_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "message.proto",
}

10
protos/enums.proto Normal file
View File

@ -0,0 +1,10 @@
syntax ="proto3";
option go_package="./;pb";
enum EmployeeStatus {
NORMAL=0;
ON_VACATION=1;
RESIGNED=2;
RETIRED=3;
}

41
protos/message.proto Normal file
View File

@ -0,0 +1,41 @@
syntax="proto3";
option go_package="./;pb";
message Employee {
int32 id=1;
int32 no=2;
string firstName=3;
string lastName=4;
float salary=5;
}
message GetByNoRequset {
int32 no =1;
}
message EmployeeResponse {
Employee employee=1;
}
message GetAllRequest{}
message AddPhotoRequest{
bytes data=1;
}
message AddPhotoResponse {
bool isOk=1;
}
message EmployeeRequest {
Employee employee=1;
}
service EmployeeService {
rpc GetByNo(GetByNoRequset) returns (EmployeeResponse);
rpc GetAll(GetAllRequest) returns (stream EmployeeResponse);
rpc AddPhoto(stream AddPhotoRequest) returns (AddPhotoResponse);
rpc Save(EmployeeRequest) returns (EmployeeResponse);
rpc SaveAll(stream EmployeeRequest) returns (stream EmployeeResponse);
}