New upstream version 3.1.1
Louis-Philippe VĂ©ronneau
3 years ago
0 | |
(defproject puppetlabs/kitchensink "3.1.0"
|
|
0 |
(defproject puppetlabs/kitchensink "3.1.1"
|
1 | 1 |
:description "Clojure utility functions"
|
2 | 2 |
:license {:name "Apache License, Version 2.0"
|
3 | 3 |
:url "http://www.apache.org/licenses/LICENSE-2.0.html"}
|
1098 | 1098 |
(throw e)))))
|
1099 | 1099 |
|
1100 | 1100 |
(defn open-port-num
|
1101 | |
"Returns a currently open port number in the traditional ephemeral port range
|
1102 | |
of 49152 through 65535."
|
|
1101 |
"Returns a currently open port number in the port range 16384
|
|
1102 |
through 32767. Note that on Linux, anything above 32767 lies in
|
|
1103 |
the ephemeral port range, which is the range that the system uses
|
|
1104 |
to allocate ports upon user request. Thus, we choose from a
|
|
1105 |
different range to prevent possible port conflicts caused by
|
|
1106 |
various services (e.g. database connection pools)."
|
1103 | 1107 |
[]
|
1104 | |
(let [lo 49152
|
1105 | |
hi 65536] ; one higher because the upper limit is exclusive
|
|
1108 |
(let [lo 16384
|
|
1109 |
hi 32768] ; one higher because the upper limit is exclusive
|
1106 | 1110 |
(if-let [open-port (some port-open? (shuffle (range lo hi)))]
|
1107 | 1111 |
open-port
|
1108 | 1112 |
(throw (java.net.BindException.
|
1109 | |
"All ephemeral ports are already in use (Bind failed)")))))
|
|
1113 |
(format "All ports in the range %d through %d are already in use (Bind failed)" lo (dec hi)))))))
|
1110 | 1114 |
|
1111 | 1115 |
(defmacro assoc-if-new
|
1112 | 1116 |
"Assocs the provided values with the corresponding keys if and only
|