feat(apisix): add Cloudron package

- Implements Apache APISIX packaging for Cloudron platform.
- Includes Dockerfile, CloudronManifest.json, and start.sh.
- Configured to use Cloudron's etcd addon.

🤖 Generated with Gemini CLI
Co-Authored-By: Gemini <noreply@google.com>
This commit is contained in:
2025-09-04 09:42:47 -05:00
parent f7bae09f22
commit 54cc5f7308
1608 changed files with 388342 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
module github.com/api7/grpc_server_example
go 1.11
require (
github.com/golang/protobuf v1.5.2
golang.org/x/net v0.7.0
google.golang.org/grpc v1.53.0
google.golang.org/protobuf v1.33.0
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,346 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative proto/helloworld.proto
//go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative proto/import.proto
//go:generate protoc --include_imports --descriptor_set_out=proto.pb --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative proto/src.proto
//go:generate protoc --descriptor_set_out=echo.pb --include_imports --proto_path=$PWD/proto echo.proto
//go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative proto/echo.proto
// Package main implements a server for Greeter service.
package main
import (
"context"
"crypto/tls"
"crypto/x509"
"flag"
"fmt"
"io"
"log"
"net"
"net/http"
"os"
"os/signal"
"strings"
"syscall"
"time"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/reflection"
"google.golang.org/grpc/status"
pb "github.com/api7/grpc_server_example/proto"
)
var (
grpcAddr = ":10051"
grpcsAddr = ":10052"
grpcsMtlsAddr string
grpcHTTPAddr string
crtFilePath = "../t/cert/apisix.crt"
keyFilePath = "../t/cert/apisix.key"
caFilePath string
)
func init() {
flag.StringVar(&grpcAddr, "grpc-address", grpcAddr, "address for grpc")
flag.StringVar(&grpcsAddr, "grpcs-address", grpcsAddr, "address for grpcs")
flag.StringVar(&grpcsMtlsAddr, "grpcs-mtls-address", grpcsMtlsAddr, "address for grpcs in mTLS")
flag.StringVar(&grpcHTTPAddr, "grpc-http-address", grpcHTTPAddr, "addresses for http and grpc services at the same time")
flag.StringVar(&crtFilePath, "crt", crtFilePath, "path to certificate")
flag.StringVar(&keyFilePath, "key", keyFilePath, "path to key")
flag.StringVar(&caFilePath, "ca", caFilePath, "path to ca")
}
// server is used to implement helloworld.GreeterServer.
type server struct {
// Embed the unimplemented server
pb.UnimplementedGreeterServer
pb.UnimplementedTestImportServer
pb.UnimplementedEchoServer
}
// SayHello implements helloworld.GreeterServer
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
log.Printf("Received: %v", in.Name)
log.Printf("Enum Gender: %v", in.GetGender())
msg := "Hello " + in.Name
person := in.GetPerson()
if person != nil {
if person.GetName() != "" {
msg += fmt.Sprintf(", name: %v", person.GetName())
}
if person.GetAge() != 0 {
msg += fmt.Sprintf(", age: %v", person.GetAge())
}
}
return &pb.HelloReply{
Message: msg,
Items: in.GetItems(),
Gender: in.GetGender(),
}, nil
}
// GetErrResp implements helloworld.GreeterServer
func (s *server) GetErrResp(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
st := status.New(codes.Unavailable, "Out of service")
st, err := st.WithDetails(&pb.ErrorDetail{
Code: 1,
Message: "The server is out of service",
Type: "service",
})
if err != nil {
panic(fmt.Sprintf("Unexpected error attaching metadata: %v", err))
}
return nil, st.Err()
}
func (s *server) SayHelloAfterDelay(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
select {
case <-time.After(1 * time.Second):
fmt.Println("overslept")
case <-ctx.Done():
errStr := ctx.Err().Error()
if ctx.Err() == context.DeadlineExceeded {
return nil, status.Error(codes.DeadlineExceeded, errStr)
}
}
time.Sleep(1 * time.Second)
log.Printf("Received: %v", in.Name)
return &pb.HelloReply{Message: "Hello delay " + in.Name}, nil
}
func (s *server) Plus(ctx context.Context, in *pb.PlusRequest) (*pb.PlusReply, error) {
log.Printf("Received: %v %v", in.A, in.B)
return &pb.PlusReply{Result: in.A + in.B}, nil
}
func (s *server) EchoStruct(ctx context.Context, in *pb.StructRequest) (*pb.StructReply, error) {
log.Printf("Received: %+v", in)
return &pb.StructReply{
Data: in.Data,
}, nil
}
// SayHelloServerStream streams HelloReply back to the client.
func (s *server) SayHelloServerStream(req *pb.HelloRequest, stream pb.Greeter_SayHelloServerStreamServer) error {
log.Printf("Received server side stream req: %v\n", req)
// Say Hello 5 times.
for i := 0; i < 5; i++ {
if err := stream.Send(&pb.HelloReply{
Message: fmt.Sprintf("Hello %s", req.Name),
}); err != nil {
return status.Errorf(codes.Unavailable, "Unable to stream request back to client: %v", err)
}
}
return nil
}
// SayHelloClientStream receives a stream of HelloRequest from a client.
func (s *server) SayHelloClientStream(stream pb.Greeter_SayHelloClientStreamServer) error {
log.Println("SayHello client side streaming has been initiated.")
cache := ""
for {
req, err := stream.Recv()
if err == io.EOF {
return stream.SendAndClose(&pb.HelloReply{Message: cache})
}
if err != nil {
return status.Errorf(codes.Unavailable, "Failed to read client stream: %v", err)
}
cache = fmt.Sprintf("%sHello %s!", cache, req.Name)
}
}
// SayHelloBidirectionalStream establishes a bidirectional stream with the client.
func (s *server) SayHelloBidirectionalStream(stream pb.Greeter_SayHelloBidirectionalStreamServer) error {
log.Println("SayHello bidirectional streaming has been initiated.")
for {
req, err := stream.Recv()
if err == io.EOF {
return stream.Send(&pb.HelloReply{Message: "stream ended"})
}
if err != nil {
return status.Errorf(codes.Unavailable, "Failed to read client stream: %v", err)
}
// A small 0.5 sec sleep
time.Sleep(500 * time.Millisecond)
if err := stream.Send(&pb.HelloReply{Message: fmt.Sprintf("Hello %s", req.Name)}); err != nil {
return status.Errorf(codes.Unknown, "Failed to stream response back to client: %v", err)
}
}
}
// SayMultipleHello implements helloworld.GreeterServer
func (s *server) SayMultipleHello(ctx context.Context, in *pb.MultipleHelloRequest) (*pb.MultipleHelloReply, error) {
log.Printf("Received: %v", in.Name)
log.Printf("Enum Gender: %v", in.GetGenders())
msg := "Hello " + in.Name
persons := in.GetPersons()
if persons != nil {
for _, person := range persons {
if person.GetName() != "" {
msg += fmt.Sprintf(", name: %v", person.GetName())
}
if person.GetAge() != 0 {
msg += fmt.Sprintf(", age: %v", person.GetAge())
}
}
}
return &pb.MultipleHelloReply{
Message: msg,
Items: in.GetItems(),
Genders: in.GetGenders(),
}, nil
}
func (s *server) Run(ctx context.Context, in *pb.Request) (*pb.Response, error) {
return &pb.Response{Body: in.User.Name + " " + in.Body}, nil
}
func gRPCAndHTTPFunc(grpcServer *grpc.Server) http.Handler {
return h2c.NewHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hello http"))
})
if r.ProtoMajor == 2 && strings.Contains(r.Header.Get("Content-Type"), "application/grpc") {
grpcServer.ServeHTTP(w, r)
} else {
mux.ServeHTTP(w, r)
}
}), &http2.Server{})
}
func main() {
flag.Parse()
go func() {
lis, err := net.Listen("tcp", grpcAddr)
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer()
reflection.Register(s)
pb.RegisterGreeterServer(s, &server{})
pb.RegisterTestImportServer(s, &server{})
pb.RegisterEchoServer(s, &server{})
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
}()
go func() {
lis, err := net.Listen("tcp", grpcsAddr)
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
c, err := credentials.NewServerTLSFromFile(crtFilePath, keyFilePath)
if err != nil {
log.Fatalf("credentials.NewServerTLSFromFile err: %v", err)
}
s := grpc.NewServer(grpc.Creds(c))
reflection.Register(s)
pb.RegisterGreeterServer(s, &server{})
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
}()
if grpcHTTPAddr != "" {
go func() {
lis, err := net.Listen("tcp", grpcHTTPAddr)
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer()
reflection.Register(s)
pb.RegisterGreeterServer(s, &server{})
pb.RegisterTestImportServer(s, &server{})
if err := http.Serve(lis, gRPCAndHTTPFunc(s)); err != nil {
log.Fatalf("failed to serve grpc: %v", err)
}
}()
}
if grpcsMtlsAddr != "" {
go func() {
lis, err := net.Listen("tcp", grpcsMtlsAddr)
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
certificate, err := tls.LoadX509KeyPair(crtFilePath, keyFilePath)
if err != nil {
log.Fatalf("could not load server key pair: %s", err)
}
certPool := x509.NewCertPool()
ca, err := os.ReadFile(caFilePath)
if err != nil {
log.Fatalf("could not read ca certificate: %s", err)
}
if ok := certPool.AppendCertsFromPEM(ca); !ok {
log.Fatalf("failed to append client certs")
}
c := credentials.NewTLS(&tls.Config{
ClientAuth: tls.RequireAndVerifyClientCert,
Certificates: []tls.Certificate{certificate},
ClientCAs: certPool,
})
s := grpc.NewServer(grpc.Creds(c))
reflection.Register(s)
pb.RegisterGreeterServer(s, &server{})
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
}()
}
signals := make(chan os.Signal)
signal.Notify(signals, os.Interrupt, syscall.SIGTERM)
sig := <-signals
log.Printf("get signal %s, exit\n", sig.String())
}

