mirror of
https://github.com/penpot/penpot.git
synced 2026-05-26 18:33:43 +00:00
✨ Minor improvements on vertx.core ns.
This commit is contained in:
parent
864081c31e
commit
685dade614
25
backend/vendor/vertx/src/vertx/core.clj
vendored
25
backend/vendor/vertx/src/vertx/core.clj
vendored
@ -26,10 +26,6 @@
|
|||||||
(declare build-actor)
|
(declare build-actor)
|
||||||
(declare build-disposable)
|
(declare build-disposable)
|
||||||
|
|
||||||
;; --- Protocols
|
|
||||||
|
|
||||||
(definterface IVerticleFactory)
|
|
||||||
|
|
||||||
;; --- Public Api
|
;; --- Public Api
|
||||||
|
|
||||||
(s/def :vertx.core$system/threads pos?)
|
(s/def :vertx.core$system/threads pos?)
|
||||||
@ -61,6 +57,7 @@
|
|||||||
promise execution chain."
|
promise execution chain."
|
||||||
([prm] (handle-on-context prm (current-context)))
|
([prm] (handle-on-context prm (current-context)))
|
||||||
([prm ctx]
|
([prm ctx]
|
||||||
|
(assert (instance? Context ctx) "`ctx` should be a valid Context instance")
|
||||||
(let [d (p/deferred)]
|
(let [d (p/deferred)]
|
||||||
(p/finally prm (fn [v e]
|
(p/finally prm (fn [v e]
|
||||||
(.runOnContext
|
(.runOnContext
|
||||||
@ -72,6 +69,14 @@
|
|||||||
(p/resolve! d v)))))))
|
(p/resolve! d v)))))))
|
||||||
d)))
|
d)))
|
||||||
|
|
||||||
|
(defn run-on-context
|
||||||
|
[ctx f]
|
||||||
|
(.runOnContext
|
||||||
|
^Context ctx
|
||||||
|
^Handler (reify Handler
|
||||||
|
(handle [_ v']
|
||||||
|
(f ctx)))))
|
||||||
|
|
||||||
(s/def :vertx.core$verticle/on-start fn?)
|
(s/def :vertx.core$verticle/on-start fn?)
|
||||||
(s/def :vertx.core$verticle/on-stop fn?)
|
(s/def :vertx.core$verticle/on-stop fn?)
|
||||||
(s/def :vertx.core$verticle/on-error fn?)
|
(s/def :vertx.core$verticle/on-error fn?)
|
||||||
@ -84,15 +89,15 @@
|
|||||||
"Creates a verticle instance (factory)."
|
"Creates a verticle instance (factory)."
|
||||||
[options]
|
[options]
|
||||||
(s/assert ::verticle-options options)
|
(s/assert ::verticle-options options)
|
||||||
|
^{::verticle true ::options options}
|
||||||
(reify
|
(reify
|
||||||
IVerticleFactory
|
|
||||||
Supplier
|
Supplier
|
||||||
(get [_] (build-verticle options))))
|
(get [_] (build-verticle options))))
|
||||||
|
|
||||||
(defn verticle?
|
(defn verticle?
|
||||||
"Return `true` if `v` is instance of `IVerticleFactory`."
|
"Return `true` if `v` is instance of `IVerticleFactory`."
|
||||||
[v]
|
[v]
|
||||||
(instance? IVerticleFactory v))
|
(true? (::verticle (meta v))))
|
||||||
|
|
||||||
(s/def :vertx.core$actor/on-message fn?)
|
(s/def :vertx.core$actor/on-message fn?)
|
||||||
(s/def ::actor-options
|
(s/def ::actor-options
|
||||||
@ -107,8 +112,8 @@
|
|||||||
[topic options]
|
[topic options]
|
||||||
(s/assert string? topic)
|
(s/assert string? topic)
|
||||||
(s/assert ::actor-options options)
|
(s/assert ::actor-options options)
|
||||||
|
^{::verticle true ::options options ::topic topic}
|
||||||
(reify
|
(reify
|
||||||
IVerticleFactory
|
|
||||||
Supplier
|
Supplier
|
||||||
(get [_] (build-actor topic options))))
|
(get [_] (build-actor topic options))))
|
||||||
|
|
||||||
@ -149,7 +154,8 @@
|
|||||||
(defn- build-verticle
|
(defn- build-verticle
|
||||||
[{:keys [on-start on-stop on-error]
|
[{:keys [on-start on-stop on-error]
|
||||||
:or {on-error (constantly nil)
|
:or {on-error (constantly nil)
|
||||||
on-stop (constantly nil)}}]
|
on-stop (constantly nil)}
|
||||||
|
:as options}]
|
||||||
(let [vsm (volatile! nil)
|
(let [vsm (volatile! nil)
|
||||||
ctx (volatile! nil)
|
ctx (volatile! nil)
|
||||||
lst (volatile! nil)]
|
lst (volatile! nil)]
|
||||||
@ -212,9 +218,10 @@
|
|||||||
opts))
|
opts))
|
||||||
|
|
||||||
(defn- opts->vertx-options
|
(defn- opts->vertx-options
|
||||||
[{:keys [threads on-error]}]
|
[{:keys [threads worker-threads on-error]}]
|
||||||
(let [opts (VertxOptions.)]
|
(let [opts (VertxOptions.)]
|
||||||
(when threads (.setEventLoopPoolSize opts (int threads)))
|
(when threads (.setEventLoopPoolSize opts (int threads)))
|
||||||
|
(when worker-threads (.setWorkerPoolSize opts (int worker-threads)))
|
||||||
(when on-error (.exceptionHandler (vu/fn->handler on-error)))
|
(when on-error (.exceptionHandler (vu/fn->handler on-error)))
|
||||||
opts))
|
opts))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user