├── .gitignore ├── LICENSE ├── README.md ├── README.pdf ├── assets ├── evans_instructions.png ├── gRPCvsREST.png └── how_ssl_works.png ├── blog ├── blog_client │ └── client.go ├── blog_server │ └── server.go └── blogpb │ ├── blog.pb.go │ ├── blog.proto │ └── blog_grpc.pb.go ├── calculator ├── calculator_client │ └── client.go ├── calculator_server │ └── server.go └── calculatorpb │ ├── calculator.pb.go │ ├── calculator.proto │ └── calculator_grpc.pb.go ├── generate.sh ├── go.mod ├── go.sum ├── greet ├── greet_client │ └── client.go ├── greet_server │ └── server.go └── greetpb │ ├── greet.pb.go │ ├── greet.proto │ └── greet_grpc.pb.go └── ssl ├── ca.crt ├── ca.key ├── instructions.sh ├── server.crt ├── server.csr ├── server.key ├── server.pem └── ssl.cnf /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vscode 3 | *.[56789ao] 4 | *.a[56789o] 5 | *.so 6 | *.pyc 7 | ._* 8 | .nfs.* 9 | [56789a].out 10 | *~ 11 | *.orig 12 | *.rej 13 | *.exe 14 | .*.swp 15 | core 16 | *.cgo*.go 17 | *.cgo*.c 18 | _cgo_* 19 | _obj 20 | _test 21 | _testmain.go 22 | /VERSION.cache 23 | /bin/ 24 | /build.out 25 | /doc/articles/wiki/*.bin 26 | /goinstall.log 27 | /last-change 28 | /misc/cgo/life/run.out 29 | /misc/cgo/stdio/run.out 30 | /misc/cgo/testso/main 31 | /pkg/ 32 | /src/*.*/ 33 | /src/cmd/cgo/zdefaultcc.go 34 | /src/cmd/dist/dist 35 | /src/cmd/go/internal/cfg/zdefaultcc.go 36 | /src/cmd/go/internal/cfg/zosarch.go 37 | /src/cmd/internal/objabi/zbootstrap.go 38 | /src/go/build/zcgo.go 39 | /src/go/doc/headscan 40 | /src/runtime/internal/sys/zversion.go 41 | /src/unicode/maketables 42 | /test.out 43 | /test/garbage/*.out 44 | /test/pass.out 45 | /test/run.out 46 | /test/times.out 47 | # This file includes artifacts of Go build that should not be checked in. 48 | # For files created by specific development environment (e.g. editor), 49 | # use alternative ways to exclude files from git. 50 | # For example, set up .git/info/exclude or use a global .gitignore. 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022 Minh Tran 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Implementation of gRPC with Go 2 | 3 | The module ([`github.com/grpc/grpc-go`](https://github.com/grpc/grpc-go)) 4 | contains the Go language implementation of gRPC. HTTP/2 based RPC with instruction 5 | 6 | The blog ([`grpc.io/core-concepts`](https://grpc.io/docs/what-is-grpc/core-concepts/)) contains the introduction to key gRPC concepts, with an overview of gRPC architecture and RPC life cycle 7 | 8 | ## gRPC vs REST 9 | 10 | [This blog](https://husobee.github.io/golang/rest/grpc/2016/05/28/golang-rest-v-grpc.html) finds that gRPC is 25 times more performant than REST API (as defined as time to have the response for an specific API) 11 | 12 | 13 | 14 | ## Protocol Buffers 15 | 16 | The module ([`github.com/golang/protobuf`](https://pkg.go.dev/mod/github.com/golang/protobuf)) 17 | contains Go bindings for Protocol Buffers 18 | 19 | The documentation and tutorials by Google can be found at [`Protocol Buffers Go tutorials`](https://developers.google.com/protocol-buffers/docs/gotutorial) 20 | 21 | My repository for Go bindings for Protocol Buffers instruction and theory can be found at [`github.com/minhtran241/protocol_buffers_go_generate`](https://github.com/minhtran241/protocol_buffers_go_generate) 22 | 23 | ## gRPC with Go 24 | 25 | Follow the module ([`github.com/grpc/grpc-go`](https://github.com/grpc/grpc-go)) to install compiler and packages supporting gRPC with Go 26 | 27 | To generate gRPC services for your application: 28 | 29 | - Update your PATH so that the protoc compiler can find the plugins 30 | ```sh 31 | PATH="${PATH}:${HOME}/go/bin" 32 | ``` 33 | - Generate services: 34 | ```sh 35 | protoc --go-grpc_out=require_unimplemented_servers=false:. ./yourpath/to.protofile/*.proto 36 | ``` 37 | 38 | ## Demo Application applied gRPC with Go 39 | 40 | The application contains: 41 | 42 | - The demo of 4 main types of RPCs 43 | 44 | - Unary RPCs 45 | - Server Streaming RPCs 46 | - Client Streaming RPCs 47 | - Bi-Directional Streaming RPCs 48 | - Blog Service with MongoDB 49 | 50 | - gRPC Error Handling 51 | 52 | - How gRPC deals with error can be found at [`grpc.io/docs/guides/error`](https://grpc.io/docs/guides/error/) 53 | - Reference to implementation oof error codes can be found at [`avi.im/grpc-errors/#go`](https://avi.im/grpc-errors/#go) 54 | - If an application needs to return extra information on top of an error code,it can use the metadata context 55 | 56 | - gRPC Deadlines 57 | 58 | - Deadlines allow gRPC clients to specify how long they are willing to wait for an RPC to complete before the RPCis terminated with the error `DEADLINE_EXCEEDED` 59 | - The gRPC documentation recommends you set a deadline for all client RPC calls 60 | - Setting the Deadlines is up to you, how long do you feel your API should have to complete? 61 | - The server should check if the deadline has exceeded and cancel the work it is doing 62 | - `defer cancel()` calls the `cancel()` function when the deadline has exceeded 63 | - This blog describe Deadlines in depth [`grpc.io/blog/deadlines`](https://grpc.io/blog/deadlines/) 64 | - Note: Deadlines are propagated across if gRPC calls are chained 65 | - A => B => C (Deadline for A is passed to B and then passed to C) 66 | 67 | - SSL Encryption in gRPC 68 | 69 | - SSL encryption is done by generating SSL certificates 70 | - SSL allows communication to be secure end-to-end and ensuring no `Man in the middle attack` can be performed 71 | - SSL allows clients and servers to encrypt packet 72 | - Routers can not view the content of the internet packets 73 | - TLS (Transport Layer Security) 74 | - Successor of SSL, encrypts the connection between 2 endpoints for secure data exchange 75 | - Two ways of using SSL (gRPC can use both) 76 | - 1-way verification, e.g. browser => WebServer 77 | - 2-way verification, e.g. SSL authentication 78 | - Detailed Setup of SSL for Encryption 79 | 80 | 81 | 82 | - All steps and command lines are noted in file `ssl/instructions.sh` 83 | - All the configuration for generating SSL certificates is specified in file `ssl/ssl.cnf` 84 | - Using `SHA256` algorithm for authentication 85 | 86 | - gRPC Reflection & CLI 87 | 88 | - Why gRPC Reflection? 89 | - As we've seen, for Clients to connect to our Server, they need to have a `.proto` file which defines the service 90 | - This is fine for production (we definitely want to know the API definition in advance) 91 | - For development, when you have a gRPC server you don't know, we have to know what APIs the server has 92 | - Reflection is the solution 93 | - Reflection helps us 94 | - Having servers "expose" which endpoints are available 95 | - Allowing CLI to talk to our server without have a preliminary `.proto` file 96 | - This project uses the [evans](`https://github.com/ktr0731/evans`) REPL to practice on the client side 97 | - To register server reflection on a gRPC server: 98 | 99 | ```sh 100 | import "google.golang.org/grpc/reflection" 101 | 102 | s := grpc.NewServer() 103 | pb.RegisterYourOwnServer(s, &server{}) 104 | 105 | // Register reflection service on gRPC server. 106 | reflection.Register(s) 107 | 108 | s.Serve(lis) 109 | ``` 110 | 111 | - More information about gRPC Reflection can be found at [`pkg.go.dev/google.golang.org/grpc/reflection`](https://pkg.go.dev/google.golang.org/grpc/reflection#section-readme) 112 | 113 | ## Blog Service with MongoDB 114 | 115 | - The Blog Service contains 5 RPCs (4 Unary RPCs and 1 Server Streaming RPC) 116 | - CRUD services 117 | - Database 118 | 119 | - Find more information about MongoDB Driver for Go at [`github.com/mongodb/mongo-go-driver`](https://github.com/mongodb/mongo-go-driver) 120 | - Installation 121 | ```sh 122 | go get go.mongodb.org/mongo-driver/mongo 123 | ``` 124 | - MongoDB runs on `localhost:27017` 125 | 126 | ## Project Usage 127 | 128 | - The project contains services 129 | - Greeting Service 130 | - Calculator Service 131 | - Blog Service 132 | - Start Demo (run all the services respectively) 133 | - Start the server of one service 134 | ```sh 135 | go run service/service_server/server.go 136 | ``` 137 | - Start the client of one service 138 | ```sh 139 | go run service/service_client/client.go 140 | ``` 141 | - Play with the services by using [`ktr0731/evans`](https://github.com/ktr0731/evans) REPL mode 142 | 143 | - Installation 144 | - MacOS 145 | ```sh 146 | brew tap ktr0731/evans 147 | brew install evans 148 | ``` 149 | - Usage 150 | - Go to the one of the services you want to play with and trigger `evans` in REPL mode 151 | ```sh 152 | evans --proto service/service_pb/service.proto repl 153 | ``` 154 | - Follow the instructions of [`ktr0731/evans`](https://github.com/ktr0731/evans) 155 | 156 | 157 | 158 | ## Contributor 159 | 160 | - Minh Tran (Me) 161 | -------------------------------------------------------------------------------- /README.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minhtran241/gRPC-introduction/f342fc02d9ab428d5eadd4b4728343988d527538/README.pdf -------------------------------------------------------------------------------- /assets/evans_instructions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minhtran241/gRPC-introduction/f342fc02d9ab428d5eadd4b4728343988d527538/assets/evans_instructions.png -------------------------------------------------------------------------------- /assets/gRPCvsREST.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minhtran241/gRPC-introduction/f342fc02d9ab428d5eadd4b4728343988d527538/assets/gRPCvsREST.png -------------------------------------------------------------------------------- /assets/how_ssl_works.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minhtran241/gRPC-introduction/f342fc02d9ab428d5eadd4b4728343988d527538/assets/how_ssl_works.png -------------------------------------------------------------------------------- /blog/blog_client/client.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "io" 7 | "log" 8 | 9 | "google.golang.org/grpc" 10 | "google.golang.org/grpc/credentials" 11 | 12 | "github.com/minhtran241/grpc-go/blog/blogpb" 13 | ) 14 | 15 | func main() { 16 | fmt.Println("Client is running...") 17 | 18 | tls := true // use tls for security or not 19 | opts := grpc.WithInsecure() 20 | 21 | if tls { 22 | certFile := "ssl/ca.crt" // Certificate Authority Trust certificate 23 | creds, sslErr := credentials.NewClientTLSFromFile(certFile, "") 24 | 25 | if sslErr != nil { 26 | log.Fatalf("Error while loading CA trust certificate: %v", sslErr) 27 | return 28 | } 29 | 30 | opts = grpc.WithTransportCredentials(creds) 31 | } 32 | 33 | cc, err := grpc.Dial("localhost:50051", opts) 34 | 35 | if err != nil { 36 | log.Fatalf("Could not connect: %v", err) 37 | } 38 | 39 | defer cc.Close() 40 | 41 | c := blogpb.NewBlogServiceClient(cc) 42 | 43 | // create Blog 44 | fmt.Println("Creating the blog...") 45 | blog := &blogpb.Blog{ 46 | AuthorId: "Balamurugan Balusamy", 47 | Title: "Big Data", 48 | Content: "An introduction to Big Data", 49 | } 50 | createBlogRes, err := c.CreateBlog(context.Background(), &blogpb.CreateBlogRequest{Blog: blog}) 51 | if err != nil { 52 | log.Fatalf("Unexpected error: %v", err) 53 | } 54 | fmt.Printf("Blog has been created: %v\n", createBlogRes) 55 | blogId := createBlogRes.GetBlog().GetId() 56 | 57 | // read Blog 58 | fmt.Println("Reading the blog...") 59 | _, err2 := c.ReadBlog(context.Background(), &blogpb.ReadBlogRequest{ 60 | BlogId: "some wrong id", 61 | }) 62 | if err2 != nil { 63 | fmt.Printf("Error happened while reading: %v\n", err2) 64 | } 65 | readBlogRes, readBlogErr := c.ReadBlog(context.Background(), &blogpb.ReadBlogRequest{ 66 | BlogId: blogId, 67 | }) 68 | if readBlogErr != nil { 69 | fmt.Printf("Error happened while reading: %v\n", readBlogErr) 70 | } 71 | fmt.Printf("Blog was read: %v\n", readBlogRes) 72 | 73 | // update Blog 74 | newBlog := &blogpb.Blog{ 75 | Id: blogId, 76 | AuthorId: "Changed Author", 77 | Title: "Big Data (edited)", 78 | Content: "An introduction to Big Data (edited)", 79 | } 80 | updateRes, updateErr := c.UpdateBlog(context.Background(), &blogpb.UpdateBlogRequest{ 81 | Blog: newBlog, 82 | }) 83 | if updateErr != nil { 84 | fmt.Printf("Error happened while updating: %v\n", updateErr) 85 | } 86 | fmt.Printf("Blog was updated: %v\n", updateRes) 87 | 88 | // delete Blog 89 | deleteRes, deleteErr := c.DeleteBlog(context.Background(), &blogpb.DeleteBlogRequest{ 90 | BlogId: blogId, 91 | }) 92 | if deleteErr != nil { 93 | fmt.Printf("Error happened while deleting: %v\n", deleteErr) 94 | } 95 | fmt.Printf("Blog was deleted: %v\n", deleteRes) 96 | 97 | // list Blogs 98 | stream, err := c.ListBlog(context.Background(), &blogpb.ListBlogRequest{}) 99 | if err != nil { 100 | log.Fatalf("Error while calling ListBlog RPC: %v", err) 101 | } 102 | for { 103 | res, err := stream.Recv() 104 | if err == io.EOF { 105 | break 106 | } 107 | if err != nil { 108 | log.Fatalf("Something went wrong: %v\n", err) 109 | } 110 | fmt.Println(res.GetBlog()) 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /blog/blog_server/server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "log" 7 | "net" 8 | "os" 9 | "os/signal" 10 | 11 | "go.mongodb.org/mongo-driver/bson" 12 | "go.mongodb.org/mongo-driver/bson/primitive" 13 | "go.mongodb.org/mongo-driver/mongo" 14 | "go.mongodb.org/mongo-driver/mongo/options" 15 | "google.golang.org/grpc" 16 | "google.golang.org/grpc/codes" 17 | "google.golang.org/grpc/credentials" 18 | "google.golang.org/grpc/reflection" 19 | "google.golang.org/grpc/status" 20 | 21 | "github.com/minhtran241/grpc-go/blog/blogpb" 22 | ) 23 | 24 | var collection *mongo.Collection 25 | 26 | type server struct{} 27 | 28 | type blogItem struct { 29 | ID primitive.ObjectID `bson:"_id,omitempty"` 30 | AuthorID string `bson:"author_id"` 31 | Content string `bson:"content"` 32 | Title string `bson:"title"` 33 | } 34 | 35 | func (*server) CreateBlog(ctx context.Context, in *blogpb.CreateBlogRequest) (*blogpb.CreateBlogResponse, error) { 36 | fmt.Println("Create blog request") 37 | blog := in.GetBlog() 38 | data := blogItem{ 39 | AuthorID: blog.GetAuthorId(), 40 | Title: blog.GetTitle(), 41 | Content: blog.GetContent(), 42 | } 43 | 44 | res, err := collection.InsertOne(context.Background(), data) 45 | if err != nil { 46 | return nil, status.Errorf( 47 | codes.Internal, 48 | fmt.Sprintf("Internal error: %v", err), 49 | ) 50 | } 51 | 52 | oid, ok := res.InsertedID.(primitive.ObjectID) 53 | if !ok { 54 | return nil, status.Errorf( 55 | codes.Internal, 56 | fmt.Sprintln("Cannot convert to OID"), 57 | ) 58 | } 59 | 60 | return &blogpb.CreateBlogResponse{ 61 | Blog: &blogpb.Blog{ 62 | Id: oid.Hex(), 63 | AuthorId: blog.GetAuthorId(), 64 | Title: blog.GetTitle(), 65 | Content: blog.GetContent(), 66 | }, 67 | }, nil 68 | } 69 | 70 | func dataToBlogPb(data *blogItem) *blogpb.Blog { 71 | return &blogpb.Blog{ 72 | Id: data.ID.Hex(), 73 | AuthorId: data.AuthorID, 74 | Title: data.Title, 75 | Content: data.Content, 76 | } 77 | } 78 | 79 | func (*server) ReadBlog(ctx context.Context, in *blogpb.ReadBlogRequest) (*blogpb.ReadBlogResponse, error) { 80 | fmt.Println("Read blog request") 81 | blogID := in.GetBlogId() 82 | oid, err := primitive.ObjectIDFromHex(blogID) 83 | if err != nil { 84 | return nil, status.Errorf( 85 | codes.InvalidArgument, 86 | fmt.Sprintln("Can not parse ID"), 87 | ) 88 | } 89 | // create an empty struct 90 | data := &blogItem{} 91 | filter := bson.D{{"_id", oid}} 92 | err = collection.FindOne(context.Background(), filter).Decode(data) 93 | if err == mongo.ErrNoDocuments { 94 | // Do something when no record was found 95 | return nil, status.Errorf(codes.NotFound, fmt.Sprintf("Can not find blog with specified ID: %v\n", err)) 96 | } else if err != nil { 97 | return nil, status.Errorf(codes.Internal, fmt.Sprintf("Something went wrong: %v\n", err)) 98 | } 99 | return &blogpb.ReadBlogResponse{ 100 | Blog: dataToBlogPb(data), 101 | }, nil 102 | } 103 | 104 | func (*server) UpdateBlog(ctx context.Context, in *blogpb.UpdateBlogRequest) (*blogpb.UpdateBlogResponse, error) { 105 | fmt.Println("Update blog request") 106 | blog := in.GetBlog() 107 | oid, err := primitive.ObjectIDFromHex(blog.GetId()) 108 | if err != nil { 109 | return nil, status.Errorf( 110 | codes.InvalidArgument, 111 | fmt.Sprintln("Can not parse ID"), 112 | ) 113 | } 114 | data := &blogItem{} 115 | filter := bson.D{{"_id", oid}} 116 | err = collection.FindOne(context.Background(), filter).Decode(data) 117 | if err == mongo.ErrNoDocuments { 118 | // Do something when no record was found 119 | return nil, status.Errorf(codes.NotFound, fmt.Sprintf("Can not find blog with specified ID: %v\n", err)) 120 | } else if err != nil { 121 | return nil, status.Errorf(codes.Internal, fmt.Sprintf("Something went wrong: %v\n", err)) 122 | } 123 | // we update our internal struct 124 | data.AuthorID = blog.GetAuthorId() 125 | data.Content = blog.GetContent() 126 | data.Title = blog.GetTitle() 127 | 128 | _, updateErr := collection.ReplaceOne(context.Background(), filter, data) 129 | if updateErr != nil { 130 | return nil, status.Errorf(codes.Internal, fmt.Sprintf("Can not update object in MongoDB: %v\n", updateErr)) 131 | } 132 | return &blogpb.UpdateBlogResponse{ 133 | Blog: dataToBlogPb(data), 134 | }, nil 135 | } 136 | 137 | func (*server) DeleteBlog(ctx context.Context, in *blogpb.DeleteBlogRequest) (*blogpb.DeleteBlogResponse, error) { 138 | fmt.Println("Delete blog request") 139 | blogID := in.GetBlogId() 140 | oid, err := primitive.ObjectIDFromHex(blogID) 141 | if err != nil { 142 | return nil, status.Errorf( 143 | codes.InvalidArgument, 144 | fmt.Sprintln("Can not parse ID"), 145 | ) 146 | } 147 | filter := bson.D{{"_id", oid}} 148 | deleteRes, deleteErr := collection.DeleteOne(context.Background(), filter) 149 | if deleteRes.DeletedCount == 0 { 150 | // Do something when no record was found 151 | return nil, status.Errorf(codes.NotFound, fmt.Sprintf("Can not find blog with specified ID: %v\n", deleteErr)) 152 | } else if deleteErr != nil { 153 | return nil, status.Errorf(codes.Internal, fmt.Sprintf("Something went wrong: %v\n", deleteErr)) 154 | } 155 | return &blogpb.DeleteBlogResponse{ 156 | BlogId: blogID, 157 | }, nil 158 | } 159 | 160 | func (*server) ListBlog(in *blogpb.ListBlogRequest, stream blogpb.BlogService_ListBlogServer) error { 161 | fmt.Println("List blog request") 162 | // cursor 163 | cur, err := collection.Find(context.Background(), bson.D{}) 164 | if err != nil { 165 | return status.Errorf(codes.Internal, fmt.Sprintf("Internal error: %v\n", err)) 166 | } 167 | defer cur.Close(context.Background()) 168 | 169 | for cur.Next(context.Background()) { 170 | data := &blogItem{} 171 | err := cur.Decode(data) 172 | if err != nil { 173 | return status.Errorf(codes.Internal, fmt.Sprintf("Error while decoding data from MongoDB: %v\n", err)) 174 | } 175 | stream.Send(&blogpb.ListBlogResponse{ 176 | Blog: dataToBlogPb(data), 177 | }) 178 | } 179 | if err := cur.Err(); err != nil { 180 | return status.Errorf(codes.Internal, fmt.Sprintf("Internal error: %v\n", err)) 181 | } 182 | return nil 183 | } 184 | 185 | func main() { 186 | // if we crash the go code, we get the file name and line number 187 | log.SetFlags(log.LstdFlags | log.Lshortfile) 188 | 189 | fmt.Println("Connecting to MongoDB...") 190 | // connect to MongoDB 191 | client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI("mongodb://localhost:27017")) 192 | if err != nil { 193 | log.Fatal(err) 194 | } 195 | 196 | defer func() { 197 | fmt.Println("Closing MongoDB Connection...") 198 | if err = client.Disconnect(context.TODO()); err != nil { 199 | panic(err) 200 | } 201 | }() 202 | 203 | fmt.Println("Blog Server is running...") 204 | collection = client.Database("mydb").Collection("blog") 205 | 206 | lis, err := net.Listen("tcp", "localhost:50051") // port binding 207 | 208 | if err != nil { 209 | log.Fatalf("Failed to listen: %v", err) 210 | } 211 | 212 | tls := true // use tls for security or not 213 | opts := []grpc.ServerOption{} 214 | 215 | if tls { 216 | certFile := "ssl/server.crt" 217 | keyFile := "ssl/server.pem" 218 | creds, sslErr := credentials.NewServerTLSFromFile(certFile, keyFile) 219 | if sslErr != nil { 220 | log.Fatalf("Failed loading certificates: %v", sslErr) 221 | return 222 | } 223 | opts = append(opts, grpc.Creds(creds)) 224 | } 225 | 226 | s := grpc.NewServer(opts...) // grpc server 227 | blogpb.RegisterBlogServiceServer(s, &server{}) // register greet service 228 | 229 | // Register reflection service on gRPC server. 230 | reflection.Register(s) 231 | 232 | go func() { 233 | fmt.Println("Starting Server...") 234 | if err := s.Serve(lis); err != nil { // bind the port to the grpc server 235 | log.Fatalf("Failed to serve: %v", err) 236 | } 237 | }() 238 | 239 | // Wait for Control C to exit 240 | ch := make(chan os.Signal, 1) 241 | signal.Notify(ch, os.Interrupt) 242 | 243 | // Block until a signal is received 244 | <-ch 245 | fmt.Println("Stopping the server...") 246 | s.Stop() 247 | fmt.Println("Stopping the listener...") 248 | lis.Close() 249 | fmt.Println("End of Program") 250 | } 251 | -------------------------------------------------------------------------------- /blog/blogpb/blog.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.28.1 4 | // protoc v3.21.7 5 | // source: blog/blogpb/blog.proto 6 | 7 | package blogpb 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type Blog struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` 29 | AuthorId string `protobuf:"bytes,2,opt,name=author_id,json=authorId,proto3" json:"author_id,omitempty"` 30 | Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"` 31 | Content string `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"` 32 | } 33 | 34 | func (x *Blog) Reset() { 35 | *x = Blog{} 36 | if protoimpl.UnsafeEnabled { 37 | mi := &file_blog_blogpb_blog_proto_msgTypes[0] 38 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 39 | ms.StoreMessageInfo(mi) 40 | } 41 | } 42 | 43 | func (x *Blog) String() string { 44 | return protoimpl.X.MessageStringOf(x) 45 | } 46 | 47 | func (*Blog) ProtoMessage() {} 48 | 49 | func (x *Blog) ProtoReflect() protoreflect.Message { 50 | mi := &file_blog_blogpb_blog_proto_msgTypes[0] 51 | if protoimpl.UnsafeEnabled && x != nil { 52 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 53 | if ms.LoadMessageInfo() == nil { 54 | ms.StoreMessageInfo(mi) 55 | } 56 | return ms 57 | } 58 | return mi.MessageOf(x) 59 | } 60 | 61 | // Deprecated: Use Blog.ProtoReflect.Descriptor instead. 62 | func (*Blog) Descriptor() ([]byte, []int) { 63 | return file_blog_blogpb_blog_proto_rawDescGZIP(), []int{0} 64 | } 65 | 66 | func (x *Blog) GetId() string { 67 | if x != nil { 68 | return x.Id 69 | } 70 | return "" 71 | } 72 | 73 | func (x *Blog) GetAuthorId() string { 74 | if x != nil { 75 | return x.AuthorId 76 | } 77 | return "" 78 | } 79 | 80 | func (x *Blog) GetTitle() string { 81 | if x != nil { 82 | return x.Title 83 | } 84 | return "" 85 | } 86 | 87 | func (x *Blog) GetContent() string { 88 | if x != nil { 89 | return x.Content 90 | } 91 | return "" 92 | } 93 | 94 | type CreateBlogRequest struct { 95 | state protoimpl.MessageState 96 | sizeCache protoimpl.SizeCache 97 | unknownFields protoimpl.UnknownFields 98 | 99 | Blog *Blog `protobuf:"bytes,1,opt,name=blog,proto3" json:"blog,omitempty"` 100 | } 101 | 102 | func (x *CreateBlogRequest) Reset() { 103 | *x = CreateBlogRequest{} 104 | if protoimpl.UnsafeEnabled { 105 | mi := &file_blog_blogpb_blog_proto_msgTypes[1] 106 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 107 | ms.StoreMessageInfo(mi) 108 | } 109 | } 110 | 111 | func (x *CreateBlogRequest) String() string { 112 | return protoimpl.X.MessageStringOf(x) 113 | } 114 | 115 | func (*CreateBlogRequest) ProtoMessage() {} 116 | 117 | func (x *CreateBlogRequest) ProtoReflect() protoreflect.Message { 118 | mi := &file_blog_blogpb_blog_proto_msgTypes[1] 119 | if protoimpl.UnsafeEnabled && x != nil { 120 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 121 | if ms.LoadMessageInfo() == nil { 122 | ms.StoreMessageInfo(mi) 123 | } 124 | return ms 125 | } 126 | return mi.MessageOf(x) 127 | } 128 | 129 | // Deprecated: Use CreateBlogRequest.ProtoReflect.Descriptor instead. 130 | func (*CreateBlogRequest) Descriptor() ([]byte, []int) { 131 | return file_blog_blogpb_blog_proto_rawDescGZIP(), []int{1} 132 | } 133 | 134 | func (x *CreateBlogRequest) GetBlog() *Blog { 135 | if x != nil { 136 | return x.Blog 137 | } 138 | return nil 139 | } 140 | 141 | type CreateBlogResponse struct { 142 | state protoimpl.MessageState 143 | sizeCache protoimpl.SizeCache 144 | unknownFields protoimpl.UnknownFields 145 | 146 | Blog *Blog `protobuf:"bytes,1,opt,name=blog,proto3" json:"blog,omitempty"` // will have a blog id 147 | } 148 | 149 | func (x *CreateBlogResponse) Reset() { 150 | *x = CreateBlogResponse{} 151 | if protoimpl.UnsafeEnabled { 152 | mi := &file_blog_blogpb_blog_proto_msgTypes[2] 153 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 154 | ms.StoreMessageInfo(mi) 155 | } 156 | } 157 | 158 | func (x *CreateBlogResponse) String() string { 159 | return protoimpl.X.MessageStringOf(x) 160 | } 161 | 162 | func (*CreateBlogResponse) ProtoMessage() {} 163 | 164 | func (x *CreateBlogResponse) ProtoReflect() protoreflect.Message { 165 | mi := &file_blog_blogpb_blog_proto_msgTypes[2] 166 | if protoimpl.UnsafeEnabled && x != nil { 167 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 168 | if ms.LoadMessageInfo() == nil { 169 | ms.StoreMessageInfo(mi) 170 | } 171 | return ms 172 | } 173 | return mi.MessageOf(x) 174 | } 175 | 176 | // Deprecated: Use CreateBlogResponse.ProtoReflect.Descriptor instead. 177 | func (*CreateBlogResponse) Descriptor() ([]byte, []int) { 178 | return file_blog_blogpb_blog_proto_rawDescGZIP(), []int{2} 179 | } 180 | 181 | func (x *CreateBlogResponse) GetBlog() *Blog { 182 | if x != nil { 183 | return x.Blog 184 | } 185 | return nil 186 | } 187 | 188 | type ReadBlogRequest struct { 189 | state protoimpl.MessageState 190 | sizeCache protoimpl.SizeCache 191 | unknownFields protoimpl.UnknownFields 192 | 193 | BlogId string `protobuf:"bytes,1,opt,name=blog_id,json=blogId,proto3" json:"blog_id,omitempty"` 194 | } 195 | 196 | func (x *ReadBlogRequest) Reset() { 197 | *x = ReadBlogRequest{} 198 | if protoimpl.UnsafeEnabled { 199 | mi := &file_blog_blogpb_blog_proto_msgTypes[3] 200 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 201 | ms.StoreMessageInfo(mi) 202 | } 203 | } 204 | 205 | func (x *ReadBlogRequest) String() string { 206 | return protoimpl.X.MessageStringOf(x) 207 | } 208 | 209 | func (*ReadBlogRequest) ProtoMessage() {} 210 | 211 | func (x *ReadBlogRequest) ProtoReflect() protoreflect.Message { 212 | mi := &file_blog_blogpb_blog_proto_msgTypes[3] 213 | if protoimpl.UnsafeEnabled && x != nil { 214 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 215 | if ms.LoadMessageInfo() == nil { 216 | ms.StoreMessageInfo(mi) 217 | } 218 | return ms 219 | } 220 | return mi.MessageOf(x) 221 | } 222 | 223 | // Deprecated: Use ReadBlogRequest.ProtoReflect.Descriptor instead. 224 | func (*ReadBlogRequest) Descriptor() ([]byte, []int) { 225 | return file_blog_blogpb_blog_proto_rawDescGZIP(), []int{3} 226 | } 227 | 228 | func (x *ReadBlogRequest) GetBlogId() string { 229 | if x != nil { 230 | return x.BlogId 231 | } 232 | return "" 233 | } 234 | 235 | type ReadBlogResponse struct { 236 | state protoimpl.MessageState 237 | sizeCache protoimpl.SizeCache 238 | unknownFields protoimpl.UnknownFields 239 | 240 | Blog *Blog `protobuf:"bytes,1,opt,name=blog,proto3" json:"blog,omitempty"` 241 | } 242 | 243 | func (x *ReadBlogResponse) Reset() { 244 | *x = ReadBlogResponse{} 245 | if protoimpl.UnsafeEnabled { 246 | mi := &file_blog_blogpb_blog_proto_msgTypes[4] 247 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 248 | ms.StoreMessageInfo(mi) 249 | } 250 | } 251 | 252 | func (x *ReadBlogResponse) String() string { 253 | return protoimpl.X.MessageStringOf(x) 254 | } 255 | 256 | func (*ReadBlogResponse) ProtoMessage() {} 257 | 258 | func (x *ReadBlogResponse) ProtoReflect() protoreflect.Message { 259 | mi := &file_blog_blogpb_blog_proto_msgTypes[4] 260 | if protoimpl.UnsafeEnabled && x != nil { 261 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 262 | if ms.LoadMessageInfo() == nil { 263 | ms.StoreMessageInfo(mi) 264 | } 265 | return ms 266 | } 267 | return mi.MessageOf(x) 268 | } 269 | 270 | // Deprecated: Use ReadBlogResponse.ProtoReflect.Descriptor instead. 271 | func (*ReadBlogResponse) Descriptor() ([]byte, []int) { 272 | return file_blog_blogpb_blog_proto_rawDescGZIP(), []int{4} 273 | } 274 | 275 | func (x *ReadBlogResponse) GetBlog() *Blog { 276 | if x != nil { 277 | return x.Blog 278 | } 279 | return nil 280 | } 281 | 282 | type UpdateBlogRequest struct { 283 | state protoimpl.MessageState 284 | sizeCache protoimpl.SizeCache 285 | unknownFields protoimpl.UnknownFields 286 | 287 | Blog *Blog `protobuf:"bytes,1,opt,name=blog,proto3" json:"blog,omitempty"` 288 | } 289 | 290 | func (x *UpdateBlogRequest) Reset() { 291 | *x = UpdateBlogRequest{} 292 | if protoimpl.UnsafeEnabled { 293 | mi := &file_blog_blogpb_blog_proto_msgTypes[5] 294 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 295 | ms.StoreMessageInfo(mi) 296 | } 297 | } 298 | 299 | func (x *UpdateBlogRequest) String() string { 300 | return protoimpl.X.MessageStringOf(x) 301 | } 302 | 303 | func (*UpdateBlogRequest) ProtoMessage() {} 304 | 305 | func (x *UpdateBlogRequest) ProtoReflect() protoreflect.Message { 306 | mi := &file_blog_blogpb_blog_proto_msgTypes[5] 307 | if protoimpl.UnsafeEnabled && x != nil { 308 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 309 | if ms.LoadMessageInfo() == nil { 310 | ms.StoreMessageInfo(mi) 311 | } 312 | return ms 313 | } 314 | return mi.MessageOf(x) 315 | } 316 | 317 | // Deprecated: Use UpdateBlogRequest.ProtoReflect.Descriptor instead. 318 | func (*UpdateBlogRequest) Descriptor() ([]byte, []int) { 319 | return file_blog_blogpb_blog_proto_rawDescGZIP(), []int{5} 320 | } 321 | 322 | func (x *UpdateBlogRequest) GetBlog() *Blog { 323 | if x != nil { 324 | return x.Blog 325 | } 326 | return nil 327 | } 328 | 329 | type UpdateBlogResponse struct { 330 | state protoimpl.MessageState 331 | sizeCache protoimpl.SizeCache 332 | unknownFields protoimpl.UnknownFields 333 | 334 | Blog *Blog `protobuf:"bytes,1,opt,name=blog,proto3" json:"blog,omitempty"` 335 | } 336 | 337 | func (x *UpdateBlogResponse) Reset() { 338 | *x = UpdateBlogResponse{} 339 | if protoimpl.UnsafeEnabled { 340 | mi := &file_blog_blogpb_blog_proto_msgTypes[6] 341 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 342 | ms.StoreMessageInfo(mi) 343 | } 344 | } 345 | 346 | func (x *UpdateBlogResponse) String() string { 347 | return protoimpl.X.MessageStringOf(x) 348 | } 349 | 350 | func (*UpdateBlogResponse) ProtoMessage() {} 351 | 352 | func (x *UpdateBlogResponse) ProtoReflect() protoreflect.Message { 353 | mi := &file_blog_blogpb_blog_proto_msgTypes[6] 354 | if protoimpl.UnsafeEnabled && x != nil { 355 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 356 | if ms.LoadMessageInfo() == nil { 357 | ms.StoreMessageInfo(mi) 358 | } 359 | return ms 360 | } 361 | return mi.MessageOf(x) 362 | } 363 | 364 | // Deprecated: Use UpdateBlogResponse.ProtoReflect.Descriptor instead. 365 | func (*UpdateBlogResponse) Descriptor() ([]byte, []int) { 366 | return file_blog_blogpb_blog_proto_rawDescGZIP(), []int{6} 367 | } 368 | 369 | func (x *UpdateBlogResponse) GetBlog() *Blog { 370 | if x != nil { 371 | return x.Blog 372 | } 373 | return nil 374 | } 375 | 376 | type DeleteBlogRequest struct { 377 | state protoimpl.MessageState 378 | sizeCache protoimpl.SizeCache 379 | unknownFields protoimpl.UnknownFields 380 | 381 | BlogId string `protobuf:"bytes,1,opt,name=blog_id,json=blogId,proto3" json:"blog_id,omitempty"` 382 | } 383 | 384 | func (x *DeleteBlogRequest) Reset() { 385 | *x = DeleteBlogRequest{} 386 | if protoimpl.UnsafeEnabled { 387 | mi := &file_blog_blogpb_blog_proto_msgTypes[7] 388 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 389 | ms.StoreMessageInfo(mi) 390 | } 391 | } 392 | 393 | func (x *DeleteBlogRequest) String() string { 394 | return protoimpl.X.MessageStringOf(x) 395 | } 396 | 397 | func (*DeleteBlogRequest) ProtoMessage() {} 398 | 399 | func (x *DeleteBlogRequest) ProtoReflect() protoreflect.Message { 400 | mi := &file_blog_blogpb_blog_proto_msgTypes[7] 401 | if protoimpl.UnsafeEnabled && x != nil { 402 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 403 | if ms.LoadMessageInfo() == nil { 404 | ms.StoreMessageInfo(mi) 405 | } 406 | return ms 407 | } 408 | return mi.MessageOf(x) 409 | } 410 | 411 | // Deprecated: Use DeleteBlogRequest.ProtoReflect.Descriptor instead. 412 | func (*DeleteBlogRequest) Descriptor() ([]byte, []int) { 413 | return file_blog_blogpb_blog_proto_rawDescGZIP(), []int{7} 414 | } 415 | 416 | func (x *DeleteBlogRequest) GetBlogId() string { 417 | if x != nil { 418 | return x.BlogId 419 | } 420 | return "" 421 | } 422 | 423 | type DeleteBlogResponse struct { 424 | state protoimpl.MessageState 425 | sizeCache protoimpl.SizeCache 426 | unknownFields protoimpl.UnknownFields 427 | 428 | BlogId string `protobuf:"bytes,1,opt,name=blog_id,json=blogId,proto3" json:"blog_id,omitempty"` 429 | } 430 | 431 | func (x *DeleteBlogResponse) Reset() { 432 | *x = DeleteBlogResponse{} 433 | if protoimpl.UnsafeEnabled { 434 | mi := &file_blog_blogpb_blog_proto_msgTypes[8] 435 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 436 | ms.StoreMessageInfo(mi) 437 | } 438 | } 439 | 440 | func (x *DeleteBlogResponse) String() string { 441 | return protoimpl.X.MessageStringOf(x) 442 | } 443 | 444 | func (*DeleteBlogResponse) ProtoMessage() {} 445 | 446 | func (x *DeleteBlogResponse) ProtoReflect() protoreflect.Message { 447 | mi := &file_blog_blogpb_blog_proto_msgTypes[8] 448 | if protoimpl.UnsafeEnabled && x != nil { 449 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 450 | if ms.LoadMessageInfo() == nil { 451 | ms.StoreMessageInfo(mi) 452 | } 453 | return ms 454 | } 455 | return mi.MessageOf(x) 456 | } 457 | 458 | // Deprecated: Use DeleteBlogResponse.ProtoReflect.Descriptor instead. 459 | func (*DeleteBlogResponse) Descriptor() ([]byte, []int) { 460 | return file_blog_blogpb_blog_proto_rawDescGZIP(), []int{8} 461 | } 462 | 463 | func (x *DeleteBlogResponse) GetBlogId() string { 464 | if x != nil { 465 | return x.BlogId 466 | } 467 | return "" 468 | } 469 | 470 | type ListBlogRequest struct { 471 | state protoimpl.MessageState 472 | sizeCache protoimpl.SizeCache 473 | unknownFields protoimpl.UnknownFields 474 | } 475 | 476 | func (x *ListBlogRequest) Reset() { 477 | *x = ListBlogRequest{} 478 | if protoimpl.UnsafeEnabled { 479 | mi := &file_blog_blogpb_blog_proto_msgTypes[9] 480 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 481 | ms.StoreMessageInfo(mi) 482 | } 483 | } 484 | 485 | func (x *ListBlogRequest) String() string { 486 | return protoimpl.X.MessageStringOf(x) 487 | } 488 | 489 | func (*ListBlogRequest) ProtoMessage() {} 490 | 491 | func (x *ListBlogRequest) ProtoReflect() protoreflect.Message { 492 | mi := &file_blog_blogpb_blog_proto_msgTypes[9] 493 | if protoimpl.UnsafeEnabled && x != nil { 494 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 495 | if ms.LoadMessageInfo() == nil { 496 | ms.StoreMessageInfo(mi) 497 | } 498 | return ms 499 | } 500 | return mi.MessageOf(x) 501 | } 502 | 503 | // Deprecated: Use ListBlogRequest.ProtoReflect.Descriptor instead. 504 | func (*ListBlogRequest) Descriptor() ([]byte, []int) { 505 | return file_blog_blogpb_blog_proto_rawDescGZIP(), []int{9} 506 | } 507 | 508 | type ListBlogResponse struct { 509 | state protoimpl.MessageState 510 | sizeCache protoimpl.SizeCache 511 | unknownFields protoimpl.UnknownFields 512 | 513 | Blog *Blog `protobuf:"bytes,1,opt,name=blog,proto3" json:"blog,omitempty"` 514 | } 515 | 516 | func (x *ListBlogResponse) Reset() { 517 | *x = ListBlogResponse{} 518 | if protoimpl.UnsafeEnabled { 519 | mi := &file_blog_blogpb_blog_proto_msgTypes[10] 520 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 521 | ms.StoreMessageInfo(mi) 522 | } 523 | } 524 | 525 | func (x *ListBlogResponse) String() string { 526 | return protoimpl.X.MessageStringOf(x) 527 | } 528 | 529 | func (*ListBlogResponse) ProtoMessage() {} 530 | 531 | func (x *ListBlogResponse) ProtoReflect() protoreflect.Message { 532 | mi := &file_blog_blogpb_blog_proto_msgTypes[10] 533 | if protoimpl.UnsafeEnabled && x != nil { 534 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 535 | if ms.LoadMessageInfo() == nil { 536 | ms.StoreMessageInfo(mi) 537 | } 538 | return ms 539 | } 540 | return mi.MessageOf(x) 541 | } 542 | 543 | // Deprecated: Use ListBlogResponse.ProtoReflect.Descriptor instead. 544 | func (*ListBlogResponse) Descriptor() ([]byte, []int) { 545 | return file_blog_blogpb_blog_proto_rawDescGZIP(), []int{10} 546 | } 547 | 548 | func (x *ListBlogResponse) GetBlog() *Blog { 549 | if x != nil { 550 | return x.Blog 551 | } 552 | return nil 553 | } 554 | 555 | var File_blog_blogpb_blog_proto protoreflect.FileDescriptor 556 | 557 | var file_blog_blogpb_blog_proto_rawDesc = []byte{ 558 | 0x0a, 0x16, 0x62, 0x6c, 0x6f, 0x67, 0x2f, 0x62, 0x6c, 0x6f, 0x67, 0x70, 0x62, 0x2f, 0x62, 0x6c, 559 | 0x6f, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x62, 0x6c, 0x6f, 0x67, 0x22, 0x63, 560 | 0x0a, 0x04, 0x42, 0x6c, 0x6f, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 561 | 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 562 | 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x75, 0x74, 0x68, 0x6f, 563 | 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 564 | 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 565 | 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 566 | 0x65, 0x6e, 0x74, 0x22, 0x33, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6c, 0x6f, 567 | 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x04, 0x62, 0x6c, 0x6f, 0x67, 568 | 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x62, 0x6c, 0x6f, 0x67, 0x2e, 0x42, 0x6c, 569 | 0x6f, 0x67, 0x52, 0x04, 0x62, 0x6c, 0x6f, 0x67, 0x22, 0x34, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 570 | 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 571 | 0x0a, 0x04, 0x62, 0x6c, 0x6f, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x62, 572 | 0x6c, 0x6f, 0x67, 0x2e, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x04, 0x62, 0x6c, 0x6f, 0x67, 0x22, 0x2a, 573 | 0x0a, 0x0f, 0x52, 0x65, 0x61, 0x64, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 574 | 0x74, 0x12, 0x17, 0x0a, 0x07, 0x62, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 575 | 0x28, 0x09, 0x52, 0x06, 0x62, 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x22, 0x32, 0x0a, 0x10, 0x52, 0x65, 576 | 0x61, 0x64, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 577 | 0x0a, 0x04, 0x62, 0x6c, 0x6f, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x62, 578 | 0x6c, 0x6f, 0x67, 0x2e, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x04, 0x62, 0x6c, 0x6f, 0x67, 0x22, 0x33, 579 | 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 580 | 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x04, 0x62, 0x6c, 0x6f, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 581 | 0x0b, 0x32, 0x0a, 0x2e, 0x62, 0x6c, 0x6f, 0x67, 0x2e, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x04, 0x62, 582 | 0x6c, 0x6f, 0x67, 0x22, 0x34, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x6c, 0x6f, 583 | 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x62, 0x6c, 0x6f, 584 | 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x62, 0x6c, 0x6f, 0x67, 0x2e, 0x42, 585 | 0x6c, 0x6f, 0x67, 0x52, 0x04, 0x62, 0x6c, 0x6f, 0x67, 0x22, 0x2c, 0x0a, 0x11, 0x44, 0x65, 0x6c, 586 | 0x65, 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 587 | 0x0a, 0x07, 0x62, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 588 | 0x06, 0x62, 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x22, 0x2d, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 589 | 0x65, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x17, 0x0a, 590 | 0x07, 0x62, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 591 | 0x62, 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x22, 0x11, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6c, 592 | 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x32, 0x0a, 0x10, 0x4c, 0x69, 0x73, 593 | 0x74, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 594 | 0x04, 0x62, 0x6c, 0x6f, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x62, 0x6c, 595 | 0x6f, 0x67, 0x2e, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x04, 0x62, 0x6c, 0x6f, 0x67, 0x32, 0xd2, 0x02, 596 | 0x0a, 0x0b, 0x42, 0x6c, 0x6f, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x41, 0x0a, 597 | 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x67, 0x12, 0x17, 0x2e, 0x62, 0x6c, 598 | 0x6f, 0x67, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x71, 599 | 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x62, 0x6c, 0x6f, 0x67, 0x2e, 0x43, 0x72, 0x65, 0x61, 600 | 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 601 | 0x12, 0x3b, 0x0a, 0x08, 0x52, 0x65, 0x61, 0x64, 0x42, 0x6c, 0x6f, 0x67, 0x12, 0x15, 0x2e, 0x62, 602 | 0x6c, 0x6f, 0x67, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 603 | 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x62, 0x6c, 0x6f, 0x67, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x42, 604 | 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 605 | 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x67, 0x12, 0x17, 0x2e, 0x62, 0x6c, 606 | 0x6f, 0x67, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x71, 607 | 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x62, 0x6c, 0x6f, 0x67, 0x2e, 0x55, 0x70, 0x64, 0x61, 608 | 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 609 | 0x12, 0x41, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x67, 0x12, 0x17, 610 | 0x2e, 0x62, 0x6c, 0x6f, 0x67, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x67, 611 | 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x62, 0x6c, 0x6f, 0x67, 0x2e, 0x44, 612 | 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 613 | 0x65, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x67, 0x12, 614 | 0x15, 0x2e, 0x62, 0x6c, 0x6f, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x67, 0x52, 615 | 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x62, 0x6c, 0x6f, 0x67, 0x2e, 0x4c, 0x69, 616 | 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 617 | 0x30, 0x01, 0x42, 0x0d, 0x5a, 0x0b, 0x62, 0x6c, 0x6f, 0x67, 0x2f, 0x62, 0x6c, 0x6f, 0x67, 0x70, 618 | 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 619 | } 620 | 621 | var ( 622 | file_blog_blogpb_blog_proto_rawDescOnce sync.Once 623 | file_blog_blogpb_blog_proto_rawDescData = file_blog_blogpb_blog_proto_rawDesc 624 | ) 625 | 626 | func file_blog_blogpb_blog_proto_rawDescGZIP() []byte { 627 | file_blog_blogpb_blog_proto_rawDescOnce.Do(func() { 628 | file_blog_blogpb_blog_proto_rawDescData = protoimpl.X.CompressGZIP(file_blog_blogpb_blog_proto_rawDescData) 629 | }) 630 | return file_blog_blogpb_blog_proto_rawDescData 631 | } 632 | 633 | var file_blog_blogpb_blog_proto_msgTypes = make([]protoimpl.MessageInfo, 11) 634 | var file_blog_blogpb_blog_proto_goTypes = []interface{}{ 635 | (*Blog)(nil), // 0: blog.Blog 636 | (*CreateBlogRequest)(nil), // 1: blog.CreateBlogRequest 637 | (*CreateBlogResponse)(nil), // 2: blog.CreateBlogResponse 638 | (*ReadBlogRequest)(nil), // 3: blog.ReadBlogRequest 639 | (*ReadBlogResponse)(nil), // 4: blog.ReadBlogResponse 640 | (*UpdateBlogRequest)(nil), // 5: blog.UpdateBlogRequest 641 | (*UpdateBlogResponse)(nil), // 6: blog.UpdateBlogResponse 642 | (*DeleteBlogRequest)(nil), // 7: blog.DeleteBlogRequest 643 | (*DeleteBlogResponse)(nil), // 8: blog.DeleteBlogResponse 644 | (*ListBlogRequest)(nil), // 9: blog.ListBlogRequest 645 | (*ListBlogResponse)(nil), // 10: blog.ListBlogResponse 646 | } 647 | var file_blog_blogpb_blog_proto_depIdxs = []int32{ 648 | 0, // 0: blog.CreateBlogRequest.blog:type_name -> blog.Blog 649 | 0, // 1: blog.CreateBlogResponse.blog:type_name -> blog.Blog 650 | 0, // 2: blog.ReadBlogResponse.blog:type_name -> blog.Blog 651 | 0, // 3: blog.UpdateBlogRequest.blog:type_name -> blog.Blog 652 | 0, // 4: blog.UpdateBlogResponse.blog:type_name -> blog.Blog 653 | 0, // 5: blog.ListBlogResponse.blog:type_name -> blog.Blog 654 | 1, // 6: blog.BlogService.CreateBlog:input_type -> blog.CreateBlogRequest 655 | 3, // 7: blog.BlogService.ReadBlog:input_type -> blog.ReadBlogRequest 656 | 5, // 8: blog.BlogService.UpdateBlog:input_type -> blog.UpdateBlogRequest 657 | 7, // 9: blog.BlogService.DeleteBlog:input_type -> blog.DeleteBlogRequest 658 | 9, // 10: blog.BlogService.ListBlog:input_type -> blog.ListBlogRequest 659 | 2, // 11: blog.BlogService.CreateBlog:output_type -> blog.CreateBlogResponse 660 | 4, // 12: blog.BlogService.ReadBlog:output_type -> blog.ReadBlogResponse 661 | 6, // 13: blog.BlogService.UpdateBlog:output_type -> blog.UpdateBlogResponse 662 | 8, // 14: blog.BlogService.DeleteBlog:output_type -> blog.DeleteBlogResponse 663 | 10, // 15: blog.BlogService.ListBlog:output_type -> blog.ListBlogResponse 664 | 11, // [11:16] is the sub-list for method output_type 665 | 6, // [6:11] is the sub-list for method input_type 666 | 6, // [6:6] is the sub-list for extension type_name 667 | 6, // [6:6] is the sub-list for extension extendee 668 | 0, // [0:6] is the sub-list for field type_name 669 | } 670 | 671 | func init() { file_blog_blogpb_blog_proto_init() } 672 | func file_blog_blogpb_blog_proto_init() { 673 | if File_blog_blogpb_blog_proto != nil { 674 | return 675 | } 676 | if !protoimpl.UnsafeEnabled { 677 | file_blog_blogpb_blog_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 678 | switch v := v.(*Blog); i { 679 | case 0: 680 | return &v.state 681 | case 1: 682 | return &v.sizeCache 683 | case 2: 684 | return &v.unknownFields 685 | default: 686 | return nil 687 | } 688 | } 689 | file_blog_blogpb_blog_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 690 | switch v := v.(*CreateBlogRequest); i { 691 | case 0: 692 | return &v.state 693 | case 1: 694 | return &v.sizeCache 695 | case 2: 696 | return &v.unknownFields 697 | default: 698 | return nil 699 | } 700 | } 701 | file_blog_blogpb_blog_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { 702 | switch v := v.(*CreateBlogResponse); i { 703 | case 0: 704 | return &v.state 705 | case 1: 706 | return &v.sizeCache 707 | case 2: 708 | return &v.unknownFields 709 | default: 710 | return nil 711 | } 712 | } 713 | file_blog_blogpb_blog_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { 714 | switch v := v.(*ReadBlogRequest); i { 715 | case 0: 716 | return &v.state 717 | case 1: 718 | return &v.sizeCache 719 | case 2: 720 | return &v.unknownFields 721 | default: 722 | return nil 723 | } 724 | } 725 | file_blog_blogpb_blog_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { 726 | switch v := v.(*ReadBlogResponse); i { 727 | case 0: 728 | return &v.state 729 | case 1: 730 | return &v.sizeCache 731 | case 2: 732 | return &v.unknownFields 733 | default: 734 | return nil 735 | } 736 | } 737 | file_blog_blogpb_blog_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { 738 | switch v := v.(*UpdateBlogRequest); i { 739 | case 0: 740 | return &v.state 741 | case 1: 742 | return &v.sizeCache 743 | case 2: 744 | return &v.unknownFields 745 | default: 746 | return nil 747 | } 748 | } 749 | file_blog_blogpb_blog_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { 750 | switch v := v.(*UpdateBlogResponse); i { 751 | case 0: 752 | return &v.state 753 | case 1: 754 | return &v.sizeCache 755 | case 2: 756 | return &v.unknownFields 757 | default: 758 | return nil 759 | } 760 | } 761 | file_blog_blogpb_blog_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { 762 | switch v := v.(*DeleteBlogRequest); i { 763 | case 0: 764 | return &v.state 765 | case 1: 766 | return &v.sizeCache 767 | case 2: 768 | return &v.unknownFields 769 | default: 770 | return nil 771 | } 772 | } 773 | file_blog_blogpb_blog_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { 774 | switch v := v.(*DeleteBlogResponse); i { 775 | case 0: 776 | return &v.state 777 | case 1: 778 | return &v.sizeCache 779 | case 2: 780 | return &v.unknownFields 781 | default: 782 | return nil 783 | } 784 | } 785 | file_blog_blogpb_blog_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { 786 | switch v := v.(*ListBlogRequest); i { 787 | case 0: 788 | return &v.state 789 | case 1: 790 | return &v.sizeCache 791 | case 2: 792 | return &v.unknownFields 793 | default: 794 | return nil 795 | } 796 | } 797 | file_blog_blogpb_blog_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { 798 | switch v := v.(*ListBlogResponse); i { 799 | case 0: 800 | return &v.state 801 | case 1: 802 | return &v.sizeCache 803 | case 2: 804 | return &v.unknownFields 805 | default: 806 | return nil 807 | } 808 | } 809 | } 810 | type x struct{} 811 | out := protoimpl.TypeBuilder{ 812 | File: protoimpl.DescBuilder{ 813 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 814 | RawDescriptor: file_blog_blogpb_blog_proto_rawDesc, 815 | NumEnums: 0, 816 | NumMessages: 11, 817 | NumExtensions: 0, 818 | NumServices: 1, 819 | }, 820 | GoTypes: file_blog_blogpb_blog_proto_goTypes, 821 | DependencyIndexes: file_blog_blogpb_blog_proto_depIdxs, 822 | MessageInfos: file_blog_blogpb_blog_proto_msgTypes, 823 | }.Build() 824 | File_blog_blogpb_blog_proto = out.File 825 | file_blog_blogpb_blog_proto_rawDesc = nil 826 | file_blog_blogpb_blog_proto_goTypes = nil 827 | file_blog_blogpb_blog_proto_depIdxs = nil 828 | } 829 | -------------------------------------------------------------------------------- /blog/blogpb/blog.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package blog; 4 | option go_package="blog/blogpb"; 5 | 6 | message Blog { 7 | string id = 1; 8 | string author_id = 2; 9 | string title = 3; 10 | string content = 4; 11 | } 12 | 13 | message CreateBlogRequest { 14 | Blog blog = 1; 15 | } 16 | 17 | message CreateBlogResponse { 18 | Blog blog = 1; // will have a blog id 19 | } 20 | 21 | message ReadBlogRequest { 22 | string blog_id = 1; 23 | } 24 | 25 | message ReadBlogResponse { 26 | Blog blog = 1; 27 | } 28 | 29 | message UpdateBlogRequest { 30 | Blog blog = 1; 31 | } 32 | 33 | message UpdateBlogResponse { 34 | Blog blog = 1; 35 | } 36 | 37 | message DeleteBlogRequest { 38 | string blog_id = 1; 39 | } 40 | 41 | message DeleteBlogResponse { 42 | string blog_id = 1; 43 | } 44 | 45 | message ListBlogRequest { 46 | 47 | } 48 | 49 | message ListBlogResponse { 50 | Blog blog = 1; 51 | } 52 | 53 | service BlogService { 54 | rpc CreateBlog (CreateBlogRequest) returns (CreateBlogResponse) {}; 55 | rpc ReadBlog (ReadBlogRequest) returns (ReadBlogResponse) {}; // return NOT_FOUND if not found 56 | rpc UpdateBlog (UpdateBlogRequest) returns (UpdateBlogResponse) {}; 57 | rpc DeleteBlog (DeleteBlogRequest) returns (DeleteBlogResponse) {}; 58 | rpc ListBlog (ListBlogRequest) returns (stream ListBlogResponse) {}; 59 | } -------------------------------------------------------------------------------- /blog/blogpb/blog_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.2.0 4 | // - protoc v3.21.7 5 | // source: blog/blogpb/blog.proto 6 | 7 | package blogpb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.32.0 or later. 19 | const _ = grpc.SupportPackageIsVersion7 20 | 21 | // BlogServiceClient is the client API for BlogService service. 22 | // 23 | // 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. 24 | type BlogServiceClient interface { 25 | CreateBlog(ctx context.Context, in *CreateBlogRequest, opts ...grpc.CallOption) (*CreateBlogResponse, error) 26 | ReadBlog(ctx context.Context, in *ReadBlogRequest, opts ...grpc.CallOption) (*ReadBlogResponse, error) 27 | UpdateBlog(ctx context.Context, in *UpdateBlogRequest, opts ...grpc.CallOption) (*UpdateBlogResponse, error) 28 | DeleteBlog(ctx context.Context, in *DeleteBlogRequest, opts ...grpc.CallOption) (*DeleteBlogResponse, error) 29 | ListBlog(ctx context.Context, in *ListBlogRequest, opts ...grpc.CallOption) (BlogService_ListBlogClient, error) 30 | } 31 | 32 | type blogServiceClient struct { 33 | cc grpc.ClientConnInterface 34 | } 35 | 36 | func NewBlogServiceClient(cc grpc.ClientConnInterface) BlogServiceClient { 37 | return &blogServiceClient{cc} 38 | } 39 | 40 | func (c *blogServiceClient) CreateBlog(ctx context.Context, in *CreateBlogRequest, opts ...grpc.CallOption) (*CreateBlogResponse, error) { 41 | out := new(CreateBlogResponse) 42 | err := c.cc.Invoke(ctx, "/blog.BlogService/CreateBlog", in, out, opts...) 43 | if err != nil { 44 | return nil, err 45 | } 46 | return out, nil 47 | } 48 | 49 | func (c *blogServiceClient) ReadBlog(ctx context.Context, in *ReadBlogRequest, opts ...grpc.CallOption) (*ReadBlogResponse, error) { 50 | out := new(ReadBlogResponse) 51 | err := c.cc.Invoke(ctx, "/blog.BlogService/ReadBlog", in, out, opts...) 52 | if err != nil { 53 | return nil, err 54 | } 55 | return out, nil 56 | } 57 | 58 | func (c *blogServiceClient) UpdateBlog(ctx context.Context, in *UpdateBlogRequest, opts ...grpc.CallOption) (*UpdateBlogResponse, error) { 59 | out := new(UpdateBlogResponse) 60 | err := c.cc.Invoke(ctx, "/blog.BlogService/UpdateBlog", in, out, opts...) 61 | if err != nil { 62 | return nil, err 63 | } 64 | return out, nil 65 | } 66 | 67 | func (c *blogServiceClient) DeleteBlog(ctx context.Context, in *DeleteBlogRequest, opts ...grpc.CallOption) (*DeleteBlogResponse, error) { 68 | out := new(DeleteBlogResponse) 69 | err := c.cc.Invoke(ctx, "/blog.BlogService/DeleteBlog", in, out, opts...) 70 | if err != nil { 71 | return nil, err 72 | } 73 | return out, nil 74 | } 75 | 76 | func (c *blogServiceClient) ListBlog(ctx context.Context, in *ListBlogRequest, opts ...grpc.CallOption) (BlogService_ListBlogClient, error) { 77 | stream, err := c.cc.NewStream(ctx, &BlogService_ServiceDesc.Streams[0], "/blog.BlogService/ListBlog", opts...) 78 | if err != nil { 79 | return nil, err 80 | } 81 | x := &blogServiceListBlogClient{stream} 82 | if err := x.ClientStream.SendMsg(in); err != nil { 83 | return nil, err 84 | } 85 | if err := x.ClientStream.CloseSend(); err != nil { 86 | return nil, err 87 | } 88 | return x, nil 89 | } 90 | 91 | type BlogService_ListBlogClient interface { 92 | Recv() (*ListBlogResponse, error) 93 | grpc.ClientStream 94 | } 95 | 96 | type blogServiceListBlogClient struct { 97 | grpc.ClientStream 98 | } 99 | 100 | func (x *blogServiceListBlogClient) Recv() (*ListBlogResponse, error) { 101 | m := new(ListBlogResponse) 102 | if err := x.ClientStream.RecvMsg(m); err != nil { 103 | return nil, err 104 | } 105 | return m, nil 106 | } 107 | 108 | // BlogServiceServer is the server API for BlogService service. 109 | // All implementations should embed UnimplementedBlogServiceServer 110 | // for forward compatibility 111 | type BlogServiceServer interface { 112 | CreateBlog(context.Context, *CreateBlogRequest) (*CreateBlogResponse, error) 113 | ReadBlog(context.Context, *ReadBlogRequest) (*ReadBlogResponse, error) 114 | UpdateBlog(context.Context, *UpdateBlogRequest) (*UpdateBlogResponse, error) 115 | DeleteBlog(context.Context, *DeleteBlogRequest) (*DeleteBlogResponse, error) 116 | ListBlog(*ListBlogRequest, BlogService_ListBlogServer) error 117 | } 118 | 119 | // UnimplementedBlogServiceServer should be embedded to have forward compatible implementations. 120 | type UnimplementedBlogServiceServer struct { 121 | } 122 | 123 | func (UnimplementedBlogServiceServer) CreateBlog(context.Context, *CreateBlogRequest) (*CreateBlogResponse, error) { 124 | return nil, status.Errorf(codes.Unimplemented, "method CreateBlog not implemented") 125 | } 126 | func (UnimplementedBlogServiceServer) ReadBlog(context.Context, *ReadBlogRequest) (*ReadBlogResponse, error) { 127 | return nil, status.Errorf(codes.Unimplemented, "method ReadBlog not implemented") 128 | } 129 | func (UnimplementedBlogServiceServer) UpdateBlog(context.Context, *UpdateBlogRequest) (*UpdateBlogResponse, error) { 130 | return nil, status.Errorf(codes.Unimplemented, "method UpdateBlog not implemented") 131 | } 132 | func (UnimplementedBlogServiceServer) DeleteBlog(context.Context, *DeleteBlogRequest) (*DeleteBlogResponse, error) { 133 | return nil, status.Errorf(codes.Unimplemented, "method DeleteBlog not implemented") 134 | } 135 | func (UnimplementedBlogServiceServer) ListBlog(*ListBlogRequest, BlogService_ListBlogServer) error { 136 | return status.Errorf(codes.Unimplemented, "method ListBlog not implemented") 137 | } 138 | 139 | // UnsafeBlogServiceServer may be embedded to opt out of forward compatibility for this service. 140 | // Use of this interface is not recommended, as added methods to BlogServiceServer will 141 | // result in compilation errors. 142 | type UnsafeBlogServiceServer interface { 143 | mustEmbedUnimplementedBlogServiceServer() 144 | } 145 | 146 | func RegisterBlogServiceServer(s grpc.ServiceRegistrar, srv BlogServiceServer) { 147 | s.RegisterService(&BlogService_ServiceDesc, srv) 148 | } 149 | 150 | func _BlogService_CreateBlog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 151 | in := new(CreateBlogRequest) 152 | if err := dec(in); err != nil { 153 | return nil, err 154 | } 155 | if interceptor == nil { 156 | return srv.(BlogServiceServer).CreateBlog(ctx, in) 157 | } 158 | info := &grpc.UnaryServerInfo{ 159 | Server: srv, 160 | FullMethod: "/blog.BlogService/CreateBlog", 161 | } 162 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 163 | return srv.(BlogServiceServer).CreateBlog(ctx, req.(*CreateBlogRequest)) 164 | } 165 | return interceptor(ctx, in, info, handler) 166 | } 167 | 168 | func _BlogService_ReadBlog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 169 | in := new(ReadBlogRequest) 170 | if err := dec(in); err != nil { 171 | return nil, err 172 | } 173 | if interceptor == nil { 174 | return srv.(BlogServiceServer).ReadBlog(ctx, in) 175 | } 176 | info := &grpc.UnaryServerInfo{ 177 | Server: srv, 178 | FullMethod: "/blog.BlogService/ReadBlog", 179 | } 180 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 181 | return srv.(BlogServiceServer).ReadBlog(ctx, req.(*ReadBlogRequest)) 182 | } 183 | return interceptor(ctx, in, info, handler) 184 | } 185 | 186 | func _BlogService_UpdateBlog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 187 | in := new(UpdateBlogRequest) 188 | if err := dec(in); err != nil { 189 | return nil, err 190 | } 191 | if interceptor == nil { 192 | return srv.(BlogServiceServer).UpdateBlog(ctx, in) 193 | } 194 | info := &grpc.UnaryServerInfo{ 195 | Server: srv, 196 | FullMethod: "/blog.BlogService/UpdateBlog", 197 | } 198 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 199 | return srv.(BlogServiceServer).UpdateBlog(ctx, req.(*UpdateBlogRequest)) 200 | } 201 | return interceptor(ctx, in, info, handler) 202 | } 203 | 204 | func _BlogService_DeleteBlog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 205 | in := new(DeleteBlogRequest) 206 | if err := dec(in); err != nil { 207 | return nil, err 208 | } 209 | if interceptor == nil { 210 | return srv.(BlogServiceServer).DeleteBlog(ctx, in) 211 | } 212 | info := &grpc.UnaryServerInfo{ 213 | Server: srv, 214 | FullMethod: "/blog.BlogService/DeleteBlog", 215 | } 216 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 217 | return srv.(BlogServiceServer).DeleteBlog(ctx, req.(*DeleteBlogRequest)) 218 | } 219 | return interceptor(ctx, in, info, handler) 220 | } 221 | 222 | func _BlogService_ListBlog_Handler(srv interface{}, stream grpc.ServerStream) error { 223 | m := new(ListBlogRequest) 224 | if err := stream.RecvMsg(m); err != nil { 225 | return err 226 | } 227 | return srv.(BlogServiceServer).ListBlog(m, &blogServiceListBlogServer{stream}) 228 | } 229 | 230 | type BlogService_ListBlogServer interface { 231 | Send(*ListBlogResponse) error 232 | grpc.ServerStream 233 | } 234 | 235 | type blogServiceListBlogServer struct { 236 | grpc.ServerStream 237 | } 238 | 239 | func (x *blogServiceListBlogServer) Send(m *ListBlogResponse) error { 240 | return x.ServerStream.SendMsg(m) 241 | } 242 | 243 | // BlogService_ServiceDesc is the grpc.ServiceDesc for BlogService service. 244 | // It's only intended for direct use with grpc.RegisterService, 245 | // and not to be introspected or modified (even as a copy) 246 | var BlogService_ServiceDesc = grpc.ServiceDesc{ 247 | ServiceName: "blog.BlogService", 248 | HandlerType: (*BlogServiceServer)(nil), 249 | Methods: []grpc.MethodDesc{ 250 | { 251 | MethodName: "CreateBlog", 252 | Handler: _BlogService_CreateBlog_Handler, 253 | }, 254 | { 255 | MethodName: "ReadBlog", 256 | Handler: _BlogService_ReadBlog_Handler, 257 | }, 258 | { 259 | MethodName: "UpdateBlog", 260 | Handler: _BlogService_UpdateBlog_Handler, 261 | }, 262 | { 263 | MethodName: "DeleteBlog", 264 | Handler: _BlogService_DeleteBlog_Handler, 265 | }, 266 | }, 267 | Streams: []grpc.StreamDesc{ 268 | { 269 | StreamName: "ListBlog", 270 | Handler: _BlogService_ListBlog_Handler, 271 | ServerStreams: true, 272 | }, 273 | }, 274 | Metadata: "blog/blogpb/blog.proto", 275 | } 276 | -------------------------------------------------------------------------------- /calculator/calculator_client/client.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "io" 7 | "log" 8 | "time" 9 | 10 | "google.golang.org/grpc" 11 | "google.golang.org/grpc/codes" 12 | "google.golang.org/grpc/status" 13 | 14 | "github.com/minhtran241/grpc-go/calculator/calculatorpb" 15 | ) 16 | 17 | func main() { 18 | 19 | cc, err := grpc.Dial("localhost:50051", grpc.WithInsecure()) 20 | 21 | if err != nil { 22 | log.Fatalf("Could not connect: %v", err) 23 | } 24 | 25 | defer cc.Close() 26 | 27 | c := calculatorpb.NewCalculatorServiceClient(cc) 28 | 29 | // doUnary(c) 30 | 31 | // doServerStreaming(c) 32 | 33 | // doClientStreaming(c) 34 | 35 | // doBiDiStreaming(c) 36 | 37 | doErrorUnary(c) 38 | } 39 | 40 | func doErrorUnary(c calculatorpb.CalculatorServiceClient) { 41 | fmt.Println("Starting to do SquareRoot Unary RPC...") 42 | 43 | // correct call 44 | doErrorCall(c, 10) 45 | 46 | // error call 47 | doErrorCall(c, -10) 48 | } 49 | 50 | func doErrorCall(c calculatorpb.CalculatorServiceClient, number int32) { 51 | res, err := c.SquareRoot(context.Background(), &calculatorpb.SquareRootRequest{ 52 | Number: number, 53 | }) 54 | 55 | if err != nil { 56 | respErr, ok := status.FromError(err) 57 | if ok { 58 | // actual error from gRPC (user error) 59 | fmt.Printf("(Error meaage from server) %s\n", respErr.Message()) 60 | fmt.Println(respErr.Code()) 61 | if respErr.Code() == codes.InvalidArgument { 62 | fmt.Println("We probably sent a negative number!") 63 | return 64 | } 65 | } else { 66 | log.Fatalf("Big Error calling SquareRoot: %v", err) 67 | return 68 | } 69 | } 70 | 71 | fmt.Printf("Result of SquareRoot of %v: %v\n", number, res.GetNumberRoot()) 72 | } 73 | 74 | func doBiDiStreaming(c calculatorpb.CalculatorServiceClient) { 75 | fmt.Println("Starting to do BiDi Streaming RPC...") 76 | 77 | stream, err := c.FindMaximum(context.Background()) 78 | 79 | if err != nil { 80 | log.Fatalf("Error while opening stream and calling FindMaximum: %v", err) 81 | } 82 | 83 | waitc := make(chan struct{}) 84 | 85 | // send go routine 86 | go func() { 87 | numbers := []int32{4, 7, 2, 19, 4, 6, 32} 88 | 89 | for i, number := range numbers { 90 | fmt.Printf("(%d)Sending number: %d...\n", i, number) 91 | stream.Send(&calculatorpb.FindMaximumRequest{ 92 | Number: number, 93 | }) 94 | time.Sleep(time.Second * 1) 95 | } 96 | stream.CloseSend() 97 | }() 98 | 99 | // receive go routine 100 | go func() { 101 | for { 102 | res, err := stream.Recv() 103 | 104 | if err == io.EOF { 105 | break 106 | } 107 | 108 | if err != nil { 109 | log.Fatalf("Problem while reading server stream response: %v", err) 110 | break 111 | } 112 | 113 | maximum := res.GetMaximum() 114 | log.Printf("Received a new maximum of...: %d\n", maximum) 115 | } 116 | close(waitc) 117 | }() 118 | 119 | // block until for loop broken 120 | <-waitc 121 | } 122 | 123 | func doClientStreaming(c calculatorpb.CalculatorServiceClient) { 124 | fmt.Println("Starting to do Client Streaming RPC...") 125 | 126 | stream, err := c.ComputeAverage(context.Background()) 127 | 128 | if err != nil { 129 | log.Fatalf("Error while opening client stream: %v", err) 130 | } 131 | 132 | numbers := []int32{3, 5, 9, 54, 23} 133 | 134 | for _, number := range numbers { 135 | fmt.Printf("Sending number: %v\n", number) 136 | stream.Send(&calculatorpb.ComputeAverageRequest{ 137 | Number: number, 138 | }) 139 | } 140 | 141 | res, err := stream.CloseAndRecv() 142 | 143 | if err != nil { 144 | log.Fatalf("Error while receiving response: %v", err) 145 | } 146 | 147 | fmt.Printf("The Average is: %v\n", res.Average) 148 | } 149 | 150 | func doServerStreaming(c calculatorpb.CalculatorServiceClient) { 151 | fmt.Println("Starting to do Server Streaming RPC...") 152 | 153 | req := &calculatorpb.PrimeNumberDecompositionRequest{ 154 | Number: 12, 155 | } 156 | 157 | streamRes, err := c.PrimeNumberDecomposition(context.Background(), req) 158 | 159 | if err != nil { 160 | log.Fatalf("error while calling GreetManyTimes RPC: %v", err) 161 | } 162 | 163 | results := []int32{} 164 | 165 | for { 166 | msg, err := streamRes.Recv() 167 | 168 | if err == io.EOF { 169 | // we've reached the end of the stream 170 | break 171 | } 172 | if err != nil { 173 | log.Fatalf("error while calling GreetManyTimes RPC: %v", err) 174 | } 175 | 176 | results = append(results, msg.GetPrimeNumberDecomposition()) 177 | } 178 | 179 | fmt.Printf("Result: %v\n", results) 180 | 181 | } 182 | 183 | func doUnary(c calculatorpb.CalculatorServiceClient) { 184 | fmt.Println("Starting to do Unary RPC...") 185 | 186 | req := &calculatorpb.SumRequest{ 187 | FirstNumber: 10, 188 | SecondNumber: 90, 189 | } 190 | 191 | res, err := c.Sum(context.Background(), req) 192 | 193 | if err != nil { 194 | log.Fatalf("error while calling Greet RPC: %v", err) 195 | } 196 | log.Printf("Response from Greet: %v", res.SumResult) 197 | } 198 | -------------------------------------------------------------------------------- /calculator/calculator_server/server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "io" 7 | "log" 8 | "math" 9 | "net" 10 | // "time" 11 | 12 | "google.golang.org/grpc" 13 | "google.golang.org/grpc/codes" 14 | "google.golang.org/grpc/reflection" 15 | "google.golang.org/grpc/status" 16 | 17 | "github.com/minhtran241/grpc-go/calculator/calculatorpb" 18 | ) 19 | 20 | type server struct{} 21 | 22 | func (*server) Sum(ctx context.Context, req *calculatorpb.SumRequest) (*calculatorpb.SumResponse, error) { 23 | fmt.Printf("Received Sum RPC: %v\n", req) 24 | 25 | firstNumber := req.FirstNumber 26 | secondNumber := req.SecondNumber 27 | 28 | sum := firstNumber + secondNumber 29 | 30 | res := &calculatorpb.SumResponse{ 31 | SumResult: sum, 32 | } 33 | 34 | return res, nil 35 | } 36 | 37 | func (*server) PrimeNumberDecomposition(in *calculatorpb.PrimeNumberDecompositionRequest, stream calculatorpb.CalculatorService_PrimeNumberDecompositionServer) error { 38 | 39 | fmt.Printf("PrimeNumberDecomposition function was invoked with %v\n", in) 40 | 41 | number := in.GetNumber() 42 | 43 | primeDecomposition := getPrimeNumberDecomposition(number) 44 | 45 | for _, value := range primeDecomposition { 46 | res := &calculatorpb.PrimeNumberDecompositionResponse{ 47 | PrimeNumberDecomposition: value, 48 | } 49 | 50 | stream.Send(res) 51 | // time.Sleep(time.Second * 1) 52 | } 53 | 54 | return nil 55 | } 56 | 57 | func getPrimeNumberDecomposition(number int32) (primeDecomposition []int32) { 58 | 59 | k := int32(2) 60 | res := []int32{} 61 | 62 | for number > 1 { 63 | if number%k == 0 { 64 | res = append(res, k) 65 | number = number / k 66 | } else { 67 | k++ 68 | } 69 | } 70 | 71 | return res 72 | } 73 | 74 | func (*server) ComputeAverage(stream calculatorpb.CalculatorService_ComputeAverageServer) error { 75 | fmt.Println("Received ComputeAverage RPC") 76 | 77 | sum := int32(0) 78 | count := 0 79 | 80 | for { 81 | req, err := stream.Recv() 82 | 83 | if err == io.EOF { 84 | average := float64(sum) / float64(count) 85 | return stream.SendAndClose(&calculatorpb.ComputeAverageResponse{ 86 | Average: average, 87 | }) 88 | } 89 | 90 | if err != nil { 91 | log.Fatalf("Error while reading client stream: %v", err) 92 | } 93 | 94 | sum += req.GetNumber() 95 | count++ 96 | } 97 | 98 | } 99 | 100 | func (*server) FindMaximum(stream calculatorpb.CalculatorService_FindMaximumServer) error { 101 | fmt.Println("Received FindMaximum RPC") 102 | 103 | maximum := int32(math.MinInt32) 104 | 105 | for { 106 | req, err := stream.Recv() 107 | 108 | if err == io.EOF { 109 | return nil 110 | } 111 | 112 | if err != nil { 113 | log.Fatalf("Error while reading client stream: %v", err) 114 | return err 115 | } 116 | number := req.GetNumber() 117 | 118 | if number > maximum { 119 | maximum = number 120 | sendErr := stream.Send(&calculatorpb.FindMaximumResponse{ 121 | Maximum: maximum, 122 | }) 123 | if sendErr != nil { 124 | log.Fatalf("Error while sending data to client: %v", sendErr) 125 | } 126 | } 127 | } 128 | } 129 | 130 | func (*server) SquareRoot(ctx context.Context, in *calculatorpb.SquareRootRequest) (*calculatorpb.SquareRootResponse, error) { 131 | fmt.Println("Received SquareRoot RPC") 132 | 133 | number := in.GetNumber() 134 | 135 | if number < 0 { 136 | // send back an error 137 | return nil, status.Errorf( 138 | codes.InvalidArgument, 139 | fmt.Sprintf("Received a negative number: %v", number), 140 | ) 141 | } 142 | 143 | return &calculatorpb.SquareRootResponse{ 144 | NumberRoot: math.Sqrt(float64(number)), 145 | }, nil 146 | } 147 | 148 | func main() { 149 | fmt.Println("Server is running...") 150 | 151 | lis, err := net.Listen("tcp", "0.0.0.0:50051") // port binding 152 | 153 | if err != nil { 154 | log.Fatalf("Failed to listen: %v", err) 155 | } 156 | 157 | s := grpc.NewServer() // grpc server 158 | calculatorpb.RegisterCalculatorServiceServer(s, &server{}) // register greet service 159 | 160 | // Register reflection service on gRPC server. 161 | reflection.Register(s) 162 | 163 | if err := s.Serve(lis); err != nil { // bind the port to the grpc server 164 | log.Fatalf("Failed to serve: %v", err) 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /calculator/calculatorpb/calculator.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.28.1 4 | // protoc v3.21.7 5 | // source: calculator/calculatorpb/calculator.proto 6 | 7 | package calculatorpb 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type SumRequest struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | FirstNumber int32 `protobuf:"varint,1,opt,name=first_number,json=firstNumber,proto3" json:"first_number,omitempty"` 29 | SecondNumber int32 `protobuf:"varint,2,opt,name=second_number,json=secondNumber,proto3" json:"second_number,omitempty"` 30 | } 31 | 32 | func (x *SumRequest) Reset() { 33 | *x = SumRequest{} 34 | if protoimpl.UnsafeEnabled { 35 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[0] 36 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 37 | ms.StoreMessageInfo(mi) 38 | } 39 | } 40 | 41 | func (x *SumRequest) String() string { 42 | return protoimpl.X.MessageStringOf(x) 43 | } 44 | 45 | func (*SumRequest) ProtoMessage() {} 46 | 47 | func (x *SumRequest) ProtoReflect() protoreflect.Message { 48 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[0] 49 | if protoimpl.UnsafeEnabled && x != nil { 50 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 51 | if ms.LoadMessageInfo() == nil { 52 | ms.StoreMessageInfo(mi) 53 | } 54 | return ms 55 | } 56 | return mi.MessageOf(x) 57 | } 58 | 59 | // Deprecated: Use SumRequest.ProtoReflect.Descriptor instead. 60 | func (*SumRequest) Descriptor() ([]byte, []int) { 61 | return file_calculator_calculatorpb_calculator_proto_rawDescGZIP(), []int{0} 62 | } 63 | 64 | func (x *SumRequest) GetFirstNumber() int32 { 65 | if x != nil { 66 | return x.FirstNumber 67 | } 68 | return 0 69 | } 70 | 71 | func (x *SumRequest) GetSecondNumber() int32 { 72 | if x != nil { 73 | return x.SecondNumber 74 | } 75 | return 0 76 | } 77 | 78 | type SumResponse struct { 79 | state protoimpl.MessageState 80 | sizeCache protoimpl.SizeCache 81 | unknownFields protoimpl.UnknownFields 82 | 83 | SumResult int32 `protobuf:"varint,1,opt,name=sum_result,json=sumResult,proto3" json:"sum_result,omitempty"` 84 | } 85 | 86 | func (x *SumResponse) Reset() { 87 | *x = SumResponse{} 88 | if protoimpl.UnsafeEnabled { 89 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[1] 90 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 91 | ms.StoreMessageInfo(mi) 92 | } 93 | } 94 | 95 | func (x *SumResponse) String() string { 96 | return protoimpl.X.MessageStringOf(x) 97 | } 98 | 99 | func (*SumResponse) ProtoMessage() {} 100 | 101 | func (x *SumResponse) ProtoReflect() protoreflect.Message { 102 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[1] 103 | if protoimpl.UnsafeEnabled && x != nil { 104 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 105 | if ms.LoadMessageInfo() == nil { 106 | ms.StoreMessageInfo(mi) 107 | } 108 | return ms 109 | } 110 | return mi.MessageOf(x) 111 | } 112 | 113 | // Deprecated: Use SumResponse.ProtoReflect.Descriptor instead. 114 | func (*SumResponse) Descriptor() ([]byte, []int) { 115 | return file_calculator_calculatorpb_calculator_proto_rawDescGZIP(), []int{1} 116 | } 117 | 118 | func (x *SumResponse) GetSumResult() int32 { 119 | if x != nil { 120 | return x.SumResult 121 | } 122 | return 0 123 | } 124 | 125 | type PrimeNumberDecompositionRequest struct { 126 | state protoimpl.MessageState 127 | sizeCache protoimpl.SizeCache 128 | unknownFields protoimpl.UnknownFields 129 | 130 | Number int32 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` 131 | } 132 | 133 | func (x *PrimeNumberDecompositionRequest) Reset() { 134 | *x = PrimeNumberDecompositionRequest{} 135 | if protoimpl.UnsafeEnabled { 136 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[2] 137 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 138 | ms.StoreMessageInfo(mi) 139 | } 140 | } 141 | 142 | func (x *PrimeNumberDecompositionRequest) String() string { 143 | return protoimpl.X.MessageStringOf(x) 144 | } 145 | 146 | func (*PrimeNumberDecompositionRequest) ProtoMessage() {} 147 | 148 | func (x *PrimeNumberDecompositionRequest) ProtoReflect() protoreflect.Message { 149 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[2] 150 | if protoimpl.UnsafeEnabled && x != nil { 151 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 152 | if ms.LoadMessageInfo() == nil { 153 | ms.StoreMessageInfo(mi) 154 | } 155 | return ms 156 | } 157 | return mi.MessageOf(x) 158 | } 159 | 160 | // Deprecated: Use PrimeNumberDecompositionRequest.ProtoReflect.Descriptor instead. 161 | func (*PrimeNumberDecompositionRequest) Descriptor() ([]byte, []int) { 162 | return file_calculator_calculatorpb_calculator_proto_rawDescGZIP(), []int{2} 163 | } 164 | 165 | func (x *PrimeNumberDecompositionRequest) GetNumber() int32 { 166 | if x != nil { 167 | return x.Number 168 | } 169 | return 0 170 | } 171 | 172 | type PrimeNumberDecompositionResponse struct { 173 | state protoimpl.MessageState 174 | sizeCache protoimpl.SizeCache 175 | unknownFields protoimpl.UnknownFields 176 | 177 | PrimeNumberDecomposition int32 `protobuf:"varint,1,opt,name=primeNumberDecomposition,proto3" json:"primeNumberDecomposition,omitempty"` 178 | } 179 | 180 | func (x *PrimeNumberDecompositionResponse) Reset() { 181 | *x = PrimeNumberDecompositionResponse{} 182 | if protoimpl.UnsafeEnabled { 183 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[3] 184 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 185 | ms.StoreMessageInfo(mi) 186 | } 187 | } 188 | 189 | func (x *PrimeNumberDecompositionResponse) String() string { 190 | return protoimpl.X.MessageStringOf(x) 191 | } 192 | 193 | func (*PrimeNumberDecompositionResponse) ProtoMessage() {} 194 | 195 | func (x *PrimeNumberDecompositionResponse) ProtoReflect() protoreflect.Message { 196 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[3] 197 | if protoimpl.UnsafeEnabled && x != nil { 198 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 199 | if ms.LoadMessageInfo() == nil { 200 | ms.StoreMessageInfo(mi) 201 | } 202 | return ms 203 | } 204 | return mi.MessageOf(x) 205 | } 206 | 207 | // Deprecated: Use PrimeNumberDecompositionResponse.ProtoReflect.Descriptor instead. 208 | func (*PrimeNumberDecompositionResponse) Descriptor() ([]byte, []int) { 209 | return file_calculator_calculatorpb_calculator_proto_rawDescGZIP(), []int{3} 210 | } 211 | 212 | func (x *PrimeNumberDecompositionResponse) GetPrimeNumberDecomposition() int32 { 213 | if x != nil { 214 | return x.PrimeNumberDecomposition 215 | } 216 | return 0 217 | } 218 | 219 | type ComputeAverageRequest struct { 220 | state protoimpl.MessageState 221 | sizeCache protoimpl.SizeCache 222 | unknownFields protoimpl.UnknownFields 223 | 224 | Number int32 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` 225 | } 226 | 227 | func (x *ComputeAverageRequest) Reset() { 228 | *x = ComputeAverageRequest{} 229 | if protoimpl.UnsafeEnabled { 230 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[4] 231 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 232 | ms.StoreMessageInfo(mi) 233 | } 234 | } 235 | 236 | func (x *ComputeAverageRequest) String() string { 237 | return protoimpl.X.MessageStringOf(x) 238 | } 239 | 240 | func (*ComputeAverageRequest) ProtoMessage() {} 241 | 242 | func (x *ComputeAverageRequest) ProtoReflect() protoreflect.Message { 243 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[4] 244 | if protoimpl.UnsafeEnabled && x != nil { 245 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 246 | if ms.LoadMessageInfo() == nil { 247 | ms.StoreMessageInfo(mi) 248 | } 249 | return ms 250 | } 251 | return mi.MessageOf(x) 252 | } 253 | 254 | // Deprecated: Use ComputeAverageRequest.ProtoReflect.Descriptor instead. 255 | func (*ComputeAverageRequest) Descriptor() ([]byte, []int) { 256 | return file_calculator_calculatorpb_calculator_proto_rawDescGZIP(), []int{4} 257 | } 258 | 259 | func (x *ComputeAverageRequest) GetNumber() int32 { 260 | if x != nil { 261 | return x.Number 262 | } 263 | return 0 264 | } 265 | 266 | type ComputeAverageResponse struct { 267 | state protoimpl.MessageState 268 | sizeCache protoimpl.SizeCache 269 | unknownFields protoimpl.UnknownFields 270 | 271 | Average float64 `protobuf:"fixed64,1,opt,name=average,proto3" json:"average,omitempty"` 272 | } 273 | 274 | func (x *ComputeAverageResponse) Reset() { 275 | *x = ComputeAverageResponse{} 276 | if protoimpl.UnsafeEnabled { 277 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[5] 278 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 279 | ms.StoreMessageInfo(mi) 280 | } 281 | } 282 | 283 | func (x *ComputeAverageResponse) String() string { 284 | return protoimpl.X.MessageStringOf(x) 285 | } 286 | 287 | func (*ComputeAverageResponse) ProtoMessage() {} 288 | 289 | func (x *ComputeAverageResponse) ProtoReflect() protoreflect.Message { 290 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[5] 291 | if protoimpl.UnsafeEnabled && x != nil { 292 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 293 | if ms.LoadMessageInfo() == nil { 294 | ms.StoreMessageInfo(mi) 295 | } 296 | return ms 297 | } 298 | return mi.MessageOf(x) 299 | } 300 | 301 | // Deprecated: Use ComputeAverageResponse.ProtoReflect.Descriptor instead. 302 | func (*ComputeAverageResponse) Descriptor() ([]byte, []int) { 303 | return file_calculator_calculatorpb_calculator_proto_rawDescGZIP(), []int{5} 304 | } 305 | 306 | func (x *ComputeAverageResponse) GetAverage() float64 { 307 | if x != nil { 308 | return x.Average 309 | } 310 | return 0 311 | } 312 | 313 | type FindMaximumRequest struct { 314 | state protoimpl.MessageState 315 | sizeCache protoimpl.SizeCache 316 | unknownFields protoimpl.UnknownFields 317 | 318 | Number int32 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` 319 | } 320 | 321 | func (x *FindMaximumRequest) Reset() { 322 | *x = FindMaximumRequest{} 323 | if protoimpl.UnsafeEnabled { 324 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[6] 325 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 326 | ms.StoreMessageInfo(mi) 327 | } 328 | } 329 | 330 | func (x *FindMaximumRequest) String() string { 331 | return protoimpl.X.MessageStringOf(x) 332 | } 333 | 334 | func (*FindMaximumRequest) ProtoMessage() {} 335 | 336 | func (x *FindMaximumRequest) ProtoReflect() protoreflect.Message { 337 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[6] 338 | if protoimpl.UnsafeEnabled && x != nil { 339 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 340 | if ms.LoadMessageInfo() == nil { 341 | ms.StoreMessageInfo(mi) 342 | } 343 | return ms 344 | } 345 | return mi.MessageOf(x) 346 | } 347 | 348 | // Deprecated: Use FindMaximumRequest.ProtoReflect.Descriptor instead. 349 | func (*FindMaximumRequest) Descriptor() ([]byte, []int) { 350 | return file_calculator_calculatorpb_calculator_proto_rawDescGZIP(), []int{6} 351 | } 352 | 353 | func (x *FindMaximumRequest) GetNumber() int32 { 354 | if x != nil { 355 | return x.Number 356 | } 357 | return 0 358 | } 359 | 360 | type FindMaximumResponse struct { 361 | state protoimpl.MessageState 362 | sizeCache protoimpl.SizeCache 363 | unknownFields protoimpl.UnknownFields 364 | 365 | Maximum int32 `protobuf:"varint,1,opt,name=maximum,proto3" json:"maximum,omitempty"` 366 | } 367 | 368 | func (x *FindMaximumResponse) Reset() { 369 | *x = FindMaximumResponse{} 370 | if protoimpl.UnsafeEnabled { 371 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[7] 372 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 373 | ms.StoreMessageInfo(mi) 374 | } 375 | } 376 | 377 | func (x *FindMaximumResponse) String() string { 378 | return protoimpl.X.MessageStringOf(x) 379 | } 380 | 381 | func (*FindMaximumResponse) ProtoMessage() {} 382 | 383 | func (x *FindMaximumResponse) ProtoReflect() protoreflect.Message { 384 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[7] 385 | if protoimpl.UnsafeEnabled && x != nil { 386 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 387 | if ms.LoadMessageInfo() == nil { 388 | ms.StoreMessageInfo(mi) 389 | } 390 | return ms 391 | } 392 | return mi.MessageOf(x) 393 | } 394 | 395 | // Deprecated: Use FindMaximumResponse.ProtoReflect.Descriptor instead. 396 | func (*FindMaximumResponse) Descriptor() ([]byte, []int) { 397 | return file_calculator_calculatorpb_calculator_proto_rawDescGZIP(), []int{7} 398 | } 399 | 400 | func (x *FindMaximumResponse) GetMaximum() int32 { 401 | if x != nil { 402 | return x.Maximum 403 | } 404 | return 0 405 | } 406 | 407 | type SquareRootRequest struct { 408 | state protoimpl.MessageState 409 | sizeCache protoimpl.SizeCache 410 | unknownFields protoimpl.UnknownFields 411 | 412 | Number int32 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` 413 | } 414 | 415 | func (x *SquareRootRequest) Reset() { 416 | *x = SquareRootRequest{} 417 | if protoimpl.UnsafeEnabled { 418 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[8] 419 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 420 | ms.StoreMessageInfo(mi) 421 | } 422 | } 423 | 424 | func (x *SquareRootRequest) String() string { 425 | return protoimpl.X.MessageStringOf(x) 426 | } 427 | 428 | func (*SquareRootRequest) ProtoMessage() {} 429 | 430 | func (x *SquareRootRequest) ProtoReflect() protoreflect.Message { 431 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[8] 432 | if protoimpl.UnsafeEnabled && x != nil { 433 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 434 | if ms.LoadMessageInfo() == nil { 435 | ms.StoreMessageInfo(mi) 436 | } 437 | return ms 438 | } 439 | return mi.MessageOf(x) 440 | } 441 | 442 | // Deprecated: Use SquareRootRequest.ProtoReflect.Descriptor instead. 443 | func (*SquareRootRequest) Descriptor() ([]byte, []int) { 444 | return file_calculator_calculatorpb_calculator_proto_rawDescGZIP(), []int{8} 445 | } 446 | 447 | func (x *SquareRootRequest) GetNumber() int32 { 448 | if x != nil { 449 | return x.Number 450 | } 451 | return 0 452 | } 453 | 454 | type SquareRootResponse struct { 455 | state protoimpl.MessageState 456 | sizeCache protoimpl.SizeCache 457 | unknownFields protoimpl.UnknownFields 458 | 459 | NumberRoot float64 `protobuf:"fixed64,1,opt,name=number_root,json=numberRoot,proto3" json:"number_root,omitempty"` 460 | } 461 | 462 | func (x *SquareRootResponse) Reset() { 463 | *x = SquareRootResponse{} 464 | if protoimpl.UnsafeEnabled { 465 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[9] 466 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 467 | ms.StoreMessageInfo(mi) 468 | } 469 | } 470 | 471 | func (x *SquareRootResponse) String() string { 472 | return protoimpl.X.MessageStringOf(x) 473 | } 474 | 475 | func (*SquareRootResponse) ProtoMessage() {} 476 | 477 | func (x *SquareRootResponse) ProtoReflect() protoreflect.Message { 478 | mi := &file_calculator_calculatorpb_calculator_proto_msgTypes[9] 479 | if protoimpl.UnsafeEnabled && x != nil { 480 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 481 | if ms.LoadMessageInfo() == nil { 482 | ms.StoreMessageInfo(mi) 483 | } 484 | return ms 485 | } 486 | return mi.MessageOf(x) 487 | } 488 | 489 | // Deprecated: Use SquareRootResponse.ProtoReflect.Descriptor instead. 490 | func (*SquareRootResponse) Descriptor() ([]byte, []int) { 491 | return file_calculator_calculatorpb_calculator_proto_rawDescGZIP(), []int{9} 492 | } 493 | 494 | func (x *SquareRootResponse) GetNumberRoot() float64 { 495 | if x != nil { 496 | return x.NumberRoot 497 | } 498 | return 0 499 | } 500 | 501 | var File_calculator_calculatorpb_calculator_proto protoreflect.FileDescriptor 502 | 503 | var file_calculator_calculatorpb_calculator_proto_rawDesc = []byte{ 504 | 0x0a, 0x28, 0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2f, 0x63, 0x61, 0x6c, 505 | 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x70, 0x62, 0x2f, 0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 506 | 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x63, 0x61, 0x6c, 0x63, 507 | 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x54, 0x0a, 0x0a, 0x53, 0x75, 0x6d, 0x52, 0x65, 0x71, 508 | 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x69, 0x72, 0x73, 0x74, 0x5f, 0x6e, 0x75, 509 | 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x66, 0x69, 0x72, 0x73, 510 | 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x65, 0x63, 0x6f, 0x6e, 511 | 0x64, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 512 | 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x2c, 0x0a, 0x0b, 513 | 0x53, 0x75, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 514 | 0x75, 0x6d, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 515 | 0x09, 0x73, 0x75, 0x6d, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x39, 0x0a, 0x1f, 0x50, 0x72, 516 | 0x69, 0x6d, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x44, 0x65, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 517 | 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 518 | 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6e, 519 | 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x5e, 0x0a, 0x20, 0x50, 0x72, 0x69, 0x6d, 0x65, 0x4e, 0x75, 520 | 0x6d, 0x62, 0x65, 0x72, 0x44, 0x65, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 521 | 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x18, 0x70, 0x72, 0x69, 522 | 0x6d, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x44, 0x65, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 523 | 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x18, 0x70, 0x72, 0x69, 524 | 0x6d, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x44, 0x65, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 525 | 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x2f, 0x0a, 0x15, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 526 | 0x41, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 527 | 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 528 | 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x32, 0x0a, 0x16, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 529 | 0x65, 0x41, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 530 | 0x12, 0x18, 0x0a, 0x07, 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 531 | 0x01, 0x52, 0x07, 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x22, 0x2c, 0x0a, 0x12, 0x46, 0x69, 532 | 0x6e, 0x64, 0x4d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 533 | 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 534 | 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x2f, 0x0a, 0x13, 0x46, 0x69, 0x6e, 0x64, 535 | 0x4d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 536 | 0x18, 0x0a, 0x07, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 537 | 0x52, 0x07, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x22, 0x2b, 0x0a, 0x11, 0x53, 0x71, 0x75, 538 | 0x61, 0x72, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 539 | 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 540 | 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x35, 0x0a, 0x12, 0x53, 0x71, 0x75, 0x61, 0x72, 0x65, 541 | 0x52, 0x6f, 0x6f, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 542 | 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 543 | 0x01, 0x52, 0x0a, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x6f, 0x6f, 0x74, 0x32, 0xca, 0x03, 544 | 0x0a, 0x11, 0x43, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x72, 0x76, 545 | 0x69, 0x63, 0x65, 0x12, 0x38, 0x0a, 0x03, 0x53, 0x75, 0x6d, 0x12, 0x16, 0x2e, 0x63, 0x61, 0x6c, 546 | 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x53, 0x75, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 547 | 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e, 548 | 0x53, 0x75, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x79, 0x0a, 549 | 0x18, 0x50, 0x72, 0x69, 0x6d, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x44, 0x65, 0x63, 0x6f, 550 | 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x2e, 0x63, 0x61, 0x6c, 0x63, 551 | 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x50, 0x72, 0x69, 0x6d, 0x65, 0x4e, 0x75, 0x6d, 0x62, 552 | 0x65, 0x72, 0x44, 0x65, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 553 | 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 554 | 0x74, 0x6f, 0x72, 0x2e, 0x50, 0x72, 0x69, 0x6d, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x44, 555 | 0x65, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 556 | 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x5b, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x70, 557 | 0x75, 0x74, 0x65, 0x41, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x12, 0x21, 0x2e, 0x63, 0x61, 0x6c, 558 | 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x41, 559 | 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 560 | 0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x75, 561 | 0x74, 0x65, 0x41, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 562 | 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x54, 0x0a, 0x0b, 0x46, 0x69, 0x6e, 0x64, 0x4d, 0x61, 0x78, 563 | 0x69, 0x6d, 0x75, 0x6d, 0x12, 0x1e, 0x2e, 0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 564 | 0x72, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x4d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x52, 0x65, 0x71, 565 | 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 566 | 0x72, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x4d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x52, 0x65, 0x73, 567 | 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x12, 0x4d, 0x0a, 0x0a, 0x53, 568 | 0x71, 0x75, 0x61, 0x72, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1d, 0x2e, 0x63, 0x61, 0x6c, 0x63, 569 | 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x53, 0x71, 0x75, 0x61, 0x72, 0x65, 0x52, 0x6f, 0x6f, 570 | 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x63, 0x61, 0x6c, 0x63, 0x75, 571 | 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x53, 0x71, 0x75, 0x61, 0x72, 0x65, 0x52, 0x6f, 0x6f, 0x74, 572 | 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x19, 0x5a, 0x17, 0x63, 0x61, 573 | 0x6c, 0x63, 0x75, 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x2f, 0x63, 0x61, 0x6c, 0x63, 0x75, 0x6c, 0x61, 574 | 0x74, 0x6f, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 575 | } 576 | 577 | var ( 578 | file_calculator_calculatorpb_calculator_proto_rawDescOnce sync.Once 579 | file_calculator_calculatorpb_calculator_proto_rawDescData = file_calculator_calculatorpb_calculator_proto_rawDesc 580 | ) 581 | 582 | func file_calculator_calculatorpb_calculator_proto_rawDescGZIP() []byte { 583 | file_calculator_calculatorpb_calculator_proto_rawDescOnce.Do(func() { 584 | file_calculator_calculatorpb_calculator_proto_rawDescData = protoimpl.X.CompressGZIP(file_calculator_calculatorpb_calculator_proto_rawDescData) 585 | }) 586 | return file_calculator_calculatorpb_calculator_proto_rawDescData 587 | } 588 | 589 | var file_calculator_calculatorpb_calculator_proto_msgTypes = make([]protoimpl.MessageInfo, 10) 590 | var file_calculator_calculatorpb_calculator_proto_goTypes = []interface{}{ 591 | (*SumRequest)(nil), // 0: calculator.SumRequest 592 | (*SumResponse)(nil), // 1: calculator.SumResponse 593 | (*PrimeNumberDecompositionRequest)(nil), // 2: calculator.PrimeNumberDecompositionRequest 594 | (*PrimeNumberDecompositionResponse)(nil), // 3: calculator.PrimeNumberDecompositionResponse 595 | (*ComputeAverageRequest)(nil), // 4: calculator.ComputeAverageRequest 596 | (*ComputeAverageResponse)(nil), // 5: calculator.ComputeAverageResponse 597 | (*FindMaximumRequest)(nil), // 6: calculator.FindMaximumRequest 598 | (*FindMaximumResponse)(nil), // 7: calculator.FindMaximumResponse 599 | (*SquareRootRequest)(nil), // 8: calculator.SquareRootRequest 600 | (*SquareRootResponse)(nil), // 9: calculator.SquareRootResponse 601 | } 602 | var file_calculator_calculatorpb_calculator_proto_depIdxs = []int32{ 603 | 0, // 0: calculator.CalculatorService.Sum:input_type -> calculator.SumRequest 604 | 2, // 1: calculator.CalculatorService.PrimeNumberDecomposition:input_type -> calculator.PrimeNumberDecompositionRequest 605 | 4, // 2: calculator.CalculatorService.ComputeAverage:input_type -> calculator.ComputeAverageRequest 606 | 6, // 3: calculator.CalculatorService.FindMaximum:input_type -> calculator.FindMaximumRequest 607 | 8, // 4: calculator.CalculatorService.SquareRoot:input_type -> calculator.SquareRootRequest 608 | 1, // 5: calculator.CalculatorService.Sum:output_type -> calculator.SumResponse 609 | 3, // 6: calculator.CalculatorService.PrimeNumberDecomposition:output_type -> calculator.PrimeNumberDecompositionResponse 610 | 5, // 7: calculator.CalculatorService.ComputeAverage:output_type -> calculator.ComputeAverageResponse 611 | 7, // 8: calculator.CalculatorService.FindMaximum:output_type -> calculator.FindMaximumResponse 612 | 9, // 9: calculator.CalculatorService.SquareRoot:output_type -> calculator.SquareRootResponse 613 | 5, // [5:10] is the sub-list for method output_type 614 | 0, // [0:5] is the sub-list for method input_type 615 | 0, // [0:0] is the sub-list for extension type_name 616 | 0, // [0:0] is the sub-list for extension extendee 617 | 0, // [0:0] is the sub-list for field type_name 618 | } 619 | 620 | func init() { file_calculator_calculatorpb_calculator_proto_init() } 621 | func file_calculator_calculatorpb_calculator_proto_init() { 622 | if File_calculator_calculatorpb_calculator_proto != nil { 623 | return 624 | } 625 | if !protoimpl.UnsafeEnabled { 626 | file_calculator_calculatorpb_calculator_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 627 | switch v := v.(*SumRequest); i { 628 | case 0: 629 | return &v.state 630 | case 1: 631 | return &v.sizeCache 632 | case 2: 633 | return &v.unknownFields 634 | default: 635 | return nil 636 | } 637 | } 638 | file_calculator_calculatorpb_calculator_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 639 | switch v := v.(*SumResponse); i { 640 | case 0: 641 | return &v.state 642 | case 1: 643 | return &v.sizeCache 644 | case 2: 645 | return &v.unknownFields 646 | default: 647 | return nil 648 | } 649 | } 650 | file_calculator_calculatorpb_calculator_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { 651 | switch v := v.(*PrimeNumberDecompositionRequest); i { 652 | case 0: 653 | return &v.state 654 | case 1: 655 | return &v.sizeCache 656 | case 2: 657 | return &v.unknownFields 658 | default: 659 | return nil 660 | } 661 | } 662 | file_calculator_calculatorpb_calculator_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { 663 | switch v := v.(*PrimeNumberDecompositionResponse); i { 664 | case 0: 665 | return &v.state 666 | case 1: 667 | return &v.sizeCache 668 | case 2: 669 | return &v.unknownFields 670 | default: 671 | return nil 672 | } 673 | } 674 | file_calculator_calculatorpb_calculator_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { 675 | switch v := v.(*ComputeAverageRequest); i { 676 | case 0: 677 | return &v.state 678 | case 1: 679 | return &v.sizeCache 680 | case 2: 681 | return &v.unknownFields 682 | default: 683 | return nil 684 | } 685 | } 686 | file_calculator_calculatorpb_calculator_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { 687 | switch v := v.(*ComputeAverageResponse); i { 688 | case 0: 689 | return &v.state 690 | case 1: 691 | return &v.sizeCache 692 | case 2: 693 | return &v.unknownFields 694 | default: 695 | return nil 696 | } 697 | } 698 | file_calculator_calculatorpb_calculator_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { 699 | switch v := v.(*FindMaximumRequest); i { 700 | case 0: 701 | return &v.state 702 | case 1: 703 | return &v.sizeCache 704 | case 2: 705 | return &v.unknownFields 706 | default: 707 | return nil 708 | } 709 | } 710 | file_calculator_calculatorpb_calculator_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { 711 | switch v := v.(*FindMaximumResponse); i { 712 | case 0: 713 | return &v.state 714 | case 1: 715 | return &v.sizeCache 716 | case 2: 717 | return &v.unknownFields 718 | default: 719 | return nil 720 | } 721 | } 722 | file_calculator_calculatorpb_calculator_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { 723 | switch v := v.(*SquareRootRequest); i { 724 | case 0: 725 | return &v.state 726 | case 1: 727 | return &v.sizeCache 728 | case 2: 729 | return &v.unknownFields 730 | default: 731 | return nil 732 | } 733 | } 734 | file_calculator_calculatorpb_calculator_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { 735 | switch v := v.(*SquareRootResponse); i { 736 | case 0: 737 | return &v.state 738 | case 1: 739 | return &v.sizeCache 740 | case 2: 741 | return &v.unknownFields 742 | default: 743 | return nil 744 | } 745 | } 746 | } 747 | type x struct{} 748 | out := protoimpl.TypeBuilder{ 749 | File: protoimpl.DescBuilder{ 750 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 751 | RawDescriptor: file_calculator_calculatorpb_calculator_proto_rawDesc, 752 | NumEnums: 0, 753 | NumMessages: 10, 754 | NumExtensions: 0, 755 | NumServices: 1, 756 | }, 757 | GoTypes: file_calculator_calculatorpb_calculator_proto_goTypes, 758 | DependencyIndexes: file_calculator_calculatorpb_calculator_proto_depIdxs, 759 | MessageInfos: file_calculator_calculatorpb_calculator_proto_msgTypes, 760 | }.Build() 761 | File_calculator_calculatorpb_calculator_proto = out.File 762 | file_calculator_calculatorpb_calculator_proto_rawDesc = nil 763 | file_calculator_calculatorpb_calculator_proto_goTypes = nil 764 | file_calculator_calculatorpb_calculator_proto_depIdxs = nil 765 | } 766 | -------------------------------------------------------------------------------- /calculator/calculatorpb/calculator.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package calculator; 4 | option go_package="calculator/calculatorpb"; 5 | 6 | message SumRequest { 7 | int32 first_number = 1; 8 | int32 second_number = 2; 9 | } 10 | 11 | message SumResponse { 12 | int32 sum_result = 1; 13 | } 14 | 15 | message PrimeNumberDecompositionRequest { 16 | int32 number = 1; 17 | } 18 | 19 | message PrimeNumberDecompositionResponse { 20 | int32 primeNumberDecomposition = 1; 21 | } 22 | 23 | message ComputeAverageRequest { 24 | int32 number = 1; 25 | } 26 | 27 | message ComputeAverageResponse { 28 | double average = 1; 29 | } 30 | 31 | message FindMaximumRequest{ 32 | int32 number = 1; 33 | } 34 | 35 | message FindMaximumResponse { 36 | int32 maximum = 1; 37 | } 38 | 39 | message SquareRootRequest { 40 | int32 number = 1; 41 | } 42 | 43 | message SquareRootResponse { 44 | double number_root = 1; 45 | } 46 | 47 | service CalculatorService { 48 | // Unary 49 | rpc Sum(SumRequest) returns (SumResponse) {}; 50 | 51 | // Server Streaming 52 | rpc PrimeNumberDecomposition(PrimeNumberDecompositionRequest) returns (stream PrimeNumberDecompositionResponse) {}; 53 | 54 | // Client Streaming 55 | rpc ComputeAverage(stream ComputeAverageRequest) returns (ComputeAverageResponse) {}; 56 | 57 | // BiDi Streaming 58 | rpc FindMaximum(stream FindMaximumRequest) returns (stream FindMaximumResponse) {}; 59 | 60 | // Errors Handling 61 | // This RPC will throw an exception if the sent number is negative 62 | // The error being sent is of type INVALID_ARGUMENT 63 | rpc SquareRoot(SquareRootRequest) returns (SquareRootResponse) {}; 64 | } -------------------------------------------------------------------------------- /calculator/calculatorpb/calculator_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.2.0 4 | // - protoc v3.21.7 5 | // source: calculator/calculatorpb/calculator.proto 6 | 7 | package calculatorpb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.32.0 or later. 19 | const _ = grpc.SupportPackageIsVersion7 20 | 21 | // CalculatorServiceClient is the client API for CalculatorService service. 22 | // 23 | // 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. 24 | type CalculatorServiceClient interface { 25 | // Unary 26 | Sum(ctx context.Context, in *SumRequest, opts ...grpc.CallOption) (*SumResponse, error) 27 | // Server Streaming 28 | PrimeNumberDecomposition(ctx context.Context, in *PrimeNumberDecompositionRequest, opts ...grpc.CallOption) (CalculatorService_PrimeNumberDecompositionClient, error) 29 | // Client Streaming 30 | ComputeAverage(ctx context.Context, opts ...grpc.CallOption) (CalculatorService_ComputeAverageClient, error) 31 | // BiDi Streaming 32 | FindMaximum(ctx context.Context, opts ...grpc.CallOption) (CalculatorService_FindMaximumClient, error) 33 | // Errors Handling 34 | // This RPC will throw an exception if the sent number is negative 35 | // The error being sent is of type INVALID_ARGUMENT 36 | SquareRoot(ctx context.Context, in *SquareRootRequest, opts ...grpc.CallOption) (*SquareRootResponse, error) 37 | } 38 | 39 | type calculatorServiceClient struct { 40 | cc grpc.ClientConnInterface 41 | } 42 | 43 | func NewCalculatorServiceClient(cc grpc.ClientConnInterface) CalculatorServiceClient { 44 | return &calculatorServiceClient{cc} 45 | } 46 | 47 | func (c *calculatorServiceClient) Sum(ctx context.Context, in *SumRequest, opts ...grpc.CallOption) (*SumResponse, error) { 48 | out := new(SumResponse) 49 | err := c.cc.Invoke(ctx, "/calculator.CalculatorService/Sum", in, out, opts...) 50 | if err != nil { 51 | return nil, err 52 | } 53 | return out, nil 54 | } 55 | 56 | func (c *calculatorServiceClient) PrimeNumberDecomposition(ctx context.Context, in *PrimeNumberDecompositionRequest, opts ...grpc.CallOption) (CalculatorService_PrimeNumberDecompositionClient, error) { 57 | stream, err := c.cc.NewStream(ctx, &CalculatorService_ServiceDesc.Streams[0], "/calculator.CalculatorService/PrimeNumberDecomposition", opts...) 58 | if err != nil { 59 | return nil, err 60 | } 61 | x := &calculatorServicePrimeNumberDecompositionClient{stream} 62 | if err := x.ClientStream.SendMsg(in); err != nil { 63 | return nil, err 64 | } 65 | if err := x.ClientStream.CloseSend(); err != nil { 66 | return nil, err 67 | } 68 | return x, nil 69 | } 70 | 71 | type CalculatorService_PrimeNumberDecompositionClient interface { 72 | Recv() (*PrimeNumberDecompositionResponse, error) 73 | grpc.ClientStream 74 | } 75 | 76 | type calculatorServicePrimeNumberDecompositionClient struct { 77 | grpc.ClientStream 78 | } 79 | 80 | func (x *calculatorServicePrimeNumberDecompositionClient) Recv() (*PrimeNumberDecompositionResponse, error) { 81 | m := new(PrimeNumberDecompositionResponse) 82 | if err := x.ClientStream.RecvMsg(m); err != nil { 83 | return nil, err 84 | } 85 | return m, nil 86 | } 87 | 88 | func (c *calculatorServiceClient) ComputeAverage(ctx context.Context, opts ...grpc.CallOption) (CalculatorService_ComputeAverageClient, error) { 89 | stream, err := c.cc.NewStream(ctx, &CalculatorService_ServiceDesc.Streams[1], "/calculator.CalculatorService/ComputeAverage", opts...) 90 | if err != nil { 91 | return nil, err 92 | } 93 | x := &calculatorServiceComputeAverageClient{stream} 94 | return x, nil 95 | } 96 | 97 | type CalculatorService_ComputeAverageClient interface { 98 | Send(*ComputeAverageRequest) error 99 | CloseAndRecv() (*ComputeAverageResponse, error) 100 | grpc.ClientStream 101 | } 102 | 103 | type calculatorServiceComputeAverageClient struct { 104 | grpc.ClientStream 105 | } 106 | 107 | func (x *calculatorServiceComputeAverageClient) Send(m *ComputeAverageRequest) error { 108 | return x.ClientStream.SendMsg(m) 109 | } 110 | 111 | func (x *calculatorServiceComputeAverageClient) CloseAndRecv() (*ComputeAverageResponse, error) { 112 | if err := x.ClientStream.CloseSend(); err != nil { 113 | return nil, err 114 | } 115 | m := new(ComputeAverageResponse) 116 | if err := x.ClientStream.RecvMsg(m); err != nil { 117 | return nil, err 118 | } 119 | return m, nil 120 | } 121 | 122 | func (c *calculatorServiceClient) FindMaximum(ctx context.Context, opts ...grpc.CallOption) (CalculatorService_FindMaximumClient, error) { 123 | stream, err := c.cc.NewStream(ctx, &CalculatorService_ServiceDesc.Streams[2], "/calculator.CalculatorService/FindMaximum", opts...) 124 | if err != nil { 125 | return nil, err 126 | } 127 | x := &calculatorServiceFindMaximumClient{stream} 128 | return x, nil 129 | } 130 | 131 | type CalculatorService_FindMaximumClient interface { 132 | Send(*FindMaximumRequest) error 133 | Recv() (*FindMaximumResponse, error) 134 | grpc.ClientStream 135 | } 136 | 137 | type calculatorServiceFindMaximumClient struct { 138 | grpc.ClientStream 139 | } 140 | 141 | func (x *calculatorServiceFindMaximumClient) Send(m *FindMaximumRequest) error { 142 | return x.ClientStream.SendMsg(m) 143 | } 144 | 145 | func (x *calculatorServiceFindMaximumClient) Recv() (*FindMaximumResponse, error) { 146 | m := new(FindMaximumResponse) 147 | if err := x.ClientStream.RecvMsg(m); err != nil { 148 | return nil, err 149 | } 150 | return m, nil 151 | } 152 | 153 | func (c *calculatorServiceClient) SquareRoot(ctx context.Context, in *SquareRootRequest, opts ...grpc.CallOption) (*SquareRootResponse, error) { 154 | out := new(SquareRootResponse) 155 | err := c.cc.Invoke(ctx, "/calculator.CalculatorService/SquareRoot", in, out, opts...) 156 | if err != nil { 157 | return nil, err 158 | } 159 | return out, nil 160 | } 161 | 162 | // CalculatorServiceServer is the server API for CalculatorService service. 163 | // All implementations should embed UnimplementedCalculatorServiceServer 164 | // for forward compatibility 165 | type CalculatorServiceServer interface { 166 | // Unary 167 | Sum(context.Context, *SumRequest) (*SumResponse, error) 168 | // Server Streaming 169 | PrimeNumberDecomposition(*PrimeNumberDecompositionRequest, CalculatorService_PrimeNumberDecompositionServer) error 170 | // Client Streaming 171 | ComputeAverage(CalculatorService_ComputeAverageServer) error 172 | // BiDi Streaming 173 | FindMaximum(CalculatorService_FindMaximumServer) error 174 | // Errors Handling 175 | // This RPC will throw an exception if the sent number is negative 176 | // The error being sent is of type INVALID_ARGUMENT 177 | SquareRoot(context.Context, *SquareRootRequest) (*SquareRootResponse, error) 178 | } 179 | 180 | // UnimplementedCalculatorServiceServer should be embedded to have forward compatible implementations. 181 | type UnimplementedCalculatorServiceServer struct { 182 | } 183 | 184 | func (UnimplementedCalculatorServiceServer) Sum(context.Context, *SumRequest) (*SumResponse, error) { 185 | return nil, status.Errorf(codes.Unimplemented, "method Sum not implemented") 186 | } 187 | func (UnimplementedCalculatorServiceServer) PrimeNumberDecomposition(*PrimeNumberDecompositionRequest, CalculatorService_PrimeNumberDecompositionServer) error { 188 | return status.Errorf(codes.Unimplemented, "method PrimeNumberDecomposition not implemented") 189 | } 190 | func (UnimplementedCalculatorServiceServer) ComputeAverage(CalculatorService_ComputeAverageServer) error { 191 | return status.Errorf(codes.Unimplemented, "method ComputeAverage not implemented") 192 | } 193 | func (UnimplementedCalculatorServiceServer) FindMaximum(CalculatorService_FindMaximumServer) error { 194 | return status.Errorf(codes.Unimplemented, "method FindMaximum not implemented") 195 | } 196 | func (UnimplementedCalculatorServiceServer) SquareRoot(context.Context, *SquareRootRequest) (*SquareRootResponse, error) { 197 | return nil, status.Errorf(codes.Unimplemented, "method SquareRoot not implemented") 198 | } 199 | 200 | // UnsafeCalculatorServiceServer may be embedded to opt out of forward compatibility for this service. 201 | // Use of this interface is not recommended, as added methods to CalculatorServiceServer will 202 | // result in compilation errors. 203 | type UnsafeCalculatorServiceServer interface { 204 | mustEmbedUnimplementedCalculatorServiceServer() 205 | } 206 | 207 | func RegisterCalculatorServiceServer(s grpc.ServiceRegistrar, srv CalculatorServiceServer) { 208 | s.RegisterService(&CalculatorService_ServiceDesc, srv) 209 | } 210 | 211 | func _CalculatorService_Sum_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 212 | in := new(SumRequest) 213 | if err := dec(in); err != nil { 214 | return nil, err 215 | } 216 | if interceptor == nil { 217 | return srv.(CalculatorServiceServer).Sum(ctx, in) 218 | } 219 | info := &grpc.UnaryServerInfo{ 220 | Server: srv, 221 | FullMethod: "/calculator.CalculatorService/Sum", 222 | } 223 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 224 | return srv.(CalculatorServiceServer).Sum(ctx, req.(*SumRequest)) 225 | } 226 | return interceptor(ctx, in, info, handler) 227 | } 228 | 229 | func _CalculatorService_PrimeNumberDecomposition_Handler(srv interface{}, stream grpc.ServerStream) error { 230 | m := new(PrimeNumberDecompositionRequest) 231 | if err := stream.RecvMsg(m); err != nil { 232 | return err 233 | } 234 | return srv.(CalculatorServiceServer).PrimeNumberDecomposition(m, &calculatorServicePrimeNumberDecompositionServer{stream}) 235 | } 236 | 237 | type CalculatorService_PrimeNumberDecompositionServer interface { 238 | Send(*PrimeNumberDecompositionResponse) error 239 | grpc.ServerStream 240 | } 241 | 242 | type calculatorServicePrimeNumberDecompositionServer struct { 243 | grpc.ServerStream 244 | } 245 | 246 | func (x *calculatorServicePrimeNumberDecompositionServer) Send(m *PrimeNumberDecompositionResponse) error { 247 | return x.ServerStream.SendMsg(m) 248 | } 249 | 250 | func _CalculatorService_ComputeAverage_Handler(srv interface{}, stream grpc.ServerStream) error { 251 | return srv.(CalculatorServiceServer).ComputeAverage(&calculatorServiceComputeAverageServer{stream}) 252 | } 253 | 254 | type CalculatorService_ComputeAverageServer interface { 255 | SendAndClose(*ComputeAverageResponse) error 256 | Recv() (*ComputeAverageRequest, error) 257 | grpc.ServerStream 258 | } 259 | 260 | type calculatorServiceComputeAverageServer struct { 261 | grpc.ServerStream 262 | } 263 | 264 | func (x *calculatorServiceComputeAverageServer) SendAndClose(m *ComputeAverageResponse) error { 265 | return x.ServerStream.SendMsg(m) 266 | } 267 | 268 | func (x *calculatorServiceComputeAverageServer) Recv() (*ComputeAverageRequest, error) { 269 | m := new(ComputeAverageRequest) 270 | if err := x.ServerStream.RecvMsg(m); err != nil { 271 | return nil, err 272 | } 273 | return m, nil 274 | } 275 | 276 | func _CalculatorService_FindMaximum_Handler(srv interface{}, stream grpc.ServerStream) error { 277 | return srv.(CalculatorServiceServer).FindMaximum(&calculatorServiceFindMaximumServer{stream}) 278 | } 279 | 280 | type CalculatorService_FindMaximumServer interface { 281 | Send(*FindMaximumResponse) error 282 | Recv() (*FindMaximumRequest, error) 283 | grpc.ServerStream 284 | } 285 | 286 | type calculatorServiceFindMaximumServer struct { 287 | grpc.ServerStream 288 | } 289 | 290 | func (x *calculatorServiceFindMaximumServer) Send(m *FindMaximumResponse) error { 291 | return x.ServerStream.SendMsg(m) 292 | } 293 | 294 | func (x *calculatorServiceFindMaximumServer) Recv() (*FindMaximumRequest, error) { 295 | m := new(FindMaximumRequest) 296 | if err := x.ServerStream.RecvMsg(m); err != nil { 297 | return nil, err 298 | } 299 | return m, nil 300 | } 301 | 302 | func _CalculatorService_SquareRoot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 303 | in := new(SquareRootRequest) 304 | if err := dec(in); err != nil { 305 | return nil, err 306 | } 307 | if interceptor == nil { 308 | return srv.(CalculatorServiceServer).SquareRoot(ctx, in) 309 | } 310 | info := &grpc.UnaryServerInfo{ 311 | Server: srv, 312 | FullMethod: "/calculator.CalculatorService/SquareRoot", 313 | } 314 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 315 | return srv.(CalculatorServiceServer).SquareRoot(ctx, req.(*SquareRootRequest)) 316 | } 317 | return interceptor(ctx, in, info, handler) 318 | } 319 | 320 | // CalculatorService_ServiceDesc is the grpc.ServiceDesc for CalculatorService service. 321 | // It's only intended for direct use with grpc.RegisterService, 322 | // and not to be introspected or modified (even as a copy) 323 | var CalculatorService_ServiceDesc = grpc.ServiceDesc{ 324 | ServiceName: "calculator.CalculatorService", 325 | HandlerType: (*CalculatorServiceServer)(nil), 326 | Methods: []grpc.MethodDesc{ 327 | { 328 | MethodName: "Sum", 329 | Handler: _CalculatorService_Sum_Handler, 330 | }, 331 | { 332 | MethodName: "SquareRoot", 333 | Handler: _CalculatorService_SquareRoot_Handler, 334 | }, 335 | }, 336 | Streams: []grpc.StreamDesc{ 337 | { 338 | StreamName: "PrimeNumberDecomposition", 339 | Handler: _CalculatorService_PrimeNumberDecomposition_Handler, 340 | ServerStreams: true, 341 | }, 342 | { 343 | StreamName: "ComputeAverage", 344 | Handler: _CalculatorService_ComputeAverage_Handler, 345 | ClientStreams: true, 346 | }, 347 | { 348 | StreamName: "FindMaximum", 349 | Handler: _CalculatorService_FindMaximum_Handler, 350 | ServerStreams: true, 351 | ClientStreams: true, 352 | }, 353 | }, 354 | Metadata: "calculator/calculatorpb/calculator.proto", 355 | } 356 | -------------------------------------------------------------------------------- /generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | protoc --go_out=. ./greet/greetpb/greet.proto #generate messages 4 | PATH="${PATH}:${HOME}/go/bin" #update your PATH so that the protoc compiler can find the plugins 5 | protoc --go-grpc_out=require_unimplemented_servers=false:. ./greet/greetpb/greet.proto #generate service 6 | 7 | protoc --go_out=. ./calculator/calculatorpb/calculator.proto 8 | PATH="${PATH}:${HOME}/go/bin" 9 | protoc --go-grpc_out=require_unimplemented_servers=false:. ./calculator/calculatorpb/calculator.proto 10 | 11 | protoc --go_out=. ./blog/blogpb/blog.proto 12 | PATH="${PATH}:${HOME}/go/bin" 13 | protoc --go-grpc_out=require_unimplemented_servers=false:. ./blog/blogpb/blog.proto -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/minhtran241/grpc-go 2 | 3 | go 1.18 4 | 5 | require ( 6 | go.mongodb.org/mongo-driver v1.10.3 7 | google.golang.org/protobuf v1.28.1 // indirectgo install google.golang.org/grpc/cmd/protoc-gen-go-grpc 8 | ) 9 | 10 | require ( 11 | github.com/golang/protobuf v1.5.2 // indirect 12 | github.com/golang/snappy v0.0.1 // indirect 13 | github.com/klauspost/compress v1.13.6 // indirect 14 | github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect 15 | github.com/pkg/errors v0.9.1 // indirect 16 | github.com/xdg-go/pbkdf2 v1.0.0 // indirect 17 | github.com/xdg-go/scram v1.1.1 // indirect 18 | github.com/xdg-go/stringprep v1.0.3 // indirect 19 | github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect 20 | golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect 21 | golang.org/x/net v0.0.0-20221004154528-8021a29435af // indirect 22 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect 23 | golang.org/x/sys v0.0.0-20221006211917-84dc82d7e875 // indirect 24 | golang.org/x/text v0.3.7 // indirect 25 | google.golang.org/genproto v0.0.0-20220930163606-c98284e70a91 // indirect 26 | google.golang.org/grpc v1.50.0 // indirect 27 | google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0 // indirect 28 | ) 29 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 2 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 3 | github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= 4 | github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= 5 | github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= 6 | github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= 7 | github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= 8 | github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= 9 | github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= 10 | github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= 11 | github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= 12 | github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= 13 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 14 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 15 | github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 16 | github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 17 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 18 | github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= 19 | github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= 20 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 21 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 22 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 23 | github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= 24 | github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= 25 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 26 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 27 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 28 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 29 | github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 30 | github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= 31 | github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= 32 | github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= 33 | github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E= 34 | github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= 35 | github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs= 36 | github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= 37 | github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= 38 | github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= 39 | go.mongodb.org/mongo-driver v1.10.3 h1:XDQEvmh6z1EUsXuIkXE9TaVeqHw6SwS1uf93jFs0HBA= 40 | go.mongodb.org/mongo-driver v1.10.3/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8= 41 | golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= 42 | golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= 43 | golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 44 | golang.org/x/net v0.0.0-20221004154528-8021a29435af h1:wv66FM3rLZGPdxpYL+ApnDe2HzHcTFta3z5nsc13wI4= 45 | golang.org/x/net v0.0.0-20221004154528-8021a29435af/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= 46 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= 47 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 48 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 49 | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 50 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 51 | golang.org/x/sys v0.0.0-20221006211917-84dc82d7e875 h1:AzgQNqF+FKwyQ5LbVrVqOcuuFB67N47F9+htZYH0wFM= 52 | golang.org/x/sys v0.0.0-20221006211917-84dc82d7e875/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 53 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 54 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 55 | golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= 56 | golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 57 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 58 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 59 | google.golang.org/genproto v0.0.0-20220930163606-c98284e70a91 h1:Ezh2cpcnP5Rq60sLensUsFnxh7P6513NLvNtCm9iyJ4= 60 | google.golang.org/genproto v0.0.0-20220930163606-c98284e70a91/go.mod h1:3526vdqwhZAwq4wsRUaVG555sVgsNmIjRtO7t/JH29U= 61 | google.golang.org/grpc v1.50.0 h1:fPVVDxY9w++VjTZsYvXWqEf9Rqar/e+9zYfxKK+W+YU= 62 | google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= 63 | google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.1 h1:M8spwkmx0pHrPq+uMdl22w5CvJ/Y+oAJTIs9oGoCpOE= 64 | google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.1/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= 65 | google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0 h1:TLkBREm4nIsEcexnCjgQd5GQWaHcqMzwQV0TX9pq8S0= 66 | google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY= 67 | google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= 68 | google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= 69 | google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= 70 | google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= 71 | google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= 72 | google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 73 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 74 | google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 75 | google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 76 | google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= 77 | google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= 78 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 79 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 80 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 81 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 82 | -------------------------------------------------------------------------------- /greet/greet_client/client.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "io" 7 | "log" 8 | "time" 9 | 10 | "google.golang.org/grpc" 11 | "google.golang.org/grpc/codes" 12 | "google.golang.org/grpc/credentials" 13 | "google.golang.org/grpc/status" 14 | 15 | "github.com/minhtran241/grpc-go/greet/greetpb" 16 | ) 17 | 18 | func main() { 19 | fmt.Println("Client is running...") 20 | 21 | tls := true // use tls for security or not 22 | opts := grpc.WithInsecure() 23 | 24 | if tls { 25 | certFile := "ssl/ca.crt" // Certificate Authority Trust certificate 26 | creds, sslErr := credentials.NewClientTLSFromFile(certFile, "") 27 | 28 | if sslErr != nil { 29 | log.Fatalf("Error while loading CA trust certificate: %v", sslErr) 30 | return 31 | } 32 | 33 | opts = grpc.WithTransportCredentials(creds) 34 | } 35 | 36 | cc, err := grpc.Dial("localhost:50051", opts) 37 | 38 | if err != nil { 39 | log.Fatalf("Could not connect: %v", err) 40 | } 41 | 42 | defer cc.Close() 43 | 44 | c := greetpb.NewGreetServiceClient(cc) 45 | 46 | doUnary(c) 47 | 48 | // doServerStreaming(c) 49 | 50 | // doClientStreaming(c) 51 | 52 | // doBiDiStreaming(c) 53 | 54 | // doUnaryWithDeadline(c, 5*time.Second) // should complete 55 | // doUnaryWithDeadline(c, 1*time.Second) // should timeout 56 | } 57 | 58 | func doUnaryWithDeadline(c greetpb.GreetServiceClient, timeout time.Duration) { 59 | fmt.Println("Starting to do UnaryWithDeadline RPC...") 60 | 61 | req := &greetpb.GreetWithDeadlineRequest{ 62 | Greeting: &greetpb.Greeting{ 63 | FirstName: "Minh", 64 | LastName: "Tran", 65 | }, 66 | } 67 | 68 | ctx, cancel := context.WithTimeout(context.Background(), timeout) 69 | defer cancel() 70 | 71 | res, err := c.GreetWithDeadline(ctx, req) 72 | 73 | if err != nil { 74 | statusErr, ok := status.FromError(err) 75 | if ok { 76 | if statusErr.Code() == codes.DeadlineExceeded { 77 | fmt.Println("Timeout was hit! Deadline was exceeded") 78 | } else { 79 | fmt.Printf("Unexpected error: %v\n", statusErr) 80 | } 81 | } 82 | log.Fatalf("(error while calling GreetWithDeadline RPC) %v\n", err) 83 | return 84 | } 85 | log.Printf("Response from GreetWithDeadline: %v\n", res) 86 | } 87 | 88 | func doBiDiStreaming(c greetpb.GreetServiceClient) { 89 | fmt.Println("Starting to do BiDi Streaming RPC...") 90 | 91 | // we create a stream by invoking the client 92 | stream, err := c.GreetEveryone(context.Background()) 93 | 94 | if err != nil { 95 | log.Fatalf("Error while creating stream: %v", err) 96 | return 97 | } 98 | 99 | requests := []*greetpb.GreetEveryoneRequest{ 100 | { 101 | Greeting: &greetpb.Greeting{ 102 | FirstName: "Minh", 103 | LastName: "Tran", 104 | }, 105 | }, 106 | { 107 | Greeting: &greetpb.Greeting{ 108 | FirstName: "Minh", 109 | LastName: "Tran", 110 | }, 111 | }, 112 | { 113 | Greeting: &greetpb.Greeting{ 114 | FirstName: "Minh", 115 | LastName: "Tran", 116 | }, 117 | }, 118 | { 119 | Greeting: &greetpb.Greeting{ 120 | FirstName: "Minh", 121 | LastName: "Tran", 122 | }, 123 | }, 124 | { 125 | Greeting: &greetpb.Greeting{ 126 | FirstName: "Minh", 127 | LastName: "Tran", 128 | }, 129 | }, 130 | } 131 | 132 | waitc := make(chan struct{}) 133 | 134 | // we send a bunch of messages to the server (go routine) 135 | go func() { 136 | // function to send a bunch of messages to the server 137 | for i, req := range requests { 138 | fmt.Printf("Sending message number %d: %v\n", i, req) 139 | err := stream.Send(req) 140 | if err != nil { 141 | log.Fatalf("Error sending request number: %d", i) 142 | } 143 | 144 | time.Sleep(time.Second * 1) 145 | } 146 | stream.CloseSend() 147 | }() 148 | 149 | // we receive a bunch of messages from the server (go routine) 150 | go func() { 151 | // function to receive a bunch of messages to the server 152 | 153 | for { 154 | res, err := stream.Recv() 155 | 156 | if err == io.EOF { 157 | break 158 | } 159 | 160 | if err != nil { 161 | log.Fatalf("Error while receiving: %v", err) 162 | break 163 | } 164 | 165 | fmt.Printf("Received: %v\n", res.GetResult()) 166 | } 167 | close(waitc) 168 | }() 169 | 170 | // block until everything is done 171 | <-waitc 172 | } 173 | 174 | func doClientStreaming(c greetpb.GreetServiceClient) { 175 | fmt.Println("Starting to do Client Streaming RPC...") 176 | 177 | requests := []*greetpb.LongGreetRequest{ 178 | { 179 | Greeting: &greetpb.Greeting{ 180 | FirstName: "Minh", 181 | LastName: "Tran", 182 | }, 183 | }, 184 | { 185 | Greeting: &greetpb.Greeting{ 186 | FirstName: "Minh", 187 | LastName: "Tran", 188 | }, 189 | }, 190 | { 191 | Greeting: &greetpb.Greeting{ 192 | FirstName: "Minh", 193 | LastName: "Tran", 194 | }, 195 | }, 196 | { 197 | Greeting: &greetpb.Greeting{ 198 | FirstName: "Minh", 199 | LastName: "Tran", 200 | }, 201 | }, 202 | { 203 | Greeting: &greetpb.Greeting{ 204 | FirstName: "Minh", 205 | LastName: "Tran", 206 | }, 207 | }, 208 | } 209 | 210 | stream, err := c.LongGreet(context.Background()) 211 | 212 | if err != nil { 213 | log.Fatalf("error while calling LongGreet: %v", err) 214 | } 215 | 216 | // we iterate over out slice and send each message individually 217 | for _, req := range requests { 218 | fmt.Printf("Sending req: %v\n", req) 219 | stream.Send(req) 220 | time.Sleep(time.Second * 1) 221 | } 222 | 223 | res, err := stream.CloseAndRecv() 224 | 225 | if err != nil { 226 | log.Fatalf("error while receiving response from LongGreet: %v", err) 227 | } 228 | 229 | fmt.Printf("LongGreet Response: %v\n", res) 230 | } 231 | 232 | func doServerStreaming(c greetpb.GreetServiceClient) { 233 | fmt.Println("Starting to do Server Streaming RPC...") 234 | 235 | req := &greetpb.GreetManyTimesRequest{ 236 | Greeting: &greetpb.Greeting{ 237 | FirstName: "Minh", 238 | LastName: "Tran", 239 | }, 240 | } 241 | 242 | streamRes, err := c.GreetManyTimes(context.Background(), req) 243 | 244 | if err != nil { 245 | log.Fatalf("error while calling GreetManyTimes RPC: %v", err) 246 | } 247 | 248 | for { 249 | msg, err := streamRes.Recv() 250 | 251 | if err == io.EOF { 252 | // we've reached the end of the stream 253 | break 254 | } 255 | if err != nil { 256 | log.Fatalf("error while calling GreetManyTimes RPC: %v", err) 257 | } 258 | log.Printf("Response from GreetManyTimes: %v", msg.GetResult()) 259 | } 260 | 261 | } 262 | 263 | func doUnary(c greetpb.GreetServiceClient) { 264 | fmt.Println("Starting to do Unary RPC...") 265 | 266 | req := &greetpb.GreetRequest{ 267 | Greeting: &greetpb.Greeting{ 268 | FirstName: "Minh", 269 | LastName: "Tran", 270 | }, 271 | } 272 | 273 | res, err := c.Greet(context.Background(), req) 274 | 275 | if err != nil { 276 | log.Fatalf("error while calling Greet RPC: %v", err) 277 | } 278 | log.Printf("Response from Greet: %v", res.Result) 279 | } 280 | -------------------------------------------------------------------------------- /greet/greet_server/server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "io" 7 | "log" 8 | "net" 9 | "strconv" 10 | "time" 11 | 12 | "google.golang.org/grpc" 13 | "google.golang.org/grpc/codes" 14 | "google.golang.org/grpc/credentials" 15 | "google.golang.org/grpc/reflection" 16 | "google.golang.org/grpc/status" 17 | 18 | "github.com/minhtran241/grpc-go/greet/greetpb" 19 | ) 20 | 21 | type server struct{} 22 | 23 | func (*server) Greet(ctx context.Context, in *greetpb.GreetRequest) (*greetpb.GreetResponse, error) { 24 | fmt.Printf("Greet function was invoked with %v\n", in) 25 | 26 | firstName := in.GetGreeting().GetFirstName() 27 | lastName := in.GetGreeting().GetLastName() 28 | 29 | result := "Hello " + firstName + " " + lastName 30 | 31 | res := &greetpb.GreetResponse{ 32 | Result: result, 33 | } 34 | 35 | return res, nil 36 | } 37 | 38 | func (*server) GreetManyTimes(in *greetpb.GreetManyTimesRequest, stream greetpb.GreetService_GreetManyTimesServer) error { 39 | fmt.Printf("GreetManyTimes function was invoked with %v\n", in) 40 | 41 | firstName := in.GetGreeting().GetFirstName() 42 | lastName := in.GetGreeting().GetLastName() 43 | 44 | for i := 0; i < 10; i++ { 45 | result := "Hello " + firstName + " " + lastName + " number " + strconv.Itoa(i) 46 | res := &greetpb.GreetManyTimesResponse{ 47 | Result: result, 48 | } 49 | stream.Send(res) 50 | time.Sleep(time.Second * 1) 51 | } 52 | 53 | return nil 54 | } 55 | 56 | func (*server) LongGreet(stream greetpb.GreetService_LongGreetServer) error { 57 | fmt.Println("LongGreet function was invoked as a streaming request") 58 | 59 | result := "Hello " 60 | 61 | for { 62 | req, err := stream.Recv() 63 | 64 | if err == io.EOF { 65 | // we've finished reading the client stream 66 | return stream.SendAndClose(&greetpb.LongGreetResponse{ 67 | Result: result, 68 | }) 69 | } 70 | if err != nil { 71 | log.Fatalf("Error while reading client stream: %v", err) 72 | } 73 | 74 | firstName := req.GetGreeting().GetFirstName() 75 | lastName := req.GetGreeting().GetLastName() 76 | 77 | result += firstName + " " + lastName + "! " 78 | } 79 | } 80 | 81 | func (*server) GreetEveryone(stream greetpb.GreetService_GreetEveryoneServer) error { 82 | fmt.Println("GreetEveryone function was invoked as a streaming request") 83 | 84 | for { 85 | 86 | req, err := stream.Recv() 87 | 88 | if err == io.EOF { 89 | return nil 90 | } 91 | 92 | if err != nil { 93 | log.Fatalf("Error while reading client stream: %v", err) 94 | return err 95 | } 96 | 97 | firstName := req.GetGreeting().GetFirstName() 98 | lastName := req.GetGreeting().GetLastName() 99 | 100 | result := "Hello " + firstName + " " + lastName + "! " 101 | sendErr := stream.Send(&greetpb.GreetEveryoneResponse{ 102 | Result: result, 103 | }) 104 | 105 | if sendErr != nil { 106 | log.Fatalf("Error while sending data to client: %v", sendErr) 107 | return sendErr 108 | } 109 | } 110 | } 111 | 112 | func (*server) GreetWithDeadline(ctx context.Context, in *greetpb.GreetWithDeadlineRequest) (*greetpb.GreetWithDeadlineResponse, error) { 113 | fmt.Printf("GreetWithDeadline function was invoked with %v\n", in) 114 | 115 | for i := 0; i < 3; i++ { 116 | if ctx.Err() == context.Canceled { 117 | fmt.Println("The client cancelled the request!") 118 | return nil, status.Error(codes.Canceled, "the client cancelled the request") 119 | } 120 | time.Sleep(time.Second * 1) 121 | } 122 | 123 | firstName := in.GetGreeting().GetFirstName() 124 | lastName := in.GetGreeting().GetLastName() 125 | 126 | result := "Hello " + firstName + " " + lastName 127 | 128 | res := &greetpb.GreetWithDeadlineResponse{ 129 | Result: result, 130 | } 131 | 132 | return res, nil 133 | } 134 | 135 | func main() { 136 | fmt.Println("Server is running...") 137 | 138 | lis, err := net.Listen("tcp", "localhost:50051") // port binding 139 | 140 | if err != nil { 141 | log.Fatalf("Failed to listen: %v", err) 142 | } 143 | 144 | tls := true // use tls for security or not 145 | opts := []grpc.ServerOption{} 146 | 147 | if tls { 148 | certFile := "ssl/server.crt" 149 | keyFile := "ssl/server.pem" 150 | creds, sslErr := credentials.NewServerTLSFromFile(certFile, keyFile) 151 | if sslErr != nil { 152 | log.Fatalf("Failed loading certificates: %v", sslErr) 153 | return 154 | } 155 | opts = append(opts, grpc.Creds(creds)) 156 | } 157 | 158 | s := grpc.NewServer(opts...) // grpc server 159 | greetpb.RegisterGreetServiceServer(s, &server{}) // register greet service 160 | 161 | // Register reflection service on gRPC server. 162 | reflection.Register(s) 163 | 164 | if err := s.Serve(lis); err != nil { // bind the port to the grpc server 165 | log.Fatalf("Failed to serve: %v", err) 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /greet/greetpb/greet.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.28.1 4 | // protoc v3.21.7 5 | // source: greet/greetpb/greet.proto 6 | 7 | package greetpb 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type Greeting struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | FirstName string `protobuf:"bytes,1,opt,name=first_name,json=firstName,proto3" json:"first_name,omitempty"` 29 | LastName string `protobuf:"bytes,2,opt,name=last_name,json=lastName,proto3" json:"last_name,omitempty"` 30 | } 31 | 32 | func (x *Greeting) Reset() { 33 | *x = Greeting{} 34 | if protoimpl.UnsafeEnabled { 35 | mi := &file_greet_greetpb_greet_proto_msgTypes[0] 36 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 37 | ms.StoreMessageInfo(mi) 38 | } 39 | } 40 | 41 | func (x *Greeting) String() string { 42 | return protoimpl.X.MessageStringOf(x) 43 | } 44 | 45 | func (*Greeting) ProtoMessage() {} 46 | 47 | func (x *Greeting) ProtoReflect() protoreflect.Message { 48 | mi := &file_greet_greetpb_greet_proto_msgTypes[0] 49 | if protoimpl.UnsafeEnabled && x != nil { 50 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 51 | if ms.LoadMessageInfo() == nil { 52 | ms.StoreMessageInfo(mi) 53 | } 54 | return ms 55 | } 56 | return mi.MessageOf(x) 57 | } 58 | 59 | // Deprecated: Use Greeting.ProtoReflect.Descriptor instead. 60 | func (*Greeting) Descriptor() ([]byte, []int) { 61 | return file_greet_greetpb_greet_proto_rawDescGZIP(), []int{0} 62 | } 63 | 64 | func (x *Greeting) GetFirstName() string { 65 | if x != nil { 66 | return x.FirstName 67 | } 68 | return "" 69 | } 70 | 71 | func (x *Greeting) GetLastName() string { 72 | if x != nil { 73 | return x.LastName 74 | } 75 | return "" 76 | } 77 | 78 | type GreetRequest struct { 79 | state protoimpl.MessageState 80 | sizeCache protoimpl.SizeCache 81 | unknownFields protoimpl.UnknownFields 82 | 83 | Greeting *Greeting `protobuf:"bytes,1,opt,name=greeting,proto3" json:"greeting,omitempty"` 84 | } 85 | 86 | func (x *GreetRequest) Reset() { 87 | *x = GreetRequest{} 88 | if protoimpl.UnsafeEnabled { 89 | mi := &file_greet_greetpb_greet_proto_msgTypes[1] 90 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 91 | ms.StoreMessageInfo(mi) 92 | } 93 | } 94 | 95 | func (x *GreetRequest) String() string { 96 | return protoimpl.X.MessageStringOf(x) 97 | } 98 | 99 | func (*GreetRequest) ProtoMessage() {} 100 | 101 | func (x *GreetRequest) ProtoReflect() protoreflect.Message { 102 | mi := &file_greet_greetpb_greet_proto_msgTypes[1] 103 | if protoimpl.UnsafeEnabled && x != nil { 104 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 105 | if ms.LoadMessageInfo() == nil { 106 | ms.StoreMessageInfo(mi) 107 | } 108 | return ms 109 | } 110 | return mi.MessageOf(x) 111 | } 112 | 113 | // Deprecated: Use GreetRequest.ProtoReflect.Descriptor instead. 114 | func (*GreetRequest) Descriptor() ([]byte, []int) { 115 | return file_greet_greetpb_greet_proto_rawDescGZIP(), []int{1} 116 | } 117 | 118 | func (x *GreetRequest) GetGreeting() *Greeting { 119 | if x != nil { 120 | return x.Greeting 121 | } 122 | return nil 123 | } 124 | 125 | type GreetResponse struct { 126 | state protoimpl.MessageState 127 | sizeCache protoimpl.SizeCache 128 | unknownFields protoimpl.UnknownFields 129 | 130 | Result string `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` 131 | } 132 | 133 | func (x *GreetResponse) Reset() { 134 | *x = GreetResponse{} 135 | if protoimpl.UnsafeEnabled { 136 | mi := &file_greet_greetpb_greet_proto_msgTypes[2] 137 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 138 | ms.StoreMessageInfo(mi) 139 | } 140 | } 141 | 142 | func (x *GreetResponse) String() string { 143 | return protoimpl.X.MessageStringOf(x) 144 | } 145 | 146 | func (*GreetResponse) ProtoMessage() {} 147 | 148 | func (x *GreetResponse) ProtoReflect() protoreflect.Message { 149 | mi := &file_greet_greetpb_greet_proto_msgTypes[2] 150 | if protoimpl.UnsafeEnabled && x != nil { 151 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 152 | if ms.LoadMessageInfo() == nil { 153 | ms.StoreMessageInfo(mi) 154 | } 155 | return ms 156 | } 157 | return mi.MessageOf(x) 158 | } 159 | 160 | // Deprecated: Use GreetResponse.ProtoReflect.Descriptor instead. 161 | func (*GreetResponse) Descriptor() ([]byte, []int) { 162 | return file_greet_greetpb_greet_proto_rawDescGZIP(), []int{2} 163 | } 164 | 165 | func (x *GreetResponse) GetResult() string { 166 | if x != nil { 167 | return x.Result 168 | } 169 | return "" 170 | } 171 | 172 | type GreetManyTimesRequest struct { 173 | state protoimpl.MessageState 174 | sizeCache protoimpl.SizeCache 175 | unknownFields protoimpl.UnknownFields 176 | 177 | Greeting *Greeting `protobuf:"bytes,1,opt,name=greeting,proto3" json:"greeting,omitempty"` 178 | } 179 | 180 | func (x *GreetManyTimesRequest) Reset() { 181 | *x = GreetManyTimesRequest{} 182 | if protoimpl.UnsafeEnabled { 183 | mi := &file_greet_greetpb_greet_proto_msgTypes[3] 184 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 185 | ms.StoreMessageInfo(mi) 186 | } 187 | } 188 | 189 | func (x *GreetManyTimesRequest) String() string { 190 | return protoimpl.X.MessageStringOf(x) 191 | } 192 | 193 | func (*GreetManyTimesRequest) ProtoMessage() {} 194 | 195 | func (x *GreetManyTimesRequest) ProtoReflect() protoreflect.Message { 196 | mi := &file_greet_greetpb_greet_proto_msgTypes[3] 197 | if protoimpl.UnsafeEnabled && x != nil { 198 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 199 | if ms.LoadMessageInfo() == nil { 200 | ms.StoreMessageInfo(mi) 201 | } 202 | return ms 203 | } 204 | return mi.MessageOf(x) 205 | } 206 | 207 | // Deprecated: Use GreetManyTimesRequest.ProtoReflect.Descriptor instead. 208 | func (*GreetManyTimesRequest) Descriptor() ([]byte, []int) { 209 | return file_greet_greetpb_greet_proto_rawDescGZIP(), []int{3} 210 | } 211 | 212 | func (x *GreetManyTimesRequest) GetGreeting() *Greeting { 213 | if x != nil { 214 | return x.Greeting 215 | } 216 | return nil 217 | } 218 | 219 | type GreetManyTimesResponse struct { 220 | state protoimpl.MessageState 221 | sizeCache protoimpl.SizeCache 222 | unknownFields protoimpl.UnknownFields 223 | 224 | Result string `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` 225 | } 226 | 227 | func (x *GreetManyTimesResponse) Reset() { 228 | *x = GreetManyTimesResponse{} 229 | if protoimpl.UnsafeEnabled { 230 | mi := &file_greet_greetpb_greet_proto_msgTypes[4] 231 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 232 | ms.StoreMessageInfo(mi) 233 | } 234 | } 235 | 236 | func (x *GreetManyTimesResponse) String() string { 237 | return protoimpl.X.MessageStringOf(x) 238 | } 239 | 240 | func (*GreetManyTimesResponse) ProtoMessage() {} 241 | 242 | func (x *GreetManyTimesResponse) ProtoReflect() protoreflect.Message { 243 | mi := &file_greet_greetpb_greet_proto_msgTypes[4] 244 | if protoimpl.UnsafeEnabled && x != nil { 245 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 246 | if ms.LoadMessageInfo() == nil { 247 | ms.StoreMessageInfo(mi) 248 | } 249 | return ms 250 | } 251 | return mi.MessageOf(x) 252 | } 253 | 254 | // Deprecated: Use GreetManyTimesResponse.ProtoReflect.Descriptor instead. 255 | func (*GreetManyTimesResponse) Descriptor() ([]byte, []int) { 256 | return file_greet_greetpb_greet_proto_rawDescGZIP(), []int{4} 257 | } 258 | 259 | func (x *GreetManyTimesResponse) GetResult() string { 260 | if x != nil { 261 | return x.Result 262 | } 263 | return "" 264 | } 265 | 266 | type LongGreetRequest struct { 267 | state protoimpl.MessageState 268 | sizeCache protoimpl.SizeCache 269 | unknownFields protoimpl.UnknownFields 270 | 271 | Greeting *Greeting `protobuf:"bytes,1,opt,name=greeting,proto3" json:"greeting,omitempty"` 272 | } 273 | 274 | func (x *LongGreetRequest) Reset() { 275 | *x = LongGreetRequest{} 276 | if protoimpl.UnsafeEnabled { 277 | mi := &file_greet_greetpb_greet_proto_msgTypes[5] 278 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 279 | ms.StoreMessageInfo(mi) 280 | } 281 | } 282 | 283 | func (x *LongGreetRequest) String() string { 284 | return protoimpl.X.MessageStringOf(x) 285 | } 286 | 287 | func (*LongGreetRequest) ProtoMessage() {} 288 | 289 | func (x *LongGreetRequest) ProtoReflect() protoreflect.Message { 290 | mi := &file_greet_greetpb_greet_proto_msgTypes[5] 291 | if protoimpl.UnsafeEnabled && x != nil { 292 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 293 | if ms.LoadMessageInfo() == nil { 294 | ms.StoreMessageInfo(mi) 295 | } 296 | return ms 297 | } 298 | return mi.MessageOf(x) 299 | } 300 | 301 | // Deprecated: Use LongGreetRequest.ProtoReflect.Descriptor instead. 302 | func (*LongGreetRequest) Descriptor() ([]byte, []int) { 303 | return file_greet_greetpb_greet_proto_rawDescGZIP(), []int{5} 304 | } 305 | 306 | func (x *LongGreetRequest) GetGreeting() *Greeting { 307 | if x != nil { 308 | return x.Greeting 309 | } 310 | return nil 311 | } 312 | 313 | type LongGreetResponse struct { 314 | state protoimpl.MessageState 315 | sizeCache protoimpl.SizeCache 316 | unknownFields protoimpl.UnknownFields 317 | 318 | Result string `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` 319 | } 320 | 321 | func (x *LongGreetResponse) Reset() { 322 | *x = LongGreetResponse{} 323 | if protoimpl.UnsafeEnabled { 324 | mi := &file_greet_greetpb_greet_proto_msgTypes[6] 325 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 326 | ms.StoreMessageInfo(mi) 327 | } 328 | } 329 | 330 | func (x *LongGreetResponse) String() string { 331 | return protoimpl.X.MessageStringOf(x) 332 | } 333 | 334 | func (*LongGreetResponse) ProtoMessage() {} 335 | 336 | func (x *LongGreetResponse) ProtoReflect() protoreflect.Message { 337 | mi := &file_greet_greetpb_greet_proto_msgTypes[6] 338 | if protoimpl.UnsafeEnabled && x != nil { 339 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 340 | if ms.LoadMessageInfo() == nil { 341 | ms.StoreMessageInfo(mi) 342 | } 343 | return ms 344 | } 345 | return mi.MessageOf(x) 346 | } 347 | 348 | // Deprecated: Use LongGreetResponse.ProtoReflect.Descriptor instead. 349 | func (*LongGreetResponse) Descriptor() ([]byte, []int) { 350 | return file_greet_greetpb_greet_proto_rawDescGZIP(), []int{6} 351 | } 352 | 353 | func (x *LongGreetResponse) GetResult() string { 354 | if x != nil { 355 | return x.Result 356 | } 357 | return "" 358 | } 359 | 360 | type GreetEveryoneRequest struct { 361 | state protoimpl.MessageState 362 | sizeCache protoimpl.SizeCache 363 | unknownFields protoimpl.UnknownFields 364 | 365 | Greeting *Greeting `protobuf:"bytes,1,opt,name=greeting,proto3" json:"greeting,omitempty"` 366 | } 367 | 368 | func (x *GreetEveryoneRequest) Reset() { 369 | *x = GreetEveryoneRequest{} 370 | if protoimpl.UnsafeEnabled { 371 | mi := &file_greet_greetpb_greet_proto_msgTypes[7] 372 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 373 | ms.StoreMessageInfo(mi) 374 | } 375 | } 376 | 377 | func (x *GreetEveryoneRequest) String() string { 378 | return protoimpl.X.MessageStringOf(x) 379 | } 380 | 381 | func (*GreetEveryoneRequest) ProtoMessage() {} 382 | 383 | func (x *GreetEveryoneRequest) ProtoReflect() protoreflect.Message { 384 | mi := &file_greet_greetpb_greet_proto_msgTypes[7] 385 | if protoimpl.UnsafeEnabled && x != nil { 386 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 387 | if ms.LoadMessageInfo() == nil { 388 | ms.StoreMessageInfo(mi) 389 | } 390 | return ms 391 | } 392 | return mi.MessageOf(x) 393 | } 394 | 395 | // Deprecated: Use GreetEveryoneRequest.ProtoReflect.Descriptor instead. 396 | func (*GreetEveryoneRequest) Descriptor() ([]byte, []int) { 397 | return file_greet_greetpb_greet_proto_rawDescGZIP(), []int{7} 398 | } 399 | 400 | func (x *GreetEveryoneRequest) GetGreeting() *Greeting { 401 | if x != nil { 402 | return x.Greeting 403 | } 404 | return nil 405 | } 406 | 407 | type GreetEveryoneResponse struct { 408 | state protoimpl.MessageState 409 | sizeCache protoimpl.SizeCache 410 | unknownFields protoimpl.UnknownFields 411 | 412 | Result string `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` 413 | } 414 | 415 | func (x *GreetEveryoneResponse) Reset() { 416 | *x = GreetEveryoneResponse{} 417 | if protoimpl.UnsafeEnabled { 418 | mi := &file_greet_greetpb_greet_proto_msgTypes[8] 419 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 420 | ms.StoreMessageInfo(mi) 421 | } 422 | } 423 | 424 | func (x *GreetEveryoneResponse) String() string { 425 | return protoimpl.X.MessageStringOf(x) 426 | } 427 | 428 | func (*GreetEveryoneResponse) ProtoMessage() {} 429 | 430 | func (x *GreetEveryoneResponse) ProtoReflect() protoreflect.Message { 431 | mi := &file_greet_greetpb_greet_proto_msgTypes[8] 432 | if protoimpl.UnsafeEnabled && x != nil { 433 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 434 | if ms.LoadMessageInfo() == nil { 435 | ms.StoreMessageInfo(mi) 436 | } 437 | return ms 438 | } 439 | return mi.MessageOf(x) 440 | } 441 | 442 | // Deprecated: Use GreetEveryoneResponse.ProtoReflect.Descriptor instead. 443 | func (*GreetEveryoneResponse) Descriptor() ([]byte, []int) { 444 | return file_greet_greetpb_greet_proto_rawDescGZIP(), []int{8} 445 | } 446 | 447 | func (x *GreetEveryoneResponse) GetResult() string { 448 | if x != nil { 449 | return x.Result 450 | } 451 | return "" 452 | } 453 | 454 | type GreetWithDeadlineRequest struct { 455 | state protoimpl.MessageState 456 | sizeCache protoimpl.SizeCache 457 | unknownFields protoimpl.UnknownFields 458 | 459 | Greeting *Greeting `protobuf:"bytes,1,opt,name=greeting,proto3" json:"greeting,omitempty"` 460 | } 461 | 462 | func (x *GreetWithDeadlineRequest) Reset() { 463 | *x = GreetWithDeadlineRequest{} 464 | if protoimpl.UnsafeEnabled { 465 | mi := &file_greet_greetpb_greet_proto_msgTypes[9] 466 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 467 | ms.StoreMessageInfo(mi) 468 | } 469 | } 470 | 471 | func (x *GreetWithDeadlineRequest) String() string { 472 | return protoimpl.X.MessageStringOf(x) 473 | } 474 | 475 | func (*GreetWithDeadlineRequest) ProtoMessage() {} 476 | 477 | func (x *GreetWithDeadlineRequest) ProtoReflect() protoreflect.Message { 478 | mi := &file_greet_greetpb_greet_proto_msgTypes[9] 479 | if protoimpl.UnsafeEnabled && x != nil { 480 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 481 | if ms.LoadMessageInfo() == nil { 482 | ms.StoreMessageInfo(mi) 483 | } 484 | return ms 485 | } 486 | return mi.MessageOf(x) 487 | } 488 | 489 | // Deprecated: Use GreetWithDeadlineRequest.ProtoReflect.Descriptor instead. 490 | func (*GreetWithDeadlineRequest) Descriptor() ([]byte, []int) { 491 | return file_greet_greetpb_greet_proto_rawDescGZIP(), []int{9} 492 | } 493 | 494 | func (x *GreetWithDeadlineRequest) GetGreeting() *Greeting { 495 | if x != nil { 496 | return x.Greeting 497 | } 498 | return nil 499 | } 500 | 501 | type GreetWithDeadlineResponse struct { 502 | state protoimpl.MessageState 503 | sizeCache protoimpl.SizeCache 504 | unknownFields protoimpl.UnknownFields 505 | 506 | Result string `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` 507 | } 508 | 509 | func (x *GreetWithDeadlineResponse) Reset() { 510 | *x = GreetWithDeadlineResponse{} 511 | if protoimpl.UnsafeEnabled { 512 | mi := &file_greet_greetpb_greet_proto_msgTypes[10] 513 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 514 | ms.StoreMessageInfo(mi) 515 | } 516 | } 517 | 518 | func (x *GreetWithDeadlineResponse) String() string { 519 | return protoimpl.X.MessageStringOf(x) 520 | } 521 | 522 | func (*GreetWithDeadlineResponse) ProtoMessage() {} 523 | 524 | func (x *GreetWithDeadlineResponse) ProtoReflect() protoreflect.Message { 525 | mi := &file_greet_greetpb_greet_proto_msgTypes[10] 526 | if protoimpl.UnsafeEnabled && x != nil { 527 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 528 | if ms.LoadMessageInfo() == nil { 529 | ms.StoreMessageInfo(mi) 530 | } 531 | return ms 532 | } 533 | return mi.MessageOf(x) 534 | } 535 | 536 | // Deprecated: Use GreetWithDeadlineResponse.ProtoReflect.Descriptor instead. 537 | func (*GreetWithDeadlineResponse) Descriptor() ([]byte, []int) { 538 | return file_greet_greetpb_greet_proto_rawDescGZIP(), []int{10} 539 | } 540 | 541 | func (x *GreetWithDeadlineResponse) GetResult() string { 542 | if x != nil { 543 | return x.Result 544 | } 545 | return "" 546 | } 547 | 548 | var File_greet_greetpb_greet_proto protoreflect.FileDescriptor 549 | 550 | var file_greet_greetpb_greet_proto_rawDesc = []byte{ 551 | 0x0a, 0x19, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2f, 0x67, 0x72, 0x65, 0x65, 0x74, 0x70, 0x62, 0x2f, 552 | 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x67, 0x72, 0x65, 553 | 0x65, 0x74, 0x22, 0x46, 0x0a, 0x08, 0x47, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x1d, 554 | 0x0a, 0x0a, 0x66, 0x69, 0x72, 0x73, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 555 | 0x28, 0x09, 0x52, 0x09, 0x66, 0x69, 0x72, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 556 | 0x09, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 557 | 0x52, 0x08, 0x6c, 0x61, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x3b, 0x0a, 0x0c, 0x47, 0x72, 558 | 0x65, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2b, 0x0a, 0x08, 0x67, 0x72, 559 | 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x67, 560 | 0x72, 0x65, 0x65, 0x74, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x67, 561 | 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x22, 0x27, 0x0a, 0x0d, 0x47, 0x72, 0x65, 0x65, 0x74, 562 | 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 563 | 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 564 | 0x22, 0x44, 0x0a, 0x15, 0x47, 0x72, 0x65, 0x65, 0x74, 0x4d, 0x61, 0x6e, 0x79, 0x54, 0x69, 0x6d, 565 | 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2b, 0x0a, 0x08, 0x67, 0x72, 0x65, 566 | 0x65, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x67, 0x72, 567 | 0x65, 0x65, 0x74, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x67, 0x72, 568 | 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x22, 0x30, 0x0a, 0x16, 0x47, 0x72, 0x65, 0x65, 0x74, 0x4d, 569 | 0x61, 0x6e, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 570 | 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 571 | 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x3f, 0x0a, 0x10, 0x4c, 0x6f, 0x6e, 0x67, 572 | 0x47, 0x72, 0x65, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2b, 0x0a, 0x08, 573 | 0x67, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 574 | 0x2e, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 575 | 0x08, 0x67, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x22, 0x2b, 0x0a, 0x11, 0x4c, 0x6f, 0x6e, 576 | 0x67, 0x47, 0x72, 0x65, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 577 | 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 578 | 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x43, 0x0a, 0x14, 0x47, 0x72, 0x65, 0x65, 0x74, 0x45, 579 | 0x76, 0x65, 0x72, 0x79, 0x6f, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2b, 580 | 0x0a, 0x08, 0x67, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 581 | 0x32, 0x0f, 0x2e, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, 582 | 0x67, 0x52, 0x08, 0x67, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x22, 0x2f, 0x0a, 0x15, 0x47, 583 | 0x72, 0x65, 0x65, 0x74, 0x45, 0x76, 0x65, 0x72, 0x79, 0x6f, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 584 | 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 585 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x47, 0x0a, 0x18, 586 | 0x47, 0x72, 0x65, 0x65, 0x74, 0x57, 0x69, 0x74, 0x68, 0x44, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 587 | 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2b, 0x0a, 0x08, 0x67, 0x72, 0x65, 0x65, 588 | 0x74, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x67, 0x72, 0x65, 589 | 0x65, 0x74, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x67, 0x72, 0x65, 590 | 0x65, 0x74, 0x69, 0x6e, 0x67, 0x22, 0x33, 0x0a, 0x19, 0x47, 0x72, 0x65, 0x65, 0x74, 0x57, 0x69, 591 | 0x74, 0x68, 0x44, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 592 | 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 593 | 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x32, 0x87, 0x03, 0x0a, 0x0c, 0x47, 594 | 0x72, 0x65, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x34, 0x0a, 0x05, 0x47, 595 | 0x72, 0x65, 0x65, 0x74, 0x12, 0x13, 0x2e, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x47, 0x72, 0x65, 596 | 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x67, 0x72, 0x65, 0x65, 597 | 0x74, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 598 | 0x00, 0x12, 0x51, 0x0a, 0x0e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x4d, 0x61, 0x6e, 0x79, 0x54, 0x69, 599 | 0x6d, 0x65, 0x73, 0x12, 0x1c, 0x2e, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x47, 0x72, 0x65, 0x65, 600 | 0x74, 0x4d, 0x61, 0x6e, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 601 | 0x74, 0x1a, 0x1d, 0x2e, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x4d, 602 | 0x61, 0x6e, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 603 | 0x22, 0x00, 0x30, 0x01, 0x12, 0x42, 0x0a, 0x09, 0x4c, 0x6f, 0x6e, 0x67, 0x47, 0x72, 0x65, 0x65, 604 | 0x74, 0x12, 0x17, 0x2e, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x4c, 0x6f, 0x6e, 0x67, 0x47, 0x72, 605 | 0x65, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x67, 0x72, 0x65, 606 | 0x65, 0x74, 0x2e, 0x4c, 0x6f, 0x6e, 0x67, 0x47, 0x72, 0x65, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 607 | 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x50, 0x0a, 0x0d, 0x47, 0x72, 0x65, 0x65, 608 | 0x74, 0x45, 0x76, 0x65, 0x72, 0x79, 0x6f, 0x6e, 0x65, 0x12, 0x1b, 0x2e, 0x67, 0x72, 0x65, 0x65, 609 | 0x74, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x45, 0x76, 0x65, 0x72, 0x79, 0x6f, 0x6e, 0x65, 0x52, 610 | 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x47, 611 | 0x72, 0x65, 0x65, 0x74, 0x45, 0x76, 0x65, 0x72, 0x79, 0x6f, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 612 | 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x12, 0x58, 0x0a, 0x11, 0x47, 0x72, 613 | 0x65, 0x65, 0x74, 0x57, 0x69, 0x74, 0x68, 0x44, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x12, 614 | 0x1f, 0x2e, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x57, 0x69, 0x74, 615 | 0x68, 0x44, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 616 | 0x1a, 0x20, 0x2e, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x57, 0x69, 617 | 0x74, 0x68, 0x44, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 618 | 0x73, 0x65, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2f, 0x67, 0x72, 619 | 0x65, 0x65, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 620 | } 621 | 622 | var ( 623 | file_greet_greetpb_greet_proto_rawDescOnce sync.Once 624 | file_greet_greetpb_greet_proto_rawDescData = file_greet_greetpb_greet_proto_rawDesc 625 | ) 626 | 627 | func file_greet_greetpb_greet_proto_rawDescGZIP() []byte { 628 | file_greet_greetpb_greet_proto_rawDescOnce.Do(func() { 629 | file_greet_greetpb_greet_proto_rawDescData = protoimpl.X.CompressGZIP(file_greet_greetpb_greet_proto_rawDescData) 630 | }) 631 | return file_greet_greetpb_greet_proto_rawDescData 632 | } 633 | 634 | var file_greet_greetpb_greet_proto_msgTypes = make([]protoimpl.MessageInfo, 11) 635 | var file_greet_greetpb_greet_proto_goTypes = []interface{}{ 636 | (*Greeting)(nil), // 0: greet.Greeting 637 | (*GreetRequest)(nil), // 1: greet.GreetRequest 638 | (*GreetResponse)(nil), // 2: greet.GreetResponse 639 | (*GreetManyTimesRequest)(nil), // 3: greet.GreetManyTimesRequest 640 | (*GreetManyTimesResponse)(nil), // 4: greet.GreetManyTimesResponse 641 | (*LongGreetRequest)(nil), // 5: greet.LongGreetRequest 642 | (*LongGreetResponse)(nil), // 6: greet.LongGreetResponse 643 | (*GreetEveryoneRequest)(nil), // 7: greet.GreetEveryoneRequest 644 | (*GreetEveryoneResponse)(nil), // 8: greet.GreetEveryoneResponse 645 | (*GreetWithDeadlineRequest)(nil), // 9: greet.GreetWithDeadlineRequest 646 | (*GreetWithDeadlineResponse)(nil), // 10: greet.GreetWithDeadlineResponse 647 | } 648 | var file_greet_greetpb_greet_proto_depIdxs = []int32{ 649 | 0, // 0: greet.GreetRequest.greeting:type_name -> greet.Greeting 650 | 0, // 1: greet.GreetManyTimesRequest.greeting:type_name -> greet.Greeting 651 | 0, // 2: greet.LongGreetRequest.greeting:type_name -> greet.Greeting 652 | 0, // 3: greet.GreetEveryoneRequest.greeting:type_name -> greet.Greeting 653 | 0, // 4: greet.GreetWithDeadlineRequest.greeting:type_name -> greet.Greeting 654 | 1, // 5: greet.GreetService.Greet:input_type -> greet.GreetRequest 655 | 3, // 6: greet.GreetService.GreetManyTimes:input_type -> greet.GreetManyTimesRequest 656 | 5, // 7: greet.GreetService.LongGreet:input_type -> greet.LongGreetRequest 657 | 7, // 8: greet.GreetService.GreetEveryone:input_type -> greet.GreetEveryoneRequest 658 | 9, // 9: greet.GreetService.GreetWithDeadline:input_type -> greet.GreetWithDeadlineRequest 659 | 2, // 10: greet.GreetService.Greet:output_type -> greet.GreetResponse 660 | 4, // 11: greet.GreetService.GreetManyTimes:output_type -> greet.GreetManyTimesResponse 661 | 6, // 12: greet.GreetService.LongGreet:output_type -> greet.LongGreetResponse 662 | 8, // 13: greet.GreetService.GreetEveryone:output_type -> greet.GreetEveryoneResponse 663 | 10, // 14: greet.GreetService.GreetWithDeadline:output_type -> greet.GreetWithDeadlineResponse 664 | 10, // [10:15] is the sub-list for method output_type 665 | 5, // [5:10] is the sub-list for method input_type 666 | 5, // [5:5] is the sub-list for extension type_name 667 | 5, // [5:5] is the sub-list for extension extendee 668 | 0, // [0:5] is the sub-list for field type_name 669 | } 670 | 671 | func init() { file_greet_greetpb_greet_proto_init() } 672 | func file_greet_greetpb_greet_proto_init() { 673 | if File_greet_greetpb_greet_proto != nil { 674 | return 675 | } 676 | if !protoimpl.UnsafeEnabled { 677 | file_greet_greetpb_greet_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 678 | switch v := v.(*Greeting); i { 679 | case 0: 680 | return &v.state 681 | case 1: 682 | return &v.sizeCache 683 | case 2: 684 | return &v.unknownFields 685 | default: 686 | return nil 687 | } 688 | } 689 | file_greet_greetpb_greet_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 690 | switch v := v.(*GreetRequest); i { 691 | case 0: 692 | return &v.state 693 | case 1: 694 | return &v.sizeCache 695 | case 2: 696 | return &v.unknownFields 697 | default: 698 | return nil 699 | } 700 | } 701 | file_greet_greetpb_greet_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { 702 | switch v := v.(*GreetResponse); i { 703 | case 0: 704 | return &v.state 705 | case 1: 706 | return &v.sizeCache 707 | case 2: 708 | return &v.unknownFields 709 | default: 710 | return nil 711 | } 712 | } 713 | file_greet_greetpb_greet_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { 714 | switch v := v.(*GreetManyTimesRequest); i { 715 | case 0: 716 | return &v.state 717 | case 1: 718 | return &v.sizeCache 719 | case 2: 720 | return &v.unknownFields 721 | default: 722 | return nil 723 | } 724 | } 725 | file_greet_greetpb_greet_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { 726 | switch v := v.(*GreetManyTimesResponse); i { 727 | case 0: 728 | return &v.state 729 | case 1: 730 | return &v.sizeCache 731 | case 2: 732 | return &v.unknownFields 733 | default: 734 | return nil 735 | } 736 | } 737 | file_greet_greetpb_greet_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { 738 | switch v := v.(*LongGreetRequest); i { 739 | case 0: 740 | return &v.state 741 | case 1: 742 | return &v.sizeCache 743 | case 2: 744 | return &v.unknownFields 745 | default: 746 | return nil 747 | } 748 | } 749 | file_greet_greetpb_greet_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { 750 | switch v := v.(*LongGreetResponse); i { 751 | case 0: 752 | return &v.state 753 | case 1: 754 | return &v.sizeCache 755 | case 2: 756 | return &v.unknownFields 757 | default: 758 | return nil 759 | } 760 | } 761 | file_greet_greetpb_greet_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { 762 | switch v := v.(*GreetEveryoneRequest); i { 763 | case 0: 764 | return &v.state 765 | case 1: 766 | return &v.sizeCache 767 | case 2: 768 | return &v.unknownFields 769 | default: 770 | return nil 771 | } 772 | } 773 | file_greet_greetpb_greet_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { 774 | switch v := v.(*GreetEveryoneResponse); i { 775 | case 0: 776 | return &v.state 777 | case 1: 778 | return &v.sizeCache 779 | case 2: 780 | return &v.unknownFields 781 | default: 782 | return nil 783 | } 784 | } 785 | file_greet_greetpb_greet_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { 786 | switch v := v.(*GreetWithDeadlineRequest); i { 787 | case 0: 788 | return &v.state 789 | case 1: 790 | return &v.sizeCache 791 | case 2: 792 | return &v.unknownFields 793 | default: 794 | return nil 795 | } 796 | } 797 | file_greet_greetpb_greet_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { 798 | switch v := v.(*GreetWithDeadlineResponse); i { 799 | case 0: 800 | return &v.state 801 | case 1: 802 | return &v.sizeCache 803 | case 2: 804 | return &v.unknownFields 805 | default: 806 | return nil 807 | } 808 | } 809 | } 810 | type x struct{} 811 | out := protoimpl.TypeBuilder{ 812 | File: protoimpl.DescBuilder{ 813 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 814 | RawDescriptor: file_greet_greetpb_greet_proto_rawDesc, 815 | NumEnums: 0, 816 | NumMessages: 11, 817 | NumExtensions: 0, 818 | NumServices: 1, 819 | }, 820 | GoTypes: file_greet_greetpb_greet_proto_goTypes, 821 | DependencyIndexes: file_greet_greetpb_greet_proto_depIdxs, 822 | MessageInfos: file_greet_greetpb_greet_proto_msgTypes, 823 | }.Build() 824 | File_greet_greetpb_greet_proto = out.File 825 | file_greet_greetpb_greet_proto_rawDesc = nil 826 | file_greet_greetpb_greet_proto_goTypes = nil 827 | file_greet_greetpb_greet_proto_depIdxs = nil 828 | } 829 | -------------------------------------------------------------------------------- /greet/greetpb/greet.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package greet; 4 | option go_package="greet/greetpb"; 5 | 6 | message Greeting { 7 | string first_name = 1; 8 | string last_name = 2; 9 | } 10 | 11 | message GreetRequest { 12 | Greeting greeting = 1; 13 | } 14 | 15 | message GreetResponse { 16 | string result = 1; 17 | } 18 | 19 | message GreetManyTimesRequest { 20 | Greeting greeting = 1; 21 | } 22 | 23 | message GreetManyTimesResponse { 24 | string result = 1; 25 | } 26 | 27 | message LongGreetRequest { 28 | Greeting greeting = 1; 29 | } 30 | 31 | message LongGreetResponse { 32 | string result = 1; 33 | } 34 | 35 | message GreetEveryoneRequest { 36 | Greeting greeting = 1; 37 | } 38 | 39 | message GreetEveryoneResponse { 40 | string result = 1; 41 | } 42 | 43 | message GreetWithDeadlineRequest { 44 | Greeting greeting = 1; 45 | } 46 | 47 | message GreetWithDeadlineResponse { 48 | string result = 1; 49 | } 50 | 51 | service GreetService{ 52 | // Unary 53 | rpc Greet(GreetRequest) returns (GreetResponse) {}; 54 | 55 | // Server Streaming 56 | rpc GreetManyTimes(GreetManyTimesRequest) returns (stream GreetManyTimesResponse) {}; 57 | 58 | // Client Streaming 59 | rpc LongGreet(stream LongGreetRequest) returns (LongGreetResponse) {}; 60 | 61 | // BiDi Streaming 62 | rpc GreetEveryone(stream GreetEveryoneRequest) returns (stream GreetEveryoneResponse) {}; 63 | 64 | // Unary with Deadline 65 | rpc GreetWithDeadline(GreetWithDeadlineRequest) returns (GreetWithDeadlineResponse) {}; 66 | } -------------------------------------------------------------------------------- /greet/greetpb/greet_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.2.0 4 | // - protoc v3.21.7 5 | // source: greet/greetpb/greet.proto 6 | 7 | package greetpb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.32.0 or later. 19 | const _ = grpc.SupportPackageIsVersion7 20 | 21 | // GreetServiceClient is the client API for GreetService service. 22 | // 23 | // 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. 24 | type GreetServiceClient interface { 25 | // Unary 26 | Greet(ctx context.Context, in *GreetRequest, opts ...grpc.CallOption) (*GreetResponse, error) 27 | // Server Streaming 28 | GreetManyTimes(ctx context.Context, in *GreetManyTimesRequest, opts ...grpc.CallOption) (GreetService_GreetManyTimesClient, error) 29 | // Client Streaming 30 | LongGreet(ctx context.Context, opts ...grpc.CallOption) (GreetService_LongGreetClient, error) 31 | // BiDi Streaming 32 | GreetEveryone(ctx context.Context, opts ...grpc.CallOption) (GreetService_GreetEveryoneClient, error) 33 | // Unary with Deadline 34 | GreetWithDeadline(ctx context.Context, in *GreetWithDeadlineRequest, opts ...grpc.CallOption) (*GreetWithDeadlineResponse, error) 35 | } 36 | 37 | type greetServiceClient struct { 38 | cc grpc.ClientConnInterface 39 | } 40 | 41 | func NewGreetServiceClient(cc grpc.ClientConnInterface) GreetServiceClient { 42 | return &greetServiceClient{cc} 43 | } 44 | 45 | func (c *greetServiceClient) Greet(ctx context.Context, in *GreetRequest, opts ...grpc.CallOption) (*GreetResponse, error) { 46 | out := new(GreetResponse) 47 | err := c.cc.Invoke(ctx, "/greet.GreetService/Greet", in, out, opts...) 48 | if err != nil { 49 | return nil, err 50 | } 51 | return out, nil 52 | } 53 | 54 | func (c *greetServiceClient) GreetManyTimes(ctx context.Context, in *GreetManyTimesRequest, opts ...grpc.CallOption) (GreetService_GreetManyTimesClient, error) { 55 | stream, err := c.cc.NewStream(ctx, &GreetService_ServiceDesc.Streams[0], "/greet.GreetService/GreetManyTimes", opts...) 56 | if err != nil { 57 | return nil, err 58 | } 59 | x := &greetServiceGreetManyTimesClient{stream} 60 | if err := x.ClientStream.SendMsg(in); err != nil { 61 | return nil, err 62 | } 63 | if err := x.ClientStream.CloseSend(); err != nil { 64 | return nil, err 65 | } 66 | return x, nil 67 | } 68 | 69 | type GreetService_GreetManyTimesClient interface { 70 | Recv() (*GreetManyTimesResponse, error) 71 | grpc.ClientStream 72 | } 73 | 74 | type greetServiceGreetManyTimesClient struct { 75 | grpc.ClientStream 76 | } 77 | 78 | func (x *greetServiceGreetManyTimesClient) Recv() (*GreetManyTimesResponse, error) { 79 | m := new(GreetManyTimesResponse) 80 | if err := x.ClientStream.RecvMsg(m); err != nil { 81 | return nil, err 82 | } 83 | return m, nil 84 | } 85 | 86 | func (c *greetServiceClient) LongGreet(ctx context.Context, opts ...grpc.CallOption) (GreetService_LongGreetClient, error) { 87 | stream, err := c.cc.NewStream(ctx, &GreetService_ServiceDesc.Streams[1], "/greet.GreetService/LongGreet", opts...) 88 | if err != nil { 89 | return nil, err 90 | } 91 | x := &greetServiceLongGreetClient{stream} 92 | return x, nil 93 | } 94 | 95 | type GreetService_LongGreetClient interface { 96 | Send(*LongGreetRequest) error 97 | CloseAndRecv() (*LongGreetResponse, error) 98 | grpc.ClientStream 99 | } 100 | 101 | type greetServiceLongGreetClient struct { 102 | grpc.ClientStream 103 | } 104 | 105 | func (x *greetServiceLongGreetClient) Send(m *LongGreetRequest) error { 106 | return x.ClientStream.SendMsg(m) 107 | } 108 | 109 | func (x *greetServiceLongGreetClient) CloseAndRecv() (*LongGreetResponse, error) { 110 | if err := x.ClientStream.CloseSend(); err != nil { 111 | return nil, err 112 | } 113 | m := new(LongGreetResponse) 114 | if err := x.ClientStream.RecvMsg(m); err != nil { 115 | return nil, err 116 | } 117 | return m, nil 118 | } 119 | 120 | func (c *greetServiceClient) GreetEveryone(ctx context.Context, opts ...grpc.CallOption) (GreetService_GreetEveryoneClient, error) { 121 | stream, err := c.cc.NewStream(ctx, &GreetService_ServiceDesc.Streams[2], "/greet.GreetService/GreetEveryone", opts...) 122 | if err != nil { 123 | return nil, err 124 | } 125 | x := &greetServiceGreetEveryoneClient{stream} 126 | return x, nil 127 | } 128 | 129 | type GreetService_GreetEveryoneClient interface { 130 | Send(*GreetEveryoneRequest) error 131 | Recv() (*GreetEveryoneResponse, error) 132 | grpc.ClientStream 133 | } 134 | 135 | type greetServiceGreetEveryoneClient struct { 136 | grpc.ClientStream 137 | } 138 | 139 | func (x *greetServiceGreetEveryoneClient) Send(m *GreetEveryoneRequest) error { 140 | return x.ClientStream.SendMsg(m) 141 | } 142 | 143 | func (x *greetServiceGreetEveryoneClient) Recv() (*GreetEveryoneResponse, error) { 144 | m := new(GreetEveryoneResponse) 145 | if err := x.ClientStream.RecvMsg(m); err != nil { 146 | return nil, err 147 | } 148 | return m, nil 149 | } 150 | 151 | func (c *greetServiceClient) GreetWithDeadline(ctx context.Context, in *GreetWithDeadlineRequest, opts ...grpc.CallOption) (*GreetWithDeadlineResponse, error) { 152 | out := new(GreetWithDeadlineResponse) 153 | err := c.cc.Invoke(ctx, "/greet.GreetService/GreetWithDeadline", in, out, opts...) 154 | if err != nil { 155 | return nil, err 156 | } 157 | return out, nil 158 | } 159 | 160 | // GreetServiceServer is the server API for GreetService service. 161 | // All implementations should embed UnimplementedGreetServiceServer 162 | // for forward compatibility 163 | type GreetServiceServer interface { 164 | // Unary 165 | Greet(context.Context, *GreetRequest) (*GreetResponse, error) 166 | // Server Streaming 167 | GreetManyTimes(*GreetManyTimesRequest, GreetService_GreetManyTimesServer) error 168 | // Client Streaming 169 | LongGreet(GreetService_LongGreetServer) error 170 | // BiDi Streaming 171 | GreetEveryone(GreetService_GreetEveryoneServer) error 172 | // Unary with Deadline 173 | GreetWithDeadline(context.Context, *GreetWithDeadlineRequest) (*GreetWithDeadlineResponse, error) 174 | } 175 | 176 | // UnimplementedGreetServiceServer should be embedded to have forward compatible implementations. 177 | type UnimplementedGreetServiceServer struct { 178 | } 179 | 180 | func (UnimplementedGreetServiceServer) Greet(context.Context, *GreetRequest) (*GreetResponse, error) { 181 | return nil, status.Errorf(codes.Unimplemented, "method Greet not implemented") 182 | } 183 | func (UnimplementedGreetServiceServer) GreetManyTimes(*GreetManyTimesRequest, GreetService_GreetManyTimesServer) error { 184 | return status.Errorf(codes.Unimplemented, "method GreetManyTimes not implemented") 185 | } 186 | func (UnimplementedGreetServiceServer) LongGreet(GreetService_LongGreetServer) error { 187 | return status.Errorf(codes.Unimplemented, "method LongGreet not implemented") 188 | } 189 | func (UnimplementedGreetServiceServer) GreetEveryone(GreetService_GreetEveryoneServer) error { 190 | return status.Errorf(codes.Unimplemented, "method GreetEveryone not implemented") 191 | } 192 | func (UnimplementedGreetServiceServer) GreetWithDeadline(context.Context, *GreetWithDeadlineRequest) (*GreetWithDeadlineResponse, error) { 193 | return nil, status.Errorf(codes.Unimplemented, "method GreetWithDeadline not implemented") 194 | } 195 | 196 | // UnsafeGreetServiceServer may be embedded to opt out of forward compatibility for this service. 197 | // Use of this interface is not recommended, as added methods to GreetServiceServer will 198 | // result in compilation errors. 199 | type UnsafeGreetServiceServer interface { 200 | mustEmbedUnimplementedGreetServiceServer() 201 | } 202 | 203 | func RegisterGreetServiceServer(s grpc.ServiceRegistrar, srv GreetServiceServer) { 204 | s.RegisterService(&GreetService_ServiceDesc, srv) 205 | } 206 | 207 | func _GreetService_Greet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 208 | in := new(GreetRequest) 209 | if err := dec(in); err != nil { 210 | return nil, err 211 | } 212 | if interceptor == nil { 213 | return srv.(GreetServiceServer).Greet(ctx, in) 214 | } 215 | info := &grpc.UnaryServerInfo{ 216 | Server: srv, 217 | FullMethod: "/greet.GreetService/Greet", 218 | } 219 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 220 | return srv.(GreetServiceServer).Greet(ctx, req.(*GreetRequest)) 221 | } 222 | return interceptor(ctx, in, info, handler) 223 | } 224 | 225 | func _GreetService_GreetManyTimes_Handler(srv interface{}, stream grpc.ServerStream) error { 226 | m := new(GreetManyTimesRequest) 227 | if err := stream.RecvMsg(m); err != nil { 228 | return err 229 | } 230 | return srv.(GreetServiceServer).GreetManyTimes(m, &greetServiceGreetManyTimesServer{stream}) 231 | } 232 | 233 | type GreetService_GreetManyTimesServer interface { 234 | Send(*GreetManyTimesResponse) error 235 | grpc.ServerStream 236 | } 237 | 238 | type greetServiceGreetManyTimesServer struct { 239 | grpc.ServerStream 240 | } 241 | 242 | func (x *greetServiceGreetManyTimesServer) Send(m *GreetManyTimesResponse) error { 243 | return x.ServerStream.SendMsg(m) 244 | } 245 | 246 | func _GreetService_LongGreet_Handler(srv interface{}, stream grpc.ServerStream) error { 247 | return srv.(GreetServiceServer).LongGreet(&greetServiceLongGreetServer{stream}) 248 | } 249 | 250 | type GreetService_LongGreetServer interface { 251 | SendAndClose(*LongGreetResponse) error 252 | Recv() (*LongGreetRequest, error) 253 | grpc.ServerStream 254 | } 255 | 256 | type greetServiceLongGreetServer struct { 257 | grpc.ServerStream 258 | } 259 | 260 | func (x *greetServiceLongGreetServer) SendAndClose(m *LongGreetResponse) error { 261 | return x.ServerStream.SendMsg(m) 262 | } 263 | 264 | func (x *greetServiceLongGreetServer) Recv() (*LongGreetRequest, error) { 265 | m := new(LongGreetRequest) 266 | if err := x.ServerStream.RecvMsg(m); err != nil { 267 | return nil, err 268 | } 269 | return m, nil 270 | } 271 | 272 | func _GreetService_GreetEveryone_Handler(srv interface{}, stream grpc.ServerStream) error { 273 | return srv.(GreetServiceServer).GreetEveryone(&greetServiceGreetEveryoneServer{stream}) 274 | } 275 | 276 | type GreetService_GreetEveryoneServer interface { 277 | Send(*GreetEveryoneResponse) error 278 | Recv() (*GreetEveryoneRequest, error) 279 | grpc.ServerStream 280 | } 281 | 282 | type greetServiceGreetEveryoneServer struct { 283 | grpc.ServerStream 284 | } 285 | 286 | func (x *greetServiceGreetEveryoneServer) Send(m *GreetEveryoneResponse) error { 287 | return x.ServerStream.SendMsg(m) 288 | } 289 | 290 | func (x *greetServiceGreetEveryoneServer) Recv() (*GreetEveryoneRequest, error) { 291 | m := new(GreetEveryoneRequest) 292 | if err := x.ServerStream.RecvMsg(m); err != nil { 293 | return nil, err 294 | } 295 | return m, nil 296 | } 297 | 298 | func _GreetService_GreetWithDeadline_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 299 | in := new(GreetWithDeadlineRequest) 300 | if err := dec(in); err != nil { 301 | return nil, err 302 | } 303 | if interceptor == nil { 304 | return srv.(GreetServiceServer).GreetWithDeadline(ctx, in) 305 | } 306 | info := &grpc.UnaryServerInfo{ 307 | Server: srv, 308 | FullMethod: "/greet.GreetService/GreetWithDeadline", 309 | } 310 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 311 | return srv.(GreetServiceServer).GreetWithDeadline(ctx, req.(*GreetWithDeadlineRequest)) 312 | } 313 | return interceptor(ctx, in, info, handler) 314 | } 315 | 316 | // GreetService_ServiceDesc is the grpc.ServiceDesc for GreetService service. 317 | // It's only intended for direct use with grpc.RegisterService, 318 | // and not to be introspected or modified (even as a copy) 319 | var GreetService_ServiceDesc = grpc.ServiceDesc{ 320 | ServiceName: "greet.GreetService", 321 | HandlerType: (*GreetServiceServer)(nil), 322 | Methods: []grpc.MethodDesc{ 323 | { 324 | MethodName: "Greet", 325 | Handler: _GreetService_Greet_Handler, 326 | }, 327 | { 328 | MethodName: "GreetWithDeadline", 329 | Handler: _GreetService_GreetWithDeadline_Handler, 330 | }, 331 | }, 332 | Streams: []grpc.StreamDesc{ 333 | { 334 | StreamName: "GreetManyTimes", 335 | Handler: _GreetService_GreetManyTimes_Handler, 336 | ServerStreams: true, 337 | }, 338 | { 339 | StreamName: "LongGreet", 340 | Handler: _GreetService_LongGreet_Handler, 341 | ClientStreams: true, 342 | }, 343 | { 344 | StreamName: "GreetEveryone", 345 | Handler: _GreetService_GreetEveryone_Handler, 346 | ServerStreams: true, 347 | ClientStreams: true, 348 | }, 349 | }, 350 | Metadata: "greet/greetpb/greet.proto", 351 | } 352 | -------------------------------------------------------------------------------- /ssl/ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEpDCCAowCCQDr67QKo48trzANBgkqhkiG9w0BAQsFADAUMRIwEAYDVQQDDAls 3 | b2NhbGhvc3QwHhcNMjIxMDA5MTc1OTA5WhcNMzIxMDA2MTc1OTA5WjAUMRIwEAYD 4 | VQQDDAlsb2NhbGhvc3QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCW 5 | 80hvszydiUwXT6s+df5xGhQKKBFPy3l46zIWRP8PpHGpgFloKJmC0zVlfS+U778w 6 | 2cIyakC2D4XnctF2Sg6YWXpVVf3HRT1RXMQwRlTYwjU6020jnLtbVmK6xAMYOqPS 7 | RY7u4Y3hH+GCA2oab5IRHeDVKWzuL34sdOHH8WAJMhhItTqPM0kZRyKzUfbMVZnt 8 | wbmZ/N82W7Ewm345EnS+Gb/47lpjmEBOlw9TmkKBOoHZuRkDyz5vY9Z1MBoZ4wF6 9 | EpeWLLP3pqxsj8dMYEVEAh7VucyI/8dU/pS+M+uimskoNGEmg1atZDt/Wl5EbYd9 10 | h2B98dc1nsZn7V1fY4nFKFGmQekU8r2LV+Zoy9gENCTUQ1HbW7lVjbXbST+ba3nX 11 | vr+0m1NlMXCyqRMK6XFMS8Q1h38maSfjJKKzFWz0hl8WBysyQKSfhcxRc1yF3xov 12 | yxGLd5P+0blr2kmpj7gAa6MmwI6BD64G0RW4DSqlauaLjCYtCUlAhR7dSywR6mcz 13 | 9YJpznh/dC/W/nOUMEMDuFiygZT0MAlmJHZQd7XeIqKk5YkcKkrwqKKgKk32tir6 14 | Vlot2Bk5MCvQ824ghi8O9BNXUX9auI8Sp6L8DqnFWzfZA4NYZmhONm4OEFM9Lm9M 15 | /GtxaxphHS8N6LZ0j/W3jHUbE4i/3i9XASfbxpzwOwIDAQABMA0GCSqGSIb3DQEB 16 | CwUAA4ICAQBf2nWzoS1ZqYckc6G52RGh6gI5srZiCLVbB5QGFuVWqwgjQbH08ZbL 17 | XXG9PkLqU5VJxvw/7UkJUn1K6rzhae13CDuM6SJCqxOo/jqezBGUEApM7LJj2YeC 18 | qYZVK3IY2B2XK40JPiqjN6wEWdoi6OtML3yD/4pfTTMNtI1uQWtv9wFYYFf+K8Rx 19 | As5sotbYhuzQASbpReFF3l3d5DaKUZQti7bIO9JN+nE1hi7JlaHfOG3YUUhp49hI 20 | DpD25ILBwZqIr+lVEpqHXaaPsKSBB6nLoMireDl8C7xH/2x83HVFgWdaw4da+pJ8 21 | t8T0QjckMBrt8fMLIhintEyY7Y/ObG9fyYISyfPT2zyGqDWrZXQ4tzjSEW/sD0s2 22 | z3H7ZLCL7HaTt86KVMUxURdMNugT+BukgWvc1JcJUUm4eqcDw97EggQlZmFDd3CA 23 | ne5khC7w0b2pv4oflC/VKEd23IhYXpif3JMdho1//6QVCJM2j6V4lQM0z+Fbf0r6 24 | p/6tUWnnA5j23C5G5Npd+NsUUDQ6KQHoqk3u1ixHSiuF66yus4n45rHjmZO3OjqT 25 | LA45GVkBXYiEsXi7ol0TQtoCs/H/8Tf/zIQ9OfiPgfizxQ44DkaG+s9OVPMUSonL 26 | J0wm3ttPbSb8PquPphsgl1pUy3hMetl3+X4651R8OA+Lwr4rPgGeUw== 27 | -----END CERTIFICATE----- 28 | -------------------------------------------------------------------------------- /ssl/ca.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-EDE3-CBC,C6EC74B031121EC4 4 | 5 | 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 54 | -----END RSA PRIVATE KEY----- 55 | -------------------------------------------------------------------------------- /ssl/instructions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Inspired from: https://github.com/grpc/grpc-java/tree/master/examples#generating-self-signed-certificates-for-use-with-grpc 3 | 4 | # Output files 5 | # ca.key: Certificate Authority private key file (this shouldn't be shared in real-life) 6 | # ca.crt: Certificate Authority trust certificate (this should be shared with users in real-life) 7 | # server.key: Server private key, password protected (this shouldn't be shared) 8 | # server.csr: Server certificate signing request (this should be shared with the CA owner) 9 | # server.crt: Server certificate signed by the CA (this would be sent back by the CA owner) - keep on server 10 | # server.pem: Conversion of server.key into a format gRPC likes (this shouldn't be shared) 11 | 12 | # Summary 13 | # Private files: ca.key, server.key, server.pem, server.crt 14 | # "Share" files: ca.crt (needed by the client), server.csr (needed by the CA) 15 | 16 | # Changes these CN's to match your hosts in your environment if needed. 17 | SERVER_CN=localhost 18 | 19 | # Step 1: Generate Certificate Authority + Trust Certificate (ca.crt) (Using SHA256 Algorithm) 20 | openssl genrsa -passout pass:1111 -des3 -out ca.key 4096 21 | openssl req -passin pass:1111 -new -x509 -sha256 -days 3650 -key ca.key -out ca.crt -subj "/CN=${SERVER_CN}" 22 | 23 | # Step 2: Generate the Server Private Key (server.key) 24 | openssl genrsa -passout pass:1111 -des3 -out server.key 4096 25 | 26 | # Step 3: Get a certificate signing request from the CA (server.csr) 27 | openssl req -passin pass:1111 -new -key server.key -out server.csr -subj "/CN=${SERVER_CN}" -config ssl.cnf 28 | 29 | # Step 4: Sign the certificate with the CA we created (it's called self signing) - server.crt (Using SHA256 Algorithm) 30 | openssl x509 -req -passin pass:1111 -sha256 -days 3650 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt -extensions req_ext -extfile ssl.cnf 31 | 32 | # Step 5: Convert the server certificate to .pem format (server.pem) - usable by gRPC 33 | openssl pkcs8 -topk8 -nocrypt -passin pass:1111 -in server.key -out server.pem -------------------------------------------------------------------------------- /ssl/server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEuzCCAqOgAwIBAgIBATANBgkqhkiG9w0BAQsFADAUMRIwEAYDVQQDDAlsb2Nh 3 | bGhvc3QwHhcNMjIxMDA5MTc1OTI2WhcNMzIxMDA2MTc1OTI2WjAUMRIwEAYDVQQD 4 | DAlsb2NhbGhvc3QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDL6WAL 5 | BxJngHm3Iy1otTpRpEavAHHdPB6CEQQh7TUcVA8GJ0DrA6OsR1IA38Jeuc4z51Ji 6 | vTugzx8FoRak3TayGlxozSS9JqdjnuNGeKcoAbmybwk8d1okhJRIYebXqyG3esNj 7 | GAKh2LZKYbWfNDNXH+DcRjrwYKvv/gFdV62loOwrH+lXqToDCr0ZLPpk8gNM3X+v 8 | TXe/2hrfGNc2hawgOWOoEtYeBkxuZk1I0JFQO5HWaKTe/rrqyJ+fnt3cuMJ78XfG 9 | qj1sl55VMtx8vd5DFIqC5MeLJCCT2isk+mCBBj3hANeJzSxsMUd0pPV2u3+7Y4At 10 | GBXJeKARIyVD3xZuV7o3fGWUJol8qWoZKezbKQUkqYiK9IE6didPmFVVO2W4Qxi9 11 | EOPqzHkawnzDQ5YtalJnlFFnAM44tvP/Gcng3fep7NRNw5f61U44gXLRDPSua2ql 12 | YsnTmYnWwukjq4/ONd9FS15ozd4JO+0miVdzBQxaEb7A4QBNiUPENW8kpH4j3eyW 13 | +1ZhE3lg++yRoRyGkDDLPI+CCpihAR9uDjLJKWTTI3LFRlabu+ePqVKDThc895q6 14 | ZZHCqQn527PmCkavhnoYnkvA4Hx0MaeyZ0U3lgw4bfoLL/3/aWsTDc2pvsv+njpe 15 | AdJMzX5rf/NYVvZnm8nGspPJjD4Bj8JWtjN8uwIDAQABoxgwFjAUBgNVHREEDTAL 16 | gglsb2NhbGhvc3QwDQYJKoZIhvcNAQELBQADggIBAANh0cYrvBPoAfMJudNAO7v/ 17 | HF5Jmqd3FS+JM6b+c5zmClcWZxC8TW/gTmICbSQxXndK0w67muvGE8iFxrZ4mQVF 18 | FSYC0s9hREpbRZuZyGFlYi1Ll+VCmFX48ifl3EmSEAxLRmD26bCRVEh/0GlnlzuR 19 | kz9TFWn7lkU1oPJozqBVf9YHiiYDFT0Nh3lFcAe8PXx/XWOoA/HpdssSObJAX9Be 20 | 6aP4g3bi80yDlhItHpkUwrFlJYQiOEHaqCd44XKe+Bt4HwT0bvyohM41XVuQAxlC 21 | Jxv2CNWL4vdtPac1IDOvULqsgmiQns6EZR6NHsDeKrGAqOdgo9sC4ye9kn1iEFuM 22 | 8MRtL16UnPabJUJAkA1qgGawjGwvCAN3hsG6/whCuKW5IK7jkyRbsmbbgZN0gfRd 23 | WRuO+QvfCd5b6nVke0aojakyIOZzr/6oVAJKQockui9/aR+Nvm0ZbBcCarkdpZY2 24 | vOot90+vBLbUfSHlDoMIcZP9o0cB1jLHEAwnliANklSWYwQk5RaE44hYWSncVEXS 25 | W32M3D/kHvCtGnEWRE59vArC0ZPL61ragr+9yro5qSdFcbWy+fqDzvBwrVQJr4MA 26 | mcZLLAVlx3ErgUrqEiU255XyXpk4GTBDy2BM0CIdth5j1FMnI1wu7CLrKzuuV44u 27 | hZYO9d0OAyY9+fRqaAiJ 28 | -----END CERTIFICATE----- 29 | -------------------------------------------------------------------------------- /ssl/server.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIIEgDCCAmgCAQAwFDESMBAGA1UEAwwJbG9jYWxob3N0MIICIjANBgkqhkiG9w0B 3 | AQEFAAOCAg8AMIICCgKCAgEAy+lgCwcSZ4B5tyMtaLU6UaRGrwBx3TweghEEIe01 4 | HFQPBidA6wOjrEdSAN/CXrnOM+dSYr07oM8fBaEWpN02shpcaM0kvSanY57jRnin 5 | KAG5sm8JPHdaJISUSGHm16sht3rDYxgCodi2SmG1nzQzVx/g3EY68GCr7/4BXVet 6 | paDsKx/pV6k6Awq9GSz6ZPIDTN1/r013v9oa3xjXNoWsIDljqBLWHgZMbmZNSNCR 7 | UDuR1mik3v666sifn57d3LjCe/F3xqo9bJeeVTLcfL3eQxSKguTHiyQgk9orJPpg 8 | gQY94QDXic0sbDFHdKT1drt/u2OALRgVyXigESMlQ98Wble6N3xllCaJfKlqGSns 9 | 2ykFJKmIivSBOnYnT5hVVTtluEMYvRDj6sx5GsJ8w0OWLWpSZ5RRZwDOOLbz/xnJ 10 | 4N33qezUTcOX+tVOOIFy0Qz0rmtqpWLJ05mJ1sLpI6uPzjXfRUteaM3eCTvtJolX 11 | cwUMWhG+wOEATYlDxDVvJKR+I93slvtWYRN5YPvskaEchpAwyzyPggqYoQEfbg4y 12 | ySlk0yNyxUZWm7vnj6lSg04XPPeaumWRwqkJ+duz5gpGr4Z6GJ5LwOB8dDGnsmdF 13 | N5YMOG36Cy/9/2lrEw3Nqb7L/p46XgHSTM1+a3/zWFb2Z5vJxrKTyYw+AY/CVrYz 14 | fLsCAwEAAaAnMCUGCSqGSIb3DQEJDjEYMBYwFAYDVR0RBA0wC4IJbG9jYWxob3N0 15 | MA0GCSqGSIb3DQEBCwUAA4ICAQC33AWmvWBQ0wRZvZHMvhxbZDZTXjii3DJVjbUg 16 | rsfM4jE+H+n05SN85foLYaok24o+aSB56nMpqC1w1JpCC1LwslWaEunHSNqDUBQe 17 | 7SS9G+DftJZuFRWPeI25z1UXlqppG4SGq5YOS+e+qhlgSyWRR2CNKP3CB7dPrSqn 18 | Zi7ewJ0qXfgOSXdYD8vd2VCqZw8T6ipmSlmMyg8mex0hirXLqjTzBW7P1MAD6Fbd 19 | f2+hysasj1BXMhQ1aKngzLZtTt0rqGXibkZkv7SfuAoplDzgU5Z3fHlIJmgi7hEq 20 | uD3tseYY8FNCWDvjJdIx5TM9N0cSLI9EHaphJTAEKn/p5IRPjUqL5a0dfYswYgj9 21 | KTyLD2vDrhtlLaUIKvN470b5fnI03hSTl3N1v99ktmn4fbEQgV4bugO5GZD9WlGb 22 | rWUlB7yykS2cllsdZeCuXBejWpLqPjr2f1Cm9eEdsNm8MLmhN66NVaK+TUk8G4pR 23 | x3eIzoOQJpTzDzjtnThpwweew7BLFrMuoMsAZ6EQqoOaUJc6et2AmelGDOAGZhL7 24 | 6YFJvWcoFheBD9TfZ+R2fbAVNDy/373CQ+TvJmV9wOQNtI5PMn2worxoPzol+6xa 25 | onzvdh+5bMkda/y8uSfdVqSQDvcYJWHN6gYDvJDcr4hai9VV/VKhA5afGP1Jqj/6 26 | guNNZg== 27 | -----END CERTIFICATE REQUEST----- 28 | -------------------------------------------------------------------------------- /ssl/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-EDE3-CBC,FFA9BEEFFB2CBE0C 4 | 5 | 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 54 | -----END RSA PRIVATE KEY----- 55 | -------------------------------------------------------------------------------- /ssl/server.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQDL6WALBxJngHm3 3 | Iy1otTpRpEavAHHdPB6CEQQh7TUcVA8GJ0DrA6OsR1IA38Jeuc4z51JivTugzx8F 4 | oRak3TayGlxozSS9JqdjnuNGeKcoAbmybwk8d1okhJRIYebXqyG3esNjGAKh2LZK 5 | YbWfNDNXH+DcRjrwYKvv/gFdV62loOwrH+lXqToDCr0ZLPpk8gNM3X+vTXe/2hrf 6 | GNc2hawgOWOoEtYeBkxuZk1I0JFQO5HWaKTe/rrqyJ+fnt3cuMJ78XfGqj1sl55V 7 | Mtx8vd5DFIqC5MeLJCCT2isk+mCBBj3hANeJzSxsMUd0pPV2u3+7Y4AtGBXJeKAR 8 | IyVD3xZuV7o3fGWUJol8qWoZKezbKQUkqYiK9IE6didPmFVVO2W4Qxi9EOPqzHka 9 | wnzDQ5YtalJnlFFnAM44tvP/Gcng3fep7NRNw5f61U44gXLRDPSua2qlYsnTmYnW 10 | wukjq4/ONd9FS15ozd4JO+0miVdzBQxaEb7A4QBNiUPENW8kpH4j3eyW+1ZhE3lg 11 | ++yRoRyGkDDLPI+CCpihAR9uDjLJKWTTI3LFRlabu+ePqVKDThc895q6ZZHCqQn5 12 | 27PmCkavhnoYnkvA4Hx0MaeyZ0U3lgw4bfoLL/3/aWsTDc2pvsv+njpeAdJMzX5r 13 | f/NYVvZnm8nGspPJjD4Bj8JWtjN8uwIDAQABAoICAQCv4MBdYqEmMvNI2gedq8r8 14 | hjQNV9XeW694wlKNLLtFjt9SkGL3EjGHNBDv/g/5gkvwCtLNpaibwGpigZo1YzR9 15 | FC2mm2LX31I7o90meIS9Bhf0Zr9RryRKISyA7iic1teDGVkTzK7giDpbF8H+6php 16 | ym45sD2//bHvk2f76dc16AIsBB9Q4/7MhuOppljm3rOoBdjPDIOAMBBDY3qlZVCc 17 | jsN9QZn7VbVw974rUvIzgN3+UE38pTv1rEu58t4sNhRRsWl9KnNGidQgankxAteF 18 | hl8eHVRbmDKdNG1IPMkmIIsY2pAOJLDvNOYMHwg1e+3lZCI3QvHvz6JIhcbrrqz5 19 | v1K+rbzetBSjxYzvsOKRGs+322rDXpbxelxOQbXFoHVDn4yn7nSC7RuqooqSOi/e 20 | lsSgHRb5kjdYkA/F4vL0z3/Sn3yXfO7VbnS50oMN5i8qO2h9qL7IB7bDReQ8aE4S 21 | sHC+hNuA9nwFx+Bw4g1jq9z5jXJKPsrhz8AUZfguRQP4qwy4p462KronaNpu6ILA 22 | 5fHG4UKOPLMCTJALhkwiVChn3XoRC8Ao9DDxse5hE07+GKpRoWvR8O1SQvpQTTD7 23 | WsW1dLy38Zfuzk1S8p0tJsfRSlCrgfCXz+jozRt3YdgYCqc4v86TLughgQjsM787 24 | GDtEX+fzT1bNudJ29vH1kQKCAQEA63AjvR84dh3MTORsZGvCn0Lg1YZxw7vGJIMQ 25 | tgspuuMmMizLYfNaO0TgK2JMFmHnBWoP7El+jlAKtRr2zp8V1zxOuXSxW1LS9wp9 26 | lAWXXfxgG3DUotSHRSIXH5504Va5TV/KSNxgux7tT+J3Z8n/ikT1+HZJqVVlYrOb 27 | 8R6SP1otCbOf8EM73VE6fMWJaR+Tvamh7/psLPKCA1n6q73RENdc8jmMwT06vINR 28 | TLsGZzhg5z6Z4wJa5NeemImQJgExrhTTpkMCdhhX1NxkbMSrtnQNIC851JGRzZ1J 29 | hkPlFj508GnIjLkfHP1Z09tBwxIb8tIttcX8BrA4Vz19N0hvUwKCAQEA3bhgU7/W 30 | Qc62RUlCbUOIAQV0s9QEy7IoJJlZ3vzzw9Ar3YS2VAo7dqrDNuR15WGhy9ZfZJLp 31 | itcTo344kBwkufKTUf3lwg+20ZsYHHRR8qAjHTDnT7EJVAjrfxTjYpQ5VxNxAMAq 32 | 6KyH24v7khL4f6dJ9zMw1JAnBW90PxhM4andSCmtVeu22f5+Z8aFDRHxNiP+qi6L 33 | 4Fn7k/RARDFCthRQ4USICHX57MPaEA32JgZEeiamQ9kD1I7f6zxmUL1bjeRQp91I 34 | QxcyOyT/HTcDXurg4/HykGopDJmCCZ9ZrEX+AKi6fUaiWXMyB6Mz/UHQ8NefGJmr 35 | tCnxj4HoJi5X+QKCAQA777RpdQU+rJ9SA+TEO9q0CKaMNUnI9oieyu76KSVaenFC 36 | 3Lx6FyWlaQdYhBGysQHLExEyqhMZz66qJE8okr9Qp/2yoM513UPvuC/3+uRp/NHK 37 | qpK3UTuOkfspBYHjy9woonYwzkmh2WG4sIKNXZM8dAnaUuK1xROmaOsOGyZIEoDc 38 | s2nIFJWs5fzpvrAYnv1Rj1m2ah4X4zTN/Z4fEpeinfD/iT8YAqptS1DrI8GhjWy9 39 | 8eXjMLpK/8lUM9EKm8s18f9fmDeMMO5LNkAqoHbGYAznYJ5sSxK/MYeCMs6jNws2 40 | GPgBOy98hdLUaED5lCahTnhsihZ67Wmqa/DwnfQZAoIBAFpX1mhJsrP91qdEwpxi 41 | 9/fykSr1KT8WyOSg183UpD8Vg8ovWVvFD5W63vBvBtsAfTzhjN0eP6sjGA12UPXn 42 | gc+C2CSAoC4C2StvVtPBUeLa/XPXiWkfaf2j5NFTYZO5cePZOCJmKxXDt1fuIgPT 43 | Vw4szCa95Re35S6By4wqCqmo3VGaKdboxQjuefMvIOfCd9bns80ESlqQT8JptAYV 44 | TGmEvbAMjKFl8QBYjXIdPj8gLqbXOMhMlRL3ZKYlZktf3P5kGblMoTU1LnKLEKiG 45 | 0gjLC/fVjlDp8PABXMsu8wsPOgBqwBJrxZtNJQWXqod3WfvI4DrV4vD2ZkdjV4S3 46 | PYECggEBAKBMcxwJNkh3/9XKWXfhiHAgdayFcXO4ug5PRaq6qcIU2ah5Ntd4CJaJ 47 | BbGCy7ZDTKMUgExm8L7eAq6pTJsuiashbZx2ZyY7UgN6C6nOKPvKgcBU9EPln4nI 48 | ujjUZFsAII3RXoh65ggKTwh8QlX8hJdM1IK94IAj8xVOWrQcdpzZ16DlvfgSZcpm 49 | uiI9YeQY8NEarSHmNS6BDZnvvp1sVOHZy2h+jOU+krjqWlyg2kbju8ox/enBk4bO 50 | FYE9qOJ5u/baCaqadN00ZrwHiLORMCbEocquJYuzBftTlC/MkOwQ5BOOB9caKQX0 51 | OPHbOW9Px9Sa7nqCaa8naeFWiXcbmvU= 52 | -----END PRIVATE KEY----- 53 | -------------------------------------------------------------------------------- /ssl/ssl.cnf: -------------------------------------------------------------------------------- 1 | [ req ] 2 | default_bits = 4096 3 | distinguished_name = dn 4 | req_extensions = req_ext 5 | prompt = no 6 | 7 | [ dn ] 8 | CN = localhost 9 | 10 | [ req_ext ] 11 | subjectAltName = @alt_names 12 | 13 | [alt_names] 14 | DNS.1 = localhost --------------------------------------------------------------------------------