-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.lisp
More file actions
31 lines (26 loc) · 983 Bytes
/
server.lisp
File metadata and controls
31 lines (26 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
;; Implement a gRPC server for Hellow World.
(defpackage #:grpc-server
(:use #:cl)
(:local-nicknames
(#:hello-rpc #:cl-protobufs.hello-rpc)
(#:hello #:cl-protobufs.hello)))
(in-package #:grpc-server)
;; A defgeneric is generated by protoc from the SayHello
;; rpc line inside of the HellowWorld service in hello.proto.
(defmethod hello-rpc:say-hello ((request hello:hello-request) rpc)
;; The RPC contains useful data for more intricate requests.
(declare (ignore rpc))
(hello:make-hello-reply
:message (concatenate 'string "Hello " (hello:hello-request.name request))))
(defconstant +hostname+ "127.0.0.1" "Hostname for our server.")
(defconstant +port-number+ "8080" "Port for our server.")
(defun main ()
;; Before we use gRPC we need to init-grpc, this sets up
;; low-level gRPC internals.
(grpc:init-grpc)
;; This starts the server.
(grpc::run-grpc-proto-server
(concatenate 'string
+hostname+ ":"
+port-number+)
'hello:hello-world))