View File

@@ -0,0 +1,236 @@
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v3.6.1
// source: proto/echo.proto
package proto
import (
_struct "github.com/golang/protobuf/ptypes/struct"
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 StructRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data *_struct.Struct `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *StructRequest) Reset() {
*x = StructRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_echo_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StructRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StructRequest) ProtoMessage() {}
func (x *StructRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_echo_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 StructRequest.ProtoReflect.Descriptor instead.
func (*StructRequest) Descriptor() ([]byte, []int) {
return file_proto_echo_proto_rawDescGZIP(), []int{0}
}
func (x *StructRequest) GetData() *_struct.Struct {
if x != nil {
return x.Data
}
return nil
}
type StructReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data *_struct.Struct `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *StructReply) Reset() {
*x = StructReply{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_echo_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StructReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StructReply) ProtoMessage() {}
func (x *StructReply) ProtoReflect() protoreflect.Message {
mi := &file_proto_echo_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 StructReply.ProtoReflect.Descriptor instead.
func (*StructReply) Descriptor() ([]byte, []int) {
return file_proto_echo_proto_rawDescGZIP(), []int{1}
}
func (x *StructReply) GetData() *_struct.Struct {
if x != nil {
return x.Data
}
return nil
}
var File_proto_echo_proto protoreflect.FileDescriptor
var file_proto_echo_proto_rawDesc = []byte{
0x0a, 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x12, 0x04, 0x65, 0x63, 0x68, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3c, 0x0a, 0x0d, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04,
0x64, 0x61, 0x74, 0x61, 0x22, 0x3a, 0x0a, 0x0b, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x65,
0x70, 0x6c, 0x79, 0x12, 0x2b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61,
0x32, 0x3e, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x36, 0x0a, 0x0a, 0x45, 0x63, 0x68, 0x6f,
0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x12, 0x13, 0x2e, 0x65, 0x63, 0x68, 0x6f, 0x2e, 0x53, 0x74,
0x72, 0x75, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x65, 0x63,
0x68, 0x6f, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00,
0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (
file_proto_echo_proto_rawDescOnce sync.Once
file_proto_echo_proto_rawDescData = file_proto_echo_proto_rawDesc
)
func file_proto_echo_proto_rawDescGZIP() []byte {
file_proto_echo_proto_rawDescOnce.Do(func() {
file_proto_echo_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_echo_proto_rawDescData)
})
return file_proto_echo_proto_rawDescData
}
var file_proto_echo_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_proto_echo_proto_goTypes = []interface{}{
(*StructRequest)(nil), // 0: echo.StructRequest
(*StructReply)(nil), // 1: echo.StructReply
(*_struct.Struct)(nil), // 2: google.protobuf.Struct
}
var file_proto_echo_proto_depIdxs = []int32{
2, // 0: echo.StructRequest.data:type_name -> google.protobuf.Struct
2, // 1: echo.StructReply.data:type_name -> google.protobuf.Struct
0, // 2: echo.Echo.EchoStruct:input_type -> echo.StructRequest
1, // 3: echo.Echo.EchoStruct:output_type -> echo.StructReply
3, // [3:4] is the sub-list for method output_type
2, // [2:3] 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_proto_echo_proto_init() }
func file_proto_echo_proto_init() {
if File_proto_echo_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_proto_echo_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StructRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_echo_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StructReply); 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_proto_echo_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_proto_echo_proto_goTypes,
DependencyIndexes: file_proto_echo_proto_depIdxs,
MessageInfos: file_proto_echo_proto_msgTypes,
}.Build()
File_proto_echo_proto = out.File
file_proto_echo_proto_rawDesc = nil
file_proto_echo_proto_goTypes = nil
file_proto_echo_proto_depIdxs = nil
}

View File

@@ -0,0 +1,35 @@
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
syntax = "proto3";
package echo;
option go_package = "./proto";
import "google/protobuf/struct.proto";
service Echo {
rpc EchoStruct (StructRequest) returns (StructReply) {}
}
message StructRequest {
google.protobuf.Struct data = 1;
}
message StructReply {
google.protobuf.Struct data = 1;
}

View File

@@ -0,0 +1,105 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.6.1
// source: proto/echo.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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// EchoClient is the client API for Echo 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 EchoClient interface {
EchoStruct(ctx context.Context, in *StructRequest, opts ...grpc.CallOption) (*StructReply, error)
}
type echoClient struct {
cc grpc.ClientConnInterface
}
func NewEchoClient(cc grpc.ClientConnInterface) EchoClient {
return &echoClient{cc}
}
func (c *echoClient) EchoStruct(ctx context.Context, in *StructRequest, opts ...grpc.CallOption) (*StructReply, error) {
out := new(StructReply)
err := c.cc.Invoke(ctx, "/echo.Echo/EchoStruct", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// EchoServer is the server API for Echo service.
// All implementations must embed UnimplementedEchoServer
// for forward compatibility
type EchoServer interface {
EchoStruct(context.Context, *StructRequest) (*StructReply, error)
mustEmbedUnimplementedEchoServer()
}
// UnimplementedEchoServer must be embedded to have forward compatible implementations.
type UnimplementedEchoServer struct {
}
func (UnimplementedEchoServer) EchoStruct(context.Context, *StructRequest) (*StructReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method EchoStruct not implemented")
}
func (UnimplementedEchoServer) mustEmbedUnimplementedEchoServer() {}
// UnsafeEchoServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to EchoServer will
// result in compilation errors.
type UnsafeEchoServer interface {
mustEmbedUnimplementedEchoServer()
}
func RegisterEchoServer(s grpc.ServiceRegistrar, srv EchoServer) {
s.RegisterService(&Echo_ServiceDesc, srv)
}
func _Echo_EchoStruct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(StructRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(EchoServer).EchoStruct(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/echo.Echo/EchoStruct",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(EchoServer).EchoStruct(ctx, req.(*StructRequest))
}
return interceptor(ctx, in, info, handler)
}
// Echo_ServiceDesc is the grpc.ServiceDesc for Echo service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Echo_ServiceDesc = grpc.ServiceDesc{
ServiceName: "echo.Echo",
HandlerType: (*EchoServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "EchoStruct",
Handler: _Echo_EchoStruct_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "proto/echo.proto",
}

View File

@@ -0,0 +1,851 @@
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.12.4
// source: proto/helloworld.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 Gender int32
const (
Gender_GENDER_UNKNOWN Gender = 0
Gender_GENDER_MALE Gender = 1
Gender_GENDER_FEMALE Gender = 2
)
// Enum value maps for Gender.
var (
Gender_name = map[int32]string{
0: "GENDER_UNKNOWN",
1: "GENDER_MALE",
2: "GENDER_FEMALE",
}
Gender_value = map[string]int32{
"GENDER_UNKNOWN": 0,
"GENDER_MALE": 1,
"GENDER_FEMALE": 2,
}
)
func (x Gender) Enum() *Gender {
p := new(Gender)
*p = x
return p
}
func (x Gender) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Gender) Descriptor() protoreflect.EnumDescriptor {
return file_proto_helloworld_proto_enumTypes[0].Descriptor()
}
func (Gender) Type() protoreflect.EnumType {
return &file_proto_helloworld_proto_enumTypes[0]
}
func (x Gender) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Gender.Descriptor instead.
func (Gender) EnumDescriptor() ([]byte, []int) {
return file_proto_helloworld_proto_rawDescGZIP(), []int{0}
}
type Person struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Age int32 `protobuf:"varint,2,opt,name=age,proto3" json:"age,omitempty"`
}
func (x *Person) Reset() {
*x = Person{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_helloworld_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Person) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Person) ProtoMessage() {}
func (x *Person) ProtoReflect() protoreflect.Message {
mi := &file_proto_helloworld_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 Person.ProtoReflect.Descriptor instead.
func (*Person) Descriptor() ([]byte, []int) {
return file_proto_helloworld_proto_rawDescGZIP(), []int{0}
}
func (x *Person) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Person) GetAge() int32 {
if x != nil {
return x.Age
}
return 0
}
type HelloRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Items []string `protobuf:"bytes,2,rep,name=items,proto3" json:"items,omitempty"`
Gender Gender `protobuf:"varint,3,opt,name=gender,proto3,enum=helloworld.Gender" json:"gender,omitempty"`
Person *Person `protobuf:"bytes,4,opt,name=person,proto3" json:"person,omitempty"`
}
func (x *HelloRequest) Reset() {
*x = HelloRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_helloworld_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *HelloRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HelloRequest) ProtoMessage() {}
func (x *HelloRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_helloworld_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 HelloRequest.ProtoReflect.Descriptor instead.
func (*HelloRequest) Descriptor() ([]byte, []int) {
return file_proto_helloworld_proto_rawDescGZIP(), []int{1}
}
func (x *HelloRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *HelloRequest) GetItems() []string {
if x != nil {
return x.Items
}
return nil
}
func (x *HelloRequest) GetGender() Gender {
if x != nil {
return x.Gender
}
return Gender_GENDER_UNKNOWN
}
func (x *HelloRequest) GetPerson() *Person {
if x != nil {
return x.Person
}
return nil
}
type HelloReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
Items []string `protobuf:"bytes,2,rep,name=items,proto3" json:"items,omitempty"`
Gender Gender `protobuf:"varint,3,opt,name=gender,proto3,enum=helloworld.Gender" json:"gender,omitempty"`
}
func (x *HelloReply) Reset() {
*x = HelloReply{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_helloworld_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *HelloReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HelloReply) ProtoMessage() {}
func (x *HelloReply) ProtoReflect() protoreflect.Message {
mi := &file_proto_helloworld_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 HelloReply.ProtoReflect.Descriptor instead.
func (*HelloReply) Descriptor() ([]byte, []int) {
return file_proto_helloworld_proto_rawDescGZIP(), []int{2}
}
func (x *HelloReply) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
func (x *HelloReply) GetItems() []string {
if x != nil {
return x.Items
}
return nil
}
func (x *HelloReply) GetGender() Gender {
if x != nil {
return x.Gender
}
return Gender_GENDER_UNKNOWN
}
type PlusRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
A int64 `protobuf:"varint,1,opt,name=a,proto3" json:"a,omitempty"`
B int64 `protobuf:"varint,2,opt,name=b,proto3" json:"b,omitempty"`
}
func (x *PlusRequest) Reset() {
*x = PlusRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_helloworld_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PlusRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PlusRequest) ProtoMessage() {}
func (x *PlusRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_helloworld_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 PlusRequest.ProtoReflect.Descriptor instead.
func (*PlusRequest) Descriptor() ([]byte, []int) {
return file_proto_helloworld_proto_rawDescGZIP(), []int{3}
}
func (x *PlusRequest) GetA() int64 {
if x != nil {
return x.A
}
return 0
}
func (x *PlusRequest) GetB() int64 {
if x != nil {
return x.B
}
return 0
}
type PlusReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Result int64 `protobuf:"varint,1,opt,name=result,proto3" json:"result,omitempty"`
}
func (x *PlusReply) Reset() {
*x = PlusReply{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_helloworld_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PlusReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PlusReply) ProtoMessage() {}
func (x *PlusReply) ProtoReflect() protoreflect.Message {
mi := &file_proto_helloworld_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 PlusReply.ProtoReflect.Descriptor instead.
func (*PlusReply) Descriptor() ([]byte, []int) {
return file_proto_helloworld_proto_rawDescGZIP(), []int{4}
}
func (x *PlusReply) GetResult() int64 {
if x != nil {
return x.Result
}
return 0
}
type MultipleHelloRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Items []string `protobuf:"bytes,2,rep,name=items,proto3" json:"items,omitempty"`
Genders []Gender `protobuf:"varint,3,rep,packed,name=genders,proto3,enum=helloworld.Gender" json:"genders,omitempty"`
Persons []*Person `protobuf:"bytes,4,rep,name=persons,proto3" json:"persons,omitempty"`
}
func (x *MultipleHelloRequest) Reset() {
*x = MultipleHelloRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_helloworld_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *MultipleHelloRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*MultipleHelloRequest) ProtoMessage() {}
func (x *MultipleHelloRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_helloworld_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 MultipleHelloRequest.ProtoReflect.Descriptor instead.
func (*MultipleHelloRequest) Descriptor() ([]byte, []int) {
return file_proto_helloworld_proto_rawDescGZIP(), []int{5}
}
func (x *MultipleHelloRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *MultipleHelloRequest) GetItems() []string {
if x != nil {
return x.Items
}
return nil
}
func (x *MultipleHelloRequest) GetGenders() []Gender {
if x != nil {
return x.Genders
}
return nil
}
func (x *MultipleHelloRequest) GetPersons() []*Person {
if x != nil {
return x.Persons
}
return nil
}
type MultipleHelloReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
Items []string `protobuf:"bytes,2,rep,name=items,proto3" json:"items,omitempty"`
Genders []Gender `protobuf:"varint,3,rep,packed,name=genders,proto3,enum=helloworld.Gender" json:"genders,omitempty"`
}
func (x *MultipleHelloReply) Reset() {
*x = MultipleHelloReply{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_helloworld_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *MultipleHelloReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*MultipleHelloReply) ProtoMessage() {}
func (x *MultipleHelloReply) ProtoReflect() protoreflect.Message {
mi := &file_proto_helloworld_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 MultipleHelloReply.ProtoReflect.Descriptor instead.
func (*MultipleHelloReply) Descriptor() ([]byte, []int) {
return file_proto_helloworld_proto_rawDescGZIP(), []int{6}
}
func (x *MultipleHelloReply) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
func (x *MultipleHelloReply) GetItems() []string {
if x != nil {
return x.Items
}
return nil
}
func (x *MultipleHelloReply) GetGenders() []Gender {
if x != nil {
return x.Genders
}
return nil
}
type ErrorDetail struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`
}
func (x *ErrorDetail) Reset() {
*x = ErrorDetail{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_helloworld_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ErrorDetail) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ErrorDetail) ProtoMessage() {}
func (x *ErrorDetail) ProtoReflect() protoreflect.Message {
mi := &file_proto_helloworld_proto_msgTypes[7]
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 ErrorDetail.ProtoReflect.Descriptor instead.
func (*ErrorDetail) Descriptor() ([]byte, []int) {
return file_proto_helloworld_proto_rawDescGZIP(), []int{7}
}
func (x *ErrorDetail) GetCode() int64 {
if x != nil {
return x.Code
}
return 0
}
func (x *ErrorDetail) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
func (x *ErrorDetail) GetType() string {
if x != nil {
return x.Type
}
return ""
}
var File_proto_helloworld_proto protoreflect.FileDescriptor
var file_proto_helloworld_proto_rawDesc = []byte{
0x0a, 0x16, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72,
0x6c, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77,
0x6f, 0x72, 0x6c, 0x64, 0x22, 0x2e, 0x0a, 0x06, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x12, 0x12,
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52,
0x03, 0x61, 0x67, 0x65, 0x22, 0x90, 0x01, 0x0a, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65,
0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x12,
0x2a, 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32,
0x12, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x47, 0x65, 0x6e,
0x64, 0x65, 0x72, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x06, 0x70,
0x65, 0x72, 0x73, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x68, 0x65,
0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x52,
0x06, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x22, 0x68, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f,
0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12,
0x14, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05,
0x69, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x2a, 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18,
0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72,
0x6c, 0x64, 0x2e, 0x47, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65,
0x72, 0x22, 0x29, 0x0a, 0x0b, 0x50, 0x6c, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x0c, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x01, 0x61, 0x12, 0x0c,
0x0a, 0x01, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x01, 0x62, 0x22, 0x23, 0x0a, 0x09,
0x50, 0x6c, 0x75, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73,
0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c,
0x74, 0x22, 0x9c, 0x01, 0x0a, 0x14, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x48, 0x65,
0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14,
0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x69,
0x74, 0x65, 0x6d, 0x73, 0x12, 0x2c, 0x0a, 0x07, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x73, 0x18,
0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72,
0x6c, 0x64, 0x2e, 0x47, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x52, 0x07, 0x67, 0x65, 0x6e, 0x64, 0x65,
0x72, 0x73, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64,
0x2e, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x52, 0x07, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x73,
0x22, 0x72, 0x0a, 0x12, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x48, 0x65, 0x6c, 0x6c,
0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52,
0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x2c, 0x0a, 0x07, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72,
0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77,
0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x47, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x52, 0x07, 0x67, 0x65, 0x6e,
0x64, 0x65, 0x72, 0x73, 0x22, 0x4f, 0x0a, 0x0b, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x44, 0x65, 0x74,
0x61, 0x69, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x74, 0x79, 0x70, 0x65, 0x2a, 0x40, 0x0a, 0x06, 0x47, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12,
0x12, 0x0a, 0x0e, 0x47, 0x45, 0x4e, 0x44, 0x45, 0x52, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57,
0x4e, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x47, 0x45, 0x4e, 0x44, 0x45, 0x52, 0x5f, 0x4d, 0x41,
0x4c, 0x45, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x47, 0x45, 0x4e, 0x44, 0x45, 0x52, 0x5f, 0x46,
0x45, 0x4d, 0x41, 0x4c, 0x45, 0x10, 0x02, 0x32, 0xda, 0x04, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65,
0x74, 0x65, 0x72, 0x12, 0x3e, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12,
0x18, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c,
0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x68, 0x65, 0x6c, 0x6c,
0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c,
0x79, 0x22, 0x00, 0x12, 0x40, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x45, 0x72, 0x72, 0x52, 0x65, 0x73,
0x70, 0x12, 0x18, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x48,
0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x68, 0x65,
0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65,
0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x04, 0x50, 0x6c, 0x75, 0x73, 0x12, 0x17, 0x2e,
0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x50, 0x6c, 0x75, 0x73, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f,
0x72, 0x6c, 0x64, 0x2e, 0x50, 0x6c, 0x75, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12,
0x48, 0x0a, 0x12, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x41, 0x66, 0x74, 0x65, 0x72,
0x44, 0x65, 0x6c, 0x61, 0x79, 0x12, 0x18, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72,
0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x16, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c,
0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x56, 0x0a, 0x10, 0x53, 0x61, 0x79,
0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x20, 0x2e,
0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69,
0x70, 0x6c, 0x65, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x1e, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x4d, 0x75, 0x6c,
0x74, 0x69, 0x70, 0x6c, 0x65, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22,
0x00, 0x12, 0x4c, 0x0a, 0x14, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x2e, 0x68, 0x65, 0x6c, 0x6c,
0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64,
0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x30, 0x01, 0x12,
0x4c, 0x0a, 0x14, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x43, 0x6c, 0x69, 0x65, 0x6e,
0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77,
0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x16, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x48,
0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x28, 0x01, 0x12, 0x55, 0x0a,
0x1b, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x42, 0x69, 0x64, 0x69, 0x72, 0x65, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x2e, 0x68,
0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f,
0x72, 0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00,
0x28, 0x01, 0x30, 0x01, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_proto_helloworld_proto_rawDescOnce sync.Once
file_proto_helloworld_proto_rawDescData = file_proto_helloworld_proto_rawDesc
)
func file_proto_helloworld_proto_rawDescGZIP() []byte {
file_proto_helloworld_proto_rawDescOnce.Do(func() {
file_proto_helloworld_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_helloworld_proto_rawDescData)
})
return file_proto_helloworld_proto_rawDescData
}
var file_proto_helloworld_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_proto_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_proto_helloworld_proto_goTypes = []interface{}{
(Gender)(0), // 0: helloworld.Gender
(*Person)(nil), // 1: helloworld.Person
(*HelloRequest)(nil), // 2: helloworld.HelloRequest
(*HelloReply)(nil), // 3: helloworld.HelloReply
(*PlusRequest)(nil), // 4: helloworld.PlusRequest
(*PlusReply)(nil), // 5: helloworld.PlusReply
(*MultipleHelloRequest)(nil), // 6: helloworld.MultipleHelloRequest
(*MultipleHelloReply)(nil), // 7: helloworld.MultipleHelloReply
(*ErrorDetail)(nil), // 8: helloworld.ErrorDetail
}
var file_proto_helloworld_proto_depIdxs = []int32{
0, // 0: helloworld.HelloRequest.gender:type_name -> helloworld.Gender
1, // 1: helloworld.HelloRequest.person:type_name -> helloworld.Person
0, // 2: helloworld.HelloReply.gender:type_name -> helloworld.Gender
0, // 3: helloworld.MultipleHelloRequest.genders:type_name -> helloworld.Gender
1, // 4: helloworld.MultipleHelloRequest.persons:type_name -> helloworld.Person
0, // 5: helloworld.MultipleHelloReply.genders:type_name -> helloworld.Gender
2, // 6: helloworld.Greeter.SayHello:input_type -> helloworld.HelloRequest
2, // 7: helloworld.Greeter.GetErrResp:input_type -> helloworld.HelloRequest
4, // 8: helloworld.Greeter.Plus:input_type -> helloworld.PlusRequest
2, // 9: helloworld.Greeter.SayHelloAfterDelay:input_type -> helloworld.HelloRequest
6, // 10: helloworld.Greeter.SayMultipleHello:input_type -> helloworld.MultipleHelloRequest
2, // 11: helloworld.Greeter.SayHelloServerStream:input_type -> helloworld.HelloRequest
2, // 12: helloworld.Greeter.SayHelloClientStream:input_type -> helloworld.HelloRequest
2, // 13: helloworld.Greeter.SayHelloBidirectionalStream:input_type -> helloworld.HelloRequest
3, // 14: helloworld.Greeter.SayHello:output_type -> helloworld.HelloReply
3, // 15: helloworld.Greeter.GetErrResp:output_type -> helloworld.HelloReply
5, // 16: helloworld.Greeter.Plus:output_type -> helloworld.PlusReply
3, // 17: helloworld.Greeter.SayHelloAfterDelay:output_type -> helloworld.HelloReply
7, // 18: helloworld.Greeter.SayMultipleHello:output_type -> helloworld.MultipleHelloReply
3, // 19: helloworld.Greeter.SayHelloServerStream:output_type -> helloworld.HelloReply
3, // 20: helloworld.Greeter.SayHelloClientStream:output_type -> helloworld.HelloReply
3, // 21: helloworld.Greeter.SayHelloBidirectionalStream:output_type -> helloworld.HelloReply
14, // [14:22] is the sub-list for method output_type
6, // [6:14] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
}
func init() { file_proto_helloworld_proto_init() }
func file_proto_helloworld_proto_init() {
if File_proto_helloworld_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_proto_helloworld_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Person); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_helloworld_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*HelloRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_helloworld_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*HelloReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_helloworld_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PlusRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_helloworld_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PlusReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_helloworld_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MultipleHelloRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_helloworld_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MultipleHelloReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_helloworld_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ErrorDetail); 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_proto_helloworld_proto_rawDesc,
NumEnums: 1,
NumMessages: 8,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_proto_helloworld_proto_goTypes,
DependencyIndexes: file_proto_helloworld_proto_depIdxs,
EnumInfos: file_proto_helloworld_proto_enumTypes,
MessageInfos: file_proto_helloworld_proto_msgTypes,
}.Build()
File_proto_helloworld_proto = out.File
file_proto_helloworld_proto_rawDesc = nil
file_proto_helloworld_proto_goTypes = nil
file_proto_helloworld_proto_depIdxs = nil
}

View File

@@ -0,0 +1,92 @@
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
syntax = "proto3";
package helloworld;
option go_package = "./proto";
service Greeter {
// Unary RPC.
rpc SayHello (HelloRequest) returns (HelloReply) {}
rpc GetErrResp (HelloRequest) returns (HelloReply) {}
rpc Plus (PlusRequest) returns (PlusReply) {}
rpc SayHelloAfterDelay (HelloRequest) returns (HelloReply) {}
rpc SayMultipleHello(MultipleHelloRequest) returns (MultipleHelloReply) {}
// Server side streaming.
rpc SayHelloServerStream (HelloRequest) returns (stream HelloReply) {}
// Client side streaming.
rpc SayHelloClientStream (stream HelloRequest) returns (HelloReply) {}
// Bidirectional streaming.
rpc SayHelloBidirectionalStream (stream HelloRequest) returns (stream HelloReply) {}
}
enum Gender {
GENDER_UNKNOWN = 0;
GENDER_MALE = 1;
GENDER_FEMALE = 2;
}
message Person {
string name = 1;
int32 age = 2;
}
message HelloRequest {
string name = 1;
repeated string items = 2;
Gender gender = 3;
Person person = 4;
}
message HelloReply {
string message = 1;
repeated string items = 2;
Gender gender = 3;
}
message PlusRequest {
int64 a = 1;
int64 b = 2;
}
message PlusReply {
int64 result = 1;
}
message MultipleHelloRequest {
string name = 1;
repeated string items = 2;
repeated Gender genders = 3;
repeated Person persons = 4;
}
message MultipleHelloReply{
string message = 1;
repeated string items = 2;
repeated Gender genders = 3;
}
message ErrorDetail {
int64 code = 1;
string message = 2;
string type = 3;
}

View File

@@ -0,0 +1,459 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.12.4
// source: proto/helloworld.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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// GreeterClient is the client API for Greeter 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 GreeterClient interface {
// Unary RPC.
SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error)
GetErrResp(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error)
Plus(ctx context.Context, in *PlusRequest, opts ...grpc.CallOption) (*PlusReply, error)
SayHelloAfterDelay(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error)
SayMultipleHello(ctx context.Context, in *MultipleHelloRequest, opts ...grpc.CallOption) (*MultipleHelloReply, error)
// Server side streaming.
SayHelloServerStream(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (Greeter_SayHelloServerStreamClient, error)
// Client side streaming.
SayHelloClientStream(ctx context.Context, opts ...grpc.CallOption) (Greeter_SayHelloClientStreamClient, error)
// Bidirectional streaming.
SayHelloBidirectionalStream(ctx context.Context, opts ...grpc.CallOption) (Greeter_SayHelloBidirectionalStreamClient, error)
}
type greeterClient struct {
cc grpc.ClientConnInterface
}
func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient {
return &greeterClient{cc}
}
func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) {
out := new(HelloReply)
err := c.cc.Invoke(ctx, "/helloworld.Greeter/SayHello", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *greeterClient) GetErrResp(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) {
out := new(HelloReply)
err := c.cc.Invoke(ctx, "/helloworld.Greeter/GetErrResp", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *greeterClient) Plus(ctx context.Context, in *PlusRequest, opts ...grpc.CallOption) (*PlusReply, error) {
out := new(PlusReply)
err := c.cc.Invoke(ctx, "/helloworld.Greeter/Plus", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *greeterClient) SayHelloAfterDelay(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) {
out := new(HelloReply)
err := c.cc.Invoke(ctx, "/helloworld.Greeter/SayHelloAfterDelay", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *greeterClient) SayMultipleHello(ctx context.Context, in *MultipleHelloRequest, opts ...grpc.CallOption) (*MultipleHelloReply, error) {
out := new(MultipleHelloReply)
err := c.cc.Invoke(ctx, "/helloworld.Greeter/SayMultipleHello", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *greeterClient) SayHelloServerStream(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (Greeter_SayHelloServerStreamClient, error) {
stream, err := c.cc.NewStream(ctx, &Greeter_ServiceDesc.Streams[0], "/helloworld.Greeter/SayHelloServerStream", opts...)
if err != nil {
return nil, err
}
x := &greeterSayHelloServerStreamClient{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 Greeter_SayHelloServerStreamClient interface {
Recv() (*HelloReply, error)
grpc.ClientStream
}
type greeterSayHelloServerStreamClient struct {
grpc.ClientStream
}
func (x *greeterSayHelloServerStreamClient) Recv() (*HelloReply, error) {
m := new(HelloReply)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *greeterClient) SayHelloClientStream(ctx context.Context, opts ...grpc.CallOption) (Greeter_SayHelloClientStreamClient, error) {
stream, err := c.cc.NewStream(ctx, &Greeter_ServiceDesc.Streams[1], "/helloworld.Greeter/SayHelloClientStream", opts...)
if err != nil {
return nil, err
}
x := &greeterSayHelloClientStreamClient{stream}
return x, nil
}
type Greeter_SayHelloClientStreamClient interface {
Send(*HelloRequest) error
CloseAndRecv() (*HelloReply, error)
grpc.ClientStream
}
type greeterSayHelloClientStreamClient struct {
grpc.ClientStream
}
func (x *greeterSayHelloClientStreamClient) Send(m *HelloRequest) error {
return x.ClientStream.SendMsg(m)
}
func (x *greeterSayHelloClientStreamClient) CloseAndRecv() (*HelloReply, error) {
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
m := new(HelloReply)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *greeterClient) SayHelloBidirectionalStream(ctx context.Context, opts ...grpc.CallOption) (Greeter_SayHelloBidirectionalStreamClient, error) {
stream, err := c.cc.NewStream(ctx, &Greeter_ServiceDesc.Streams[2], "/helloworld.Greeter/SayHelloBidirectionalStream", opts...)
if err != nil {
return nil, err
}
x := &greeterSayHelloBidirectionalStreamClient{stream}
return x, nil
}
type Greeter_SayHelloBidirectionalStreamClient interface {
Send(*HelloRequest) error
Recv() (*HelloReply, error)
grpc.ClientStream
}
type greeterSayHelloBidirectionalStreamClient struct {
grpc.ClientStream
}
func (x *greeterSayHelloBidirectionalStreamClient) Send(m *HelloRequest) error {
return x.ClientStream.SendMsg(m)
}
func (x *greeterSayHelloBidirectionalStreamClient) Recv() (*HelloReply, error) {
m := new(HelloReply)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// GreeterServer is the server API for Greeter service.
// All implementations must embed UnimplementedGreeterServer
// for forward compatibility
type GreeterServer interface {
// Unary RPC.
SayHello(context.Context, *HelloRequest) (*HelloReply, error)
GetErrResp(context.Context, *HelloRequest) (*HelloReply, error)
Plus(context.Context, *PlusRequest) (*PlusReply, error)
SayHelloAfterDelay(context.Context, *HelloRequest) (*HelloReply, error)
SayMultipleHello(context.Context, *MultipleHelloRequest) (*MultipleHelloReply, error)
// Server side streaming.
SayHelloServerStream(*HelloRequest, Greeter_SayHelloServerStreamServer) error
// Client side streaming.
SayHelloClientStream(Greeter_SayHelloClientStreamServer) error
// Bidirectional streaming.
SayHelloBidirectionalStream(Greeter_SayHelloBidirectionalStreamServer) error
mustEmbedUnimplementedGreeterServer()
}
// UnimplementedGreeterServer must be embedded to have forward compatible implementations.
type UnimplementedGreeterServer struct {
}
func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented")
}
func (UnimplementedGreeterServer) GetErrResp(context.Context, *HelloRequest) (*HelloReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetErrResp not implemented")
}
func (UnimplementedGreeterServer) Plus(context.Context, *PlusRequest) (*PlusReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Plus not implemented")
}
func (UnimplementedGreeterServer) SayHelloAfterDelay(context.Context, *HelloRequest) (*HelloReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method SayHelloAfterDelay not implemented")
}
func (UnimplementedGreeterServer) SayMultipleHello(context.Context, *MultipleHelloRequest) (*MultipleHelloReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method SayMultipleHello not implemented")
}
func (UnimplementedGreeterServer) SayHelloServerStream(*HelloRequest, Greeter_SayHelloServerStreamServer) error {
return status.Errorf(codes.Unimplemented, "method SayHelloServerStream not implemented")
}
func (UnimplementedGreeterServer) SayHelloClientStream(Greeter_SayHelloClientStreamServer) error {
return status.Errorf(codes.Unimplemented, "method SayHelloClientStream not implemented")
}
func (UnimplementedGreeterServer) SayHelloBidirectionalStream(Greeter_SayHelloBidirectionalStreamServer) error {
return status.Errorf(codes.Unimplemented, "method SayHelloBidirectionalStream not implemented")
}
func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {}
// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to GreeterServer will
// result in compilation errors.
type UnsafeGreeterServer interface {
mustEmbedUnimplementedGreeterServer()
}
func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) {
s.RegisterService(&Greeter_ServiceDesc, srv)
}
func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HelloRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GreeterServer).SayHello(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/helloworld.Greeter/SayHello",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Greeter_GetErrResp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HelloRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GreeterServer).GetErrResp(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/helloworld.Greeter/GetErrResp",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GreeterServer).GetErrResp(ctx, req.(*HelloRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Greeter_Plus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PlusRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GreeterServer).Plus(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/helloworld.Greeter/Plus",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GreeterServer).Plus(ctx, req.(*PlusRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Greeter_SayHelloAfterDelay_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HelloRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GreeterServer).SayHelloAfterDelay(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/helloworld.Greeter/SayHelloAfterDelay",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GreeterServer).SayHelloAfterDelay(ctx, req.(*HelloRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Greeter_SayMultipleHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MultipleHelloRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GreeterServer).SayMultipleHello(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/helloworld.Greeter/SayMultipleHello",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GreeterServer).SayMultipleHello(ctx, req.(*MultipleHelloRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Greeter_SayHelloServerStream_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(HelloRequest)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(GreeterServer).SayHelloServerStream(m, &greeterSayHelloServerStreamServer{stream})
}
type Greeter_SayHelloServerStreamServer interface {
Send(*HelloReply) error
grpc.ServerStream
}
type greeterSayHelloServerStreamServer struct {
grpc.ServerStream
}
func (x *greeterSayHelloServerStreamServer) Send(m *HelloReply) error {
return x.ServerStream.SendMsg(m)
}
func _Greeter_SayHelloClientStream_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(GreeterServer).SayHelloClientStream(&greeterSayHelloClientStreamServer{stream})
}
type Greeter_SayHelloClientStreamServer interface {
SendAndClose(*HelloReply) error
Recv() (*HelloRequest, error)
grpc.ServerStream
}
type greeterSayHelloClientStreamServer struct {
grpc.ServerStream
}
func (x *greeterSayHelloClientStreamServer) SendAndClose(m *HelloReply) error {
return x.ServerStream.SendMsg(m)
}
func (x *greeterSayHelloClientStreamServer) Recv() (*HelloRequest, error) {
m := new(HelloRequest)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func _Greeter_SayHelloBidirectionalStream_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(GreeterServer).SayHelloBidirectionalStream(&greeterSayHelloBidirectionalStreamServer{stream})
}
type Greeter_SayHelloBidirectionalStreamServer interface {
Send(*HelloReply) error
Recv() (*HelloRequest, error)
grpc.ServerStream
}
type greeterSayHelloBidirectionalStreamServer struct {
grpc.ServerStream
}
func (x *greeterSayHelloBidirectionalStreamServer) Send(m *HelloReply) error {
return x.ServerStream.SendMsg(m)
}
func (x *greeterSayHelloBidirectionalStreamServer) Recv() (*HelloRequest, error) {
m := new(HelloRequest)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Greeter_ServiceDesc = grpc.ServiceDesc{
ServiceName: "helloworld.Greeter",
HandlerType: (*GreeterServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "SayHello",
Handler: _Greeter_SayHello_Handler,
},
{
MethodName: "GetErrResp",
Handler: _Greeter_GetErrResp_Handler,
},
{
MethodName: "Plus",
Handler: _Greeter_Plus_Handler,
},
{
MethodName: "SayHelloAfterDelay",
Handler: _Greeter_SayHelloAfterDelay_Handler,
},
{
MethodName: "SayMultipleHello",
Handler: _Greeter_SayMultipleHello_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "SayHelloServerStream",
Handler: _Greeter_SayHelloServerStream_Handler,
ServerStreams: true,
},
{
StreamName: "SayHelloClientStream",
Handler: _Greeter_SayHelloClientStream_Handler,
ClientStreams: true,
},
{
StreamName: "SayHelloBidirectionalStream",
Handler: _Greeter_SayHelloBidirectionalStream_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "proto/helloworld.proto",
}

View File

@@ -0,0 +1,220 @@
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.12.4
// source: proto/import.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 User struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
}
func (x *User) Reset() {
*x = User{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_import_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *User) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*User) ProtoMessage() {}
func (x *User) ProtoReflect() protoreflect.Message {
mi := &file_proto_import_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 User.ProtoReflect.Descriptor instead.
func (*User) Descriptor() ([]byte, []int) {
return file_proto_import_proto_rawDescGZIP(), []int{0}
}
func (x *User) GetName() string {
if x != nil {
return x.Name
}
return ""
}
type Response struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Body string `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"`
}
func (x *Response) Reset() {
*x = Response{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_import_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Response) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Response) ProtoMessage() {}
func (x *Response) ProtoReflect() protoreflect.Message {
mi := &file_proto_import_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 Response.ProtoReflect.Descriptor instead.
func (*Response) Descriptor() ([]byte, []int) {
return file_proto_import_proto_rawDescGZIP(), []int{1}
}
func (x *Response) GetBody() string {
if x != nil {
return x.Body
}
return ""
}
var File_proto_import_proto protoreflect.FileDescriptor
var file_proto_import_proto_rawDesc = []byte{
0x0a, 0x12, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x70, 0x6b, 0x67, 0x22, 0x1a, 0x0a, 0x04, 0x55, 0x73, 0x65,
0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x1e, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x62, 0x6f, 0x64, 0x79, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_proto_import_proto_rawDescOnce sync.Once
file_proto_import_proto_rawDescData = file_proto_import_proto_rawDesc
)
func file_proto_import_proto_rawDescGZIP() []byte {
file_proto_import_proto_rawDescOnce.Do(func() {
file_proto_import_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_import_proto_rawDescData)
})
return file_proto_import_proto_rawDescData
}
var file_proto_import_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_proto_import_proto_goTypes = []interface{}{
(*User)(nil), // 0: pkg.User
(*Response)(nil), // 1: pkg.Response
}
var file_proto_import_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_proto_import_proto_init() }
func file_proto_import_proto_init() {
if File_proto_import_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_proto_import_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*User); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_import_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Response); 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_proto_import_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_proto_import_proto_goTypes,
DependencyIndexes: file_proto_import_proto_depIdxs,
MessageInfos: file_proto_import_proto_msgTypes,
}.Build()
File_proto_import_proto = out.File
file_proto_import_proto_rawDesc = nil
file_proto_import_proto_goTypes = nil
file_proto_import_proto_depIdxs = nil
}

