Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9b82c93

Browse files
author
Dainius Jocas
committed
feat: compile to native image
1 parent 06e6e2b commit 9b82c93

File tree

5 files changed

+39
-5
lines changed

5 files changed

+39
-5
lines changed

‎.gitignore‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.cpcache/
2+
.idea/
3+
**/*.iml
4+
libsunec.so
5+
pom.xml
6+
target/*
7+
url-checker

‎Dockerfile‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM tokenmill/clojure:graalvm-ce-19.0.0-tools-deps-1.10.0.442 as builder
2+
3+
RUN mkdir -p /usr/src/app
4+
WORKDIR /usr/src/app
5+
6+
COPY deps.edn /usr/src/app/
7+
RUN clojure -R:native-image
8+
COPY . /usr/src/app
9+
RUN clojure -A:native-image
10+
RUN cp $JAVA_HOME/jre/lib/amd64/libsunec.so .
11+
RUN cp target/app url-checker

‎Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ build-graal-url-checker:
2222
docker rm build || true
2323
docker create --name build fast-url-checker
2424
docker cp build:/usr/src/app/url-checker url-checker
25+
docker cp build:/usr/src/app/libsunec.so libsunec.so

‎deps.edn‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@
1717
:main-opts ["-e" "(require,'[kibit.driver,:as,k])(k/external-run,[\"src\"],nil)"]}
1818
:eastwood {:main-opts ["-m" "eastwood.lint" "{:source-paths,[\"src\"]}"]
1919
:extra-deps {jonase/eastwood {:mvn/version "RELEASE"}}}
20-
:uberjar {:extra-deps {luchiniatwork/cambada {:mvn/version "1.0.0"}}
20+
:uberjar {:extra-deps {luchiniatwork/cambada {:git/url "https://github.com/xfthhxk/cambada"
21+
:sha "8fdc7d29a41620ad3e9e6210fd7140f3a4c7936b"
22+
:exclusions [org.slf4j/slf4j-nop]}}
2123
:main-opts ["-m" "cambada.uberjar"
22-
"-m" "fast_url_check.java"]}}}
24+
"-m" "fast_url_check.java"]}
25+
:native-image
26+
{:extra-deps {luchiniatwork/cambada {:git/url "https://github.com/xfthhxk/cambada"
27+
:sha "8fdc7d29a41620ad3e9e6210fd7140f3a4c7936b"
28+
:exclusions [org.slf4j/slf4j-nop]}}
29+
:main-opts ["-m" "cambada.native-image"
30+
"-m" "fast_url_check.core"
31+
"-a" "fast-url-check.core"
32+
"-O" "-initialize-at-build-time"
33+
"-O" "-enable-all-security-services"
34+
"-O" "-initialize-at-run-time=org.httpkit.client.SslContextFactory"
35+
"-O" "-initialize-at-run-time=org.httpkit.client.HttpClient"]}}}

‎src/fast_url_check/core.clj‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(ns fast-url-check.core
2+
(:gen-class)
23
(:require [clojure.tools.logging :as log]
34
[org.httpkit.client :as http]
45
[clojure.string :as s]
@@ -71,8 +72,8 @@
7172
(merge default-opts opts {:url url :method :head})
7273
(fn [{:keys [status headers error]}]
7374
(let [redirect-url (get headers :location "")
74-
status-type (some-> status (str) (first) (Character/getNumericValue))
75-
exception (some-> error (.getMessage) (remove-url-in-error-message url))]
75+
status-type (some-> status (str) ^Character (first) (Character/getNumericValue))
76+
exception (some-> ^Exception error (.getMessage) (remove-url-in-error-message url))]
7677
(merge {:url url
7778
:seed seed
7879
:status status
@@ -131,4 +132,5 @@
131132
(doseq [{:keys [url seed status status-type response-time exception]}
132133
(check-access-bulk (line-seq rdr) :opts (json/decode opts true))]
133134
(csv/write-csv *out* [[(Instant/now) seed url status (name status-type) response-time exception]])
134-
(flush))))
135+
(flush)))
136+
(shutdown-agents))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /