Skip to content

Commit

Permalink
backported latest updates from basilisp-blender (#1)
Browse files Browse the repository at this point in the history
* backported latest updates from basilisp-blender

* workaround for GH failure with 3.12.7

* handle 3.9- test outcome
  • Loading branch information
ikappaki authored Nov 11, 2024
1 parent b1886b6 commit e560cc1
Show file tree
Hide file tree
Showing 6 changed files with 341 additions and 185 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/tests-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ jobs:
run: poetry install

- name: Run tests
run: poetry run basilisp test
# workaround for https://github.com/basilisp-lang/basilisp/issues/1119
env:
PYTHONPATH: ${{ github.workspace }}
run: poetry run pytest -v

9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## Unreleased

## 0.1.0b2

- Upgraded Basilisp to 0.2.4.
- Improved on the nREPL server exception messages by matching that of the REPL user friendly format, backported from [basilisp-blender](https://github.com/ikappaki/basilisp-blender).
- Fix incorrect line numbers for compiler exceptions in nREPL when evaluating forms in loaded files, backported from [basilisp-blender](https://github.com/ikappaki/basilisp-blender)
- nREPL server no longer sends ANSI color escape sequences in exception messages to clients, backported from [basilisp-blender](https://github.com/ikappaki/basilisp-blender).
- Conform to the `cider-nrepl` `info` ops spec by ensuring result's `:file` is URI, also added missing :column number, backported from [basilisp-blender](https://github.com/ikappaki/basilisp-blender).


## 0.1.0b1

- Initial version based on basilisp-blender nREPL server with improved error reporting.
61 changes: 49 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# A Basilisp async nREPL server for cooperative multitasking

## Overview
`basilisp-nrepl-async` is an nREPL server implementation for [Basilisp](https://basilisp.readthedocs.io/en/latest/) that allows client requests to be evaluated asynchronously by the main program at a chosen time and place. This enables cooperative multitasking on a single thread between the program and the nREPL server on the Python VM.
`basilisp-nrepl-async` is an nREPL server implementation for [Basilisp](https://basilisp.readthedocs.io/en/latest/) that allows client requests to be evaluated asynchronously by the main program at a chosen time and place. This enables cooperative multitasking on a single thread between the program and the nREPL server on the Python VM, while avoiding conflicts with the Global Interpreter Lock (GIL) and single threaded libraries.

## Installation

To install `basilisp-nrepl-async`, run:

```shell
pip install https://github.com/ikappaki/basilisp-nrepl-async/releases/download/v0.1.0b1/basilisp_nrepl_async-0.1.0b1-py3-none-any.whl
pip install https://github.com/ikappaki/basilisp-nrepl-async/releases/download/v0.1.0b2/basilisp_nrepl_async-0.1.0b2-py3-none-any.whl
```

## Usage
Expand All @@ -26,23 +26,60 @@ To start the nREPL server on a random port bound to the local interface, call th
(def server-async (nr/start-server! {:async? true}))
; nREPL server started on port 55144 on host 127.0.0.1 - nrepl://127.0.0.1:55144

;; Process client requests on this thread
;; Process client requests on this thread
(let [{:keys [host port shutdown-fn work-fn]} server-async]
(try
(loop [] ;; suppose this is the main event loop

(loop [] ;; suppose this is the main loop
(work-fn) ;; Execute any pending nREPL client work

(work-fn) ;; Execute any pending nREPL client work
;; simulate some work
(time/sleep 0.5)

;; simulate some work
(time/sleep 0.5)

(recur))))
(recur)))
```

The server will create an `.nrepl-port` file in the current working directory with the port number, which nREPL-enabled Clojure editors can use to connect.

You can also pass additional options to the `server-start!` function, such as `:address` and `:port`, to explicitly set the server's listening interface and port, respectively. See the function documentation for more details.
You can also pass additional options to the `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 `<your-basilisp-lib>/.nrepl-port` for integration with your editor). See the function documentation for more details in [src/basilisp_nrepl_async/nrepl_server.lpy](src/basilisp_nrepl_async/nrepl_server.lpy)

```clojure
"Create an nREPL server with `server-make` (of which see) according to
``opts`` if given, and blocks for serving clients.
It prints out the `nrepl-server-signature` message at startup for
IDEs to pickup the host number to connect to.
``opts`` is a map of options with the following optional keys
:async? If truthy, runs the server non-blocking in a separate thread
where requests are queued instead of executed immediately. Returns a
map with
:error :error Contains details of any error during server
creation.
:host The host interface the server is bound to.
:port The local port the server is listening on.
:shutdown-fn The function to shutdown the server.
:work-fn The function to process any pending client
requests.
:nrepl-port-file An optional filepath to write the port number
to. Typically set to .nrepl-port for the editors to detect.
:server* An optional promise of a map delivered on success with
:host The host interface the server is bound to.
:port The local port the server is listening on.
:shutdown-fn The function to shutdown the server.
also see `server-make` for additionally supported ``opts`` keys."
```

## Development and Testing

Expand All @@ -58,4 +95,4 @@ This project is licensed under the Eclipse Public License 2.0. See the [LICENSE]

## Acknowledgments

This library is a spin-off of the [basilisp-blender](https://github.com/ikappaki/basilisp-blender) nrepl-server namespace.
This library is a spin-off of [basilisp-blender](https://github.com/ikappaki/basilisp-blender)'s `basilisp-blender.nrepl-server` namespace.
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[tool.poetry]
name = "basilisp-nrepl-async"
version = "0.1.0b1"
version = "0.1.0b2"
description = ""
authors = ["ikappaki <[email protected]>"]
readme = "README.md"
packages = [{include = "basilisp_nrepl_async", from = "src"}]

[project.urls]
Homepage = "https://github.com/ikappaki/basilisp-nrepl-async"

[tool.poetry.dependencies]
python = "^3.8"
basilisp = "^0.2.4"
Expand Down
Loading

0 comments on commit e560cc1

Please sign in to comment.