View File

@@ -0,0 +1,29 @@
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
syntax = "proto3";
package pkg;
option go_package = "./proto";
message User {
string name = 1;
}
message Response {
string body = 1;
}

View File

@@ -0,0 +1,179 @@
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.12.4
// source: proto/src.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 Request struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
Body string `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"`
}
func (x *Request) Reset() {
*x = Request{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_src_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Request) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Request) ProtoMessage() {}
func (x *Request) ProtoReflect() protoreflect.Message {
mi := &file_proto_src_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 Request.ProtoReflect.Descriptor instead.
func (*Request) Descriptor() ([]byte, []int) {
return file_proto_src_proto_rawDescGZIP(), []int{0}
}
func (x *Request) GetUser() *User {
if x != nil {
return x.User
}
return nil
}
func (x *Request) GetBody() string {
if x != nil {
return x.Body
}
return ""
}
var File_proto_src_proto protoreflect.FileDescriptor
var file_proto_src_proto_rawDesc = []byte{
0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x72, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x12, 0x0a, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x1a, 0x12, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x22, 0x3c, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x04,
0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x70, 0x6b, 0x67,
0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x62,
0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x32,
0x39, 0x0a, 0x0a, 0x54, 0x65, 0x73, 0x74, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x2b, 0x0a,
0x03, 0x52, 0x75, 0x6e, 0x12, 0x13, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c,
0x64, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x70, 0x6b, 0x67, 0x2e,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_proto_src_proto_rawDescOnce sync.Once
file_proto_src_proto_rawDescData = file_proto_src_proto_rawDesc
)
func file_proto_src_proto_rawDescGZIP() []byte {
file_proto_src_proto_rawDescOnce.Do(func() {
file_proto_src_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_src_proto_rawDescData)
})
return file_proto_src_proto_rawDescData
}
var file_proto_src_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_proto_src_proto_goTypes = []interface{}{
(*Request)(nil), // 0: helloworld.Request
(*User)(nil), // 1: pkg.User
(*Response)(nil), // 2: pkg.Response
}
var file_proto_src_proto_depIdxs = []int32{
1, // 0: helloworld.Request.user:type_name -> pkg.User
0, // 1: helloworld.TestImport.Run:input_type -> helloworld.Request
2, // 2: helloworld.TestImport.Run:output_type -> pkg.Response
2, // [2:3] is the sub-list for method output_type
1, // [1:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_proto_src_proto_init() }
func file_proto_src_proto_init() {
if File_proto_src_proto != nil {
return
}
file_proto_import_proto_init()
if !protoimpl.UnsafeEnabled {
file_proto_src_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Request); 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_proto_src_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_proto_src_proto_goTypes,
DependencyIndexes: file_proto_src_proto_depIdxs,
MessageInfos: file_proto_src_proto_msgTypes,
}.Build()
File_proto_src_proto = out.File
file_proto_src_proto_rawDesc = nil
file_proto_src_proto_goTypes = nil
file_proto_src_proto_depIdxs = nil
}

