Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prestancedesign/get-port
Get an available TCP port in Clojure with options
https://github.com/prestancedesign/get-port
clojure clojure-library http
Last synced: 8 days ago
JSON representation
Get an available TCP port in Clojure with options
- Host: GitHub
- URL: https://github.com/prestancedesign/get-port
- Owner: prestancedesign
- License: epl-1.0
- Created: 2020-12-10T21:50:28.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-27T19:49:04.000Z (over 2 years ago)
- Last Synced: 2024-04-24T02:01:09.197Z (7 months ago)
- Topics: clojure, clojure-library, http
- Language: Clojure
- Homepage:
- Size: 25.4 KB
- Stars: 19
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# get-port
Get an available TCP port for Clojure.
The latest versions on Clojar
[![Clojars Project](https://clojars.org/prestancedesign/get-port/latest-version.svg)](https://clojars.org/prestancedesign/get-port)
## Installation
For `deps.edn`:
```clojure
prestancedesign/get-port {:mvn/version "0.1.1"}
```
For `project.clj`:```clojure
[prestancedesign/get-port "0.1.1"]
```## Usage
```clojure
(ns hello-world.core
(:require [prestancedesign.get-port :refer [get-port make-range]]
[ring.adapter.jetty :as server]))...
(server/run-jetty handler {:port (get-port)}) ; Get a random available port
```Pass in a preferred port:
```clojure
(get-port {:port 3000})
```Pass in a vector of preferred ports:
```clojure
(get-port {:port [3000 3004 3010]})
```Use the `make-range` helper in case you need a port in a certain (inclusive) range:
```clojure
(get-port {:port (make-range 3000 3005)})
```Copyright © 2020-2021 Michaël SALIHI
Distributed under the Eclipse Public License, the same as Clojure.