File tree Expand file tree Collapse file tree 3 files changed +60
-0
lines changed
Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright 2021 Google LLC
2+ //
3+ // Use of this source code is governed by an MIT-style
4+ // license that can be found in the LICENSE file or at
5+ // https://opensource.org/licenses/MIT.
6+
7+ syntax = "proto3" ;
8+
9+ message HelloRequest {
10+ optional string name = 1 ;
11+ }
12+
13+ message HelloReply {
14+ optional string message = 1 ;
15+ }
16+
17+ service HelloWorld {
18+ rpc SayHello (HelloRequest ) returns (HelloReply ) {}
19+ }
Original file line number Diff line number Diff line change 1+ (defsystem :hw-grpc
2+ :author " Jonathan Godbout <[email protected] >" 3+ :description
4+ " Tutorial Program to go along with blog posts about using gRPC."
5+ :license " MIT"
6+ :defsystem-depends-on (:cl-protobufs.asdf )
7+ :depends-on (:cl-protobufs :grpc )
8+ :serial t
9+ :components ((:protobuf-source-file " hello" )
10+ (:file " server" )))
Original file line number Diff line number Diff line change 1+ ; ; Implement a gRPC server for Hellow World.
2+
3+ (defpackage #:grpc-server
4+ (:use # :cl)
5+ (:local-nicknames
6+ (# :hello-rpc # :cl-protobufs.hello-rpc)
7+ (# :hello # :cl-protobufs.hello)))
8+
9+ (in-package # :grpc-server)
10+
11+ ; ; A defgeneric is generated by protoc from the SayHello
12+ ; ; rpc line inside of the HellowWorld service in hello.proto.
13+ (defmethod hello-rpc :say-hello ((request hello :hello-request) rpc)
14+ ; ; The RPC contains useful data for more intricate requests.
15+ (declare (ignore rpc))
16+ (hello :make-hello-reply
17+ :message (concatenate ' string " Hello " (hello :hello-request.name request))))
18+
19+ (defconstant hostname " 127.0.0.1" " Hostname for our server." )
20+ (defconstant port-number " 8080" " Port for our server." )
21+
22+ (defun main ()
23+ ; ; Before we use gRPC we need to init-grpc, this sets up
24+ ; ; low-level gRPC internals.
25+ (grpc :init-grpc)
26+ ; ; This starts the server.
27+ (grpc ::run-grpc-proto-server
28+ (concatenate ' string
29+ hostname " :"
30+ (write-to-string port-number))
31+ ' hello:hello-world))
You can’t perform that action at this time.
0 commit comments