View File

@@ -0,0 +1,32 @@
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
syntax = "proto3";
package helloworld;
option go_package = "./proto";
import "proto/import.proto";
service TestImport {
rpc Run (Request) returns (pkg.Response) {}
}
message Request {
pkg.User user = 1;
string body = 2;
}

View File

@@ -0,0 +1,105 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.12.4
// source: proto/src.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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// TestImportClient is the client API for TestImport 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 TestImportClient interface {
Run(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
}
type testImportClient struct {
cc grpc.ClientConnInterface
}
func NewTestImportClient(cc grpc.ClientConnInterface) TestImportClient {
return &testImportClient{cc}
}
func (c *testImportClient) Run(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
out := new(Response)
err := c.cc.Invoke(ctx, "/helloworld.TestImport/Run", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// TestImportServer is the server API for TestImport service.
// All implementations must embed UnimplementedTestImportServer
// for forward compatibility
type TestImportServer interface {
Run(context.Context, *Request) (*Response, error)
mustEmbedUnimplementedTestImportServer()
}
// UnimplementedTestImportServer must be embedded to have forward compatible implementations.
type UnimplementedTestImportServer struct {
}
func (UnimplementedTestImportServer) Run(context.Context, *Request) (*Response, error) {
return nil, status.Errorf(codes.Unimplemented, "method Run not implemented")
}
func (UnimplementedTestImportServer) mustEmbedUnimplementedTestImportServer() {}
// UnsafeTestImportServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to TestImportServer will
// result in compilation errors.
type UnsafeTestImportServer interface {
mustEmbedUnimplementedTestImportServer()
}
func RegisterTestImportServer(s grpc.ServiceRegistrar, srv TestImportServer) {
s.RegisterService(&TestImport_ServiceDesc, srv)
}
func _TestImport_Run_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Request)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TestImportServer).Run(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/helloworld.TestImport/Run",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TestImportServer).Run(ctx, req.(*Request))
}
return interceptor(ctx, in, info, handler)
}
// TestImport_ServiceDesc is the grpc.ServiceDesc for TestImport service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var TestImport_ServiceDesc = grpc.ServiceDesc{
ServiceName: "helloworld.TestImport",
HandlerType: (*TestImportServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Run",
Handler: _TestImport_Run_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "proto/src.proto",
}