blob: 3a6d86134fd13632db7817846f2e996719e47662 [file] [log] [blame]
Tomek Kurcze93a9012017-09-19 09:16:43 +02001(in-package #:cl-user)
2
3;;;; Licensed under the Apache License, Version 2.0 (the "License");
4;;;; you may not use this file except in compliance with the License.
5;;;; You may obtain a copy of the License at
6;;;;
7;;;; http://www.apache.org/licenses/LICENSE-2.0
8;;;;
9;;;; Unless required by applicable law or agreed to in writing, software
10;;;; distributed under the License is distributed on an "AS IS" BASIS,
11;;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12;;;; See the License for the specific language governing permissions and
13;;;; limitations under the License.
14
15(require "asdf")
Allen George54e95872018-11-30 15:06:44 -050016(load (merge-pathnames "load-locally.lisp" *load-truename*))
Tomek Kurcze93a9012017-09-19 09:16:43 +020017(asdf:load-system :net.didierverna.clon)
18(asdf:load-asd (merge-pathnames "gen-cl/shared/thrift-gen-shared.asd" *load-truename*))
19(asdf:load-asd (merge-pathnames "gen-cl/tutorial/thrift-gen-tutorial.asd" *load-truename*))
20(asdf:load-asd (merge-pathnames "thrift-tutorial.asd" *load-truename*))
21(asdf:load-system :thrift-tutorial)
22
23(net.didierverna.clon:nickname-package)
24
25(defun main ()
26 "Entry point for the binary."
27 (thrift:with-client (prot #u"thrift://127.0.0.1:9090")
28 (tutorial.calculator:ping prot)
29 (format t "ping()~%")
30 (format t "1 + 1 = ~a~%" (tutorial.calculator:add prot 1 1))
31 (let ((work-instance (tutorial:make-work :num1 5
32 :num2 0
33 :op tutorial:operation.divide
34 :comment "Booya!")))
35 (handler-case (format t
36 "5 / 0 = ~a - Oh, really? An exception should have been thrown here.~%"
37 (tutorial.calculator:calculate prot 1 work-instance))
38 (tutorial:invalidoperation (e)
39 (format t "---~%(Expected) Invalid Operation caught: ~%~a~%---~%" e))))
40 (let ((work-instance (tutorial:make-work :num1 15
41 :num2 10
42 :op tutorial:operation.subtract
43 :comment "Playing nice this time.")))
44 (handler-case (format t
45 "15 - 10 = ~a~%"
46 (tutorial.calculator:calculate prot 1 work-instance))
47 (tutorial:invalidoperation (e)
48 (format t "---~%(Unexpected) Invalid Operation caught: ~%~a~%---~%" e))))
49 (format t "Check log: ~a~%" (shared.shared-service:get-struct prot 1))))
50
51(clon:dump "TutorialClient" main)