Skip to content

Latest commit

 

History

History
145 lines (90 loc) · 5.76 KB

API.md

File metadata and controls

145 lines (90 loc) · 5.76 KB

Table of contents

  • basilisp-nrepl-async.nrepl-server
    • logger - The logger for this namespace.
    • ops - A map of operations supported by the nREPL server (as keywords) to function handlers for those operations.
    • server-start! - Creates an socketserver/ThreadingTCPServer nREPL server with optional OPTS.
  • basilisp-nrepl-async.utils
    • error->str - Converts the ERROR list to a human-readable string and returns it.
    • error-add - Adds additional DETAILS to the existing ERROR list and returns it.
    • error-make - Returns a list from the provided error DETAILS to represent an error.
    • with-eprotect - Creates a try/catch wrapper around BODY that returns any exception as an error prefixed with the id from ID-OR-OPTS.

The logger for this namespace.

Source

A map of operations supported by the nREPL server (as keywords) to function handlers for those operations.

Source

(server-start!)
(server-start! opts)

Function.

Creates an socketserver/ThreadingTCPServer nREPL server with optional OPTS. By default, it listens on 127.0.0.1 at a random available port 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 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.

:host The host address to bind to, defaults to 127.0.0.1.

:nrepl-port-file An optional filepath to write the port number to. Typically set to .nrepl-port (the default) for the editors to 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

 :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.

Source


(error->str error)

Macro.

Converts the ERROR list to a human-readable string and returns it. Includes stack traces for any embedded exceptions.

Source

(error-add error & details)

Macro.

Adds additional DETAILS to the existing ERROR list and returns it.

Source

(error-make & details)

Macro.

Returns a list from the provided error DETAILS to represent an error.

Source

(with-eprotect id-or-opts & body)

Macro.

Creates a try/catch wrapper around BODY that returns any exception as an error prefixed with the id from ID-OR-OPTS.

ID-OR-OPTS is either a printable object used as the id, or a map with the following keys

:id The id to prefix the error with.

:on-err-str [opt] A function to call if an exception is caught, which accepts the formated error message as only argument.

Source