Просмотр исходного кода

Adds Woo Common Lisp framework to project (#4233)

* Adds caveman2 and woo Lisp frameworks

* Removes caveman2 temporarily

* Update README.md
Julian Coleman 6 лет назад
Родитель
Сommit
e70dea1816

+ 1 - 0
.travis.yml

@@ -89,6 +89,7 @@ env:
      - "TESTDIR=Java/wizzardo-http"
      - "TESTLANG=JavaScript"
      - "TESTLANG=Kotlin"
+     - "TESTLANG=Lisp"
      - "TESTLANG=Lua"
      - "TESTLANG=Nim"
      - "TESTLANG=Perl"

+ 6 - 0
frameworks/Lisp/woo/README.md

@@ -0,0 +1,6 @@
+# Woo
+
+Woo is a fast non-blocking HTTP server built on top of
+libev.
+
+https://github.com/fukamachi/woo

+ 25 - 0
frameworks/Lisp/woo/benchmark_config.json

@@ -0,0 +1,25 @@
+{
+    "framework": "woo",
+    "tests": [
+        {
+            "default": {
+                "plaintext_url": "/plaintext",
+                "port": 8080,
+                "approach": "Realistic",
+                "classification": "Micro",
+                "database": "None",
+                "framework": "woo",
+                "language": "Lisp",
+                "flavor": "None",
+                "orm": "Raw",
+                "platform": "Lisp",
+                "webserver": "None",
+                "os": "Linux",
+                "database_os": "Linux",
+                "display_name": "woo",
+                "notes": "",
+                "versus": ""
+            }
+        }
+    ]
+}

+ 10 - 0
frameworks/Lisp/woo/woo.dockerfile

@@ -0,0 +1,10 @@
+FROM fukamachi/roswell
+
+WORKDIR /woo
+ADD  . .
+
+RUN apt install -y libev-dev
+
+RUN ["chmod", "+x", "./woo.ros"]
+
+CMD ./woo.ros --worker $(nproc) --port 8080

+ 82 - 0
frameworks/Lisp/woo/woo.ros

@@ -0,0 +1,82 @@
+#|-*- mode:lisp -*-|#
+#|
+exec ros -Q -- $0 "$@"
+|#
+
+;; Woo is a fast non-blocking HTTP server built on top of
+;; libev. Although Woo is written in Common Lisp, it aims
+;; to be the fastest web server written in any programming
+;; language.
+
+;; https://github.com/fukamachi/woo
+
+;; Quicklisp is a library manager for Common Lisp. Use
+;; QuickLisp's quickload function to retrieve external
+;; packages. These packages are automatically curl'd when
+;; the program runs.
+
+;; Woo - https://github.com/fukamachi/woo
+;; Clack - https://github.com/fukamachi/clack
+;; Alexandria - https://github.com/keithj/alexandria
+;; Optima - https://github.com/m2ym/optima
+;; Jonathan - https://github.com/fukamachi/jonathan
+
+(ql:quickload '(:uiop :woo :alexandria :optima :jonathan) :silent t)
+(use-package :optima)
+
+;; This is just boilerplate
+(defun starts-with (x starts)
+  (and (<= (length starts) (length x))
+       (string= x starts :end1 (length starts))))
+
+(defun parse-argv (args)
+  (flet ((parse-int-value (option value)
+           (handler-case (parse-integer value)
+             (error (e)
+               (error "Invalid value for ~S: ~S~%  ~A" option value e)))))
+    (loop for option = (pop args)
+          for value = (pop args)
+          while option
+          if (not (starts-with option "--"))
+            do (error "Invalid option: ~S" option)
+          else
+            if (equal option "--worker")
+              append (list :worker-num (parse-int-value option value))
+          else
+            if (equal option "--port")
+              append (list :port (parse-int-value option value))
+          else
+            do (error "Unknown option: ~S" option))))
+;; END BOILERPLATE
+
+
+;; Plaintext handler
+(defun plaintext (env)
+  (declare (ignore env))
+  '(200 (:content-type "text/plain" :server "Woo") ("Hello, World!"))
+)
+
+
+;; Route handler
+(defun handler (env)
+  (optima:match env
+    (
+      (guard (property :path-info path) (alexandria:starts-with-subseq "/plaintext" path))
+      (funcall 'plaintext env)
+    )
+  )
+)
+
+
+;; Create and start the server
+(defun main (&rest argv)
+  (let ((args (parse-argv argv)))
+    (apply #'woo:run
+      (lambda (env)
+        (funcall 'handler env)
+      )
+      :debug nil
+      args
+    )
+  )
+)