diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 695b389..a861e9a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -34,5 +34,5 @@ jobs: run: gh release upload ${{ github.event.release.tag_name }} dist/*.{tar.gz,whl} env: GH_TOKEN: ${{ github.token }} - # - name: Publish package distributions to PyPI - # uses: pypa/gh-action-pypi-publish@release/v1 + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/API.md b/API.md index 783a371..bf82fba 100644 --- a/API.md +++ b/API.md @@ -23,7 +23,7 @@ The logger for this namespace. -
+ ## `ops` @@ -32,7 +32,7 @@ The logger for this namespace. A map of operations supported by the nREPL server (as keywords) to function handlers for those operations. - + ## `server-start!` ``` clojure @@ -72,6 +72,7 @@ Creates an `socketserver/ThreadingTCPServer` nREPL server with detect. `:port` The port number to listen to, defaults to 0 which means to + pickup a random available port. `:server*` An optional promise delivering a map on server upbringing with the following keys @@ -81,7 +82,7 @@ Creates an `socketserver/ThreadingTCPServer` nREPL server with :port The local port the server is listening on. :shutdown-fn The function to shutdown the server. - + ----- # basilisp-nrepl-async.utils @@ -100,7 +101,7 @@ Macro. Converts the `ERROR` list to a human-readable string and returns it. Includes stack traces for any embedded exceptions. - + ## `error-add` ``` clojure @@ -111,7 +112,7 @@ Macro. Adds additional `DETAILS` to the existing `ERROR` list and returns it. - + ## `error-make` ``` clojure @@ -122,7 +123,7 @@ Macro. Returns a list from the provided error `DETAILS` to represent an error. - + ## `with-eprotect` ``` clojure @@ -141,4 +142,4 @@ Creates a try/catch wrapper around `BODY` that returns any exception `:on-err-str` [opt] A function to call if an exception is caught, which accepts the formated error message as only argument. - + diff --git a/README.md b/README.md index f3f114b..4556128 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,9 @@ ## Overview -This package provides an nREPL server implementation for Basilisp, evolved from the `basilisp.contrib.nrepl-server` namespace in Basilisp, addressing issues that arise from serving nREPL request in parallel with the main event loop. +An nREPL server is a networked REPL for Clojure that facilitates remote code evaluation, code completion, and debugging within Clojure-enabled editors like Emacs (via [CIDER](https://docs.cider.mx/cider/index.html)) and VS Code (via [Calva](https://calva.io/)), among others. + +This package provides an nREPL server implementation for Basilisp Clojure, evolved from the [basilisp.contrib.nrepl-server](https://basilisp.readthedocs.io/en/latest/api/contrib/nrepl-server.html) namespace in Basilisp, addressing issues that arise from serving nREPL request in parallel with the main event loop. Serving an nREPL client connection on a parallel thread in Python may conflict with the Global Interpreter Lock (GIL) and single-threaded libraries, potentially causing errors or crashes. @@ -17,16 +19,27 @@ To mitigate this, the library includes an asynchronous mode where client request To install `basilisp-nrepl-async`, run: ```shell -pip install https://github.com/ikappaki/basilisp-nrepl-async/releases/download/v0.1.0b3/basilisp_nrepl_async-0.1.0b3-py3-none-any.whl +pip install basilisp-nrepl-async ``` ## Usage See [API.md](API.md). +### Synchronous mode + +To start in synchronous mode, call [server-start!](API.md#basilisp-nrepl-async.nrepl-server/server-start!) with the optional `:host`, `:port` and `:nrepl-port-file` keys. The server will block and handle client requests as they arrive. + +```clojure +(require '[basilisp-nrepl-async.nrepl-server :as nr]) + +(def server-async (nr/server-start! {:port 9999})) +; nREPL server started on port 9999 on host 127.0.0.1 - nrepl://127.0.0.1:9999 +``` + ### Asynchronous mode -To start the nREPL server on a random port bound to the local interface in asynchronous mode, call [server-start!](API.md#basilisp-nrepl-async.nrepl-server/server-start!) with the `async?` option set to `true`. Periodically invoke the returned `work-fn` within your program's main loop to handle client requests. +To start the nREPL server on a random port bound to the local interface in asynchronous mode, call [server-start!](API.md#basilisp-nrepl-async.nrepl-server/server-start!) with the `async?` option set to `true`. Periodically invoke the returned `work-fn` within your program's main loop to handle client requests. Use the `shutdown-fn` to stop the server. ```clojure (require '[basilisp-nrepl-async.nrepl-server :as nr]) @@ -53,17 +66,6 @@ The server will create an `.nrepl-port` file in the current working directory wi You can also pass additional options to the [server-start!](API.md#basilisp-nrepl-async.nrepl-server/server-start!) function, such as `:host`, `:port` and `:nrepl-port-file`, to explicitly configure the server's listening interface, port, and the file where the port number is written (typically `