1(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")
16(load (merge-pathnames "load-locally.lisp" *load-truename*))
17(require "sb-grovel") ;; necessary for :net.didierverna.clon.termio
18(asdf:load-asd (first (directory (merge-pathnames "../../lib/cl/externals/software/clon-*/termio/net.didierverna.clon.termio.asd"
19                                                  *load-truename*))))
20(asdf:load-system :net.didierverna.clon)
21(asdf:load-asd (merge-pathnames "gen-cl/shared/thrift-gen-shared.asd" *load-truename*))
22(asdf:load-asd (merge-pathnames "gen-cl/tutorial/thrift-gen-tutorial.asd" *load-truename*))
23(asdf:load-asd (merge-pathnames "thrift-tutorial.asd" *load-truename*))
24(asdf:load-system :thrift-tutorial)
25
26(net.didierverna.clon:nickname-package)
27
28(defun main ()
29  "Entry point for the binary."
30  (thrift:with-client (prot #u"thrift://127.0.0.1:9090")
31    (tutorial.calculator:ping prot)
32    (format t "ping()~%")
33    (format t "1 + 1 = ~a~%" (tutorial.calculator:add prot 1 1))
34    (let ((work-instance (tutorial:make-work :num1 5
35                                             :num2 0
36                                             :op tutorial:operation.divide
37                                             :comment "Booya!")))
38      (handler-case (format t
39                            "5 / 0 = ~a - Oh, really? An exception should have been thrown here.~%"
40                            (tutorial.calculator:calculate prot 1 work-instance))
41        (tutorial:invalidoperation (e)
42          (format t "---~%(Expected) Invalid Operation caught: ~%~a~%---~%" e))))
43    (let ((work-instance (tutorial:make-work :num1 15
44                                             :num2 10
45                                             :op tutorial:operation.subtract
46                                             :comment "Playing nice this time.")))
47      (handler-case (format t
48                            "15 - 10 = ~a~%"
49                            (tutorial.calculator:calculate prot 1 work-instance))
50        (tutorial:invalidoperation (e)
51          (format t "---~%(Unexpected) Invalid Operation caught: ~%~a~%---~%" e))))
52    (format t "Check log: ~a~%" (shared.shared-service:get-struct prot 1))))
53
54(clon:dump "TutorialClient" main)
55