Liking cljdoc? Tell your friends :D

com.brunobonacci.rdt.utils


client-socketclj

(client-socket host port send-wrapper receive-wrapper)

The client side communication function for the server-socket. see server-socket for more info. The send-wrapper is a function which takes a message and returns another message before it gets sent. The receive-wrapper is the same but for incoming messages.

The client side communication function for the server-socket. see
`server-socket` for more info.
The send-wrapper is a function which takes a message and returns another message
before it gets sent. The receive-wrapper is the same but for incoming messages.
sourceraw docstring

clojure-data-wrapperclj

(clojure-data-wrapper handler)
source

current-dirclj

(current-dir)
source

deserializeclj

(deserialize data)
source

displayclj

(display v)
(display indent v)
source

do-withcljmacro

(do-with value & forms)
source

do-with-exceptioncljmacro

(do-with-exception value ok fail)
source

file-to-nsclj

(file-to-ns f)
source

indent-byclj

(indent-by indent s)
source

java-base-commandclj

(java-base-command)

Returns the java command used to start the current JVM with all the JVM parameters and classpath up to, but excluding, the main class and its parameters

Returns the java command used to start the current JVM with
all the JVM parameters and classpath up to, but excluding,
the main class and its parameters
sourceraw docstring

java-classpathclj

(java-classpath)
source

java-executableclj

(java-executable)
source

java-process-argumentsclj

(java-process-arguments)
source

lazy-list-dirclj

(lazy-list-dir base)
source

lazy-list-filesclj

(lazy-list-files base)
source

lazy-list-relative-filesclj

(lazy-list-relative-files base)
source

live-counterclj

(live-counter stats-atom)
source

no-failcljmacro

(no-fail & body)
source

ppr-strclj

(ppr-str v)

pretty print to string

pretty print to string
sourceraw docstring

pr-ex-strclj

(pr-ex-str ex)
(pr-ex-str type ex)
source

pr-strclj

(pr-str v)

like clojure.core/pr-str but ignores *print-level* and *print-length*

like clojure.core/pr-str but ignores `*print-level*` and `*print-length*`
sourceraw docstring

project-dirsclj

(project-dirs)
source

relative-pathclj

(relative-path relative-to)
source

serializeclj

(serialize data)
source

server-socketclj

(server-socket port handler)

Trivial server-socket for client/server communication. It listen for messages on the given port. Multiple clients can connect at the same time, each client will be handled in a separate thread. The communication protocol is very simple, each message is sent on a single line so if you have new-lines characters in your message they need to be escaped as . The server handle the message with the give function and sends the response back to the client in a single line. If the handling of the function throws as exception the server will send a message to the client with the following format:

!ERR: <server error message>

If you specify 0 as the port, the server will choose a free random port.

Here is how to use it. In this example we are starting a server on a random port and it will echo back any message sent but in upper-case letters:

(def server (server-socket 0 str/upper-case))

;; return the server port
(server :port) => 61835
;; return the list of open connections
(server :open-connections)


;; start a client
(def client (client-socket "127.0.0.1" (server :port) identity identity))
@(client :send "hello") ;; => "HELLO"

;; shutdown client and servers
(client :close)
(server :close)
Trivial server-socket for client/server communication.
   It listen for messages on the given port. Multiple clients can connect
   at the same time, each client will be handled in a separate thread.
   The communication protocol is very simple, each message is sent on a single line
   so if you have new-lines characters in your message they need to be escaped as `
`.
   The server handle the message with the give function and sends the response back
   to the client in a single line. If the handling of the function throws as exception
   the server will send a message to the client with the following format:

   ```
   !ERR: <server error message>
   ```

   If you specify `0` as the port, the server will choose a free random port.

   Here is how to use it. In this example we are starting a server on a random port
   and it will echo back any message sent but in upper-case letters:
   ```
  (def server (server-socket 0 str/upper-case))

  ;; return the server port
  (server :port) => 61835
  ;; return the list of open connections
  (server :open-connections)


  ;; start a client
  (def client (client-socket "127.0.0.1" (server :port) identity identity))
  @(client :send "hello") ;; => "HELLO"

  ;; shutdown client and servers
  (client :close)
  (server :close)
   ```
  
sourceraw docstring

shclj

(sh cmd)

Like clojure.java/sh but err and out are merged in the same stream and returned as string like in a terminal. cmd is an array of strings argument starting from the process name

Like `clojure.java/sh` but `err` and `out` are merged in the same stream
 and returned as string like in a terminal.
`cmd` is an array of strings argument starting from the process name
sourceraw docstring

sha256clj

(sha256 data)

hex encoded sha-256 hash

hex encoded sha-256 hash
sourceraw docstring

thread-continuationclj

(thread-continuation name f state & {:keys [sleep-time] :or {sleep-time 0}})

Execute the function f in a separate thread called name, and it return a function without arguments which when called it stop the execution of the thread. The function f must accept one argument, its state and return the next state. The first state is provided at the start. If the thread completes its work it can return :thread-continuation/done, and the thread will be stopped.

Between two execution the thread can optionally sleep for a configurable amount of time (in millis) with :sleep-time 5000 option Ex: (def t (thread-continuation "hello" (fn [_] (println "hello world")) nil :sleep-time 3000)) ;; in background you should see every 3s appear the following message ;; hello world ;; hello world ;; hello world ;; to stop the thread (t) (def t (thread-continuation "counter" (fn [counter] (println "counter:" c) ;; return the next value (inc c)) 0 ;; initial state :sleep-time 1000)) ;; in background you should see every 1s appear the following message ;; counter: 0 ;; counter: 1 ;; counter: 2 ;; counter: 3 ;; to stop the thread (t)

Execute the function `f` in a separate thread called `name`,
 and it return a function without arguments which when called it
stop the execution of the thread.  The function `f` must accept one
argument, its state and return the next state. The first state is provided
at the start. If the thread completes its work it can return
:thread-continuation/done, and the thread will be stopped.

Between two execution the thread can optionally sleep for a configurable
amount of time (in millis) with `:sleep-time 5000` option
Ex:
    (def t (thread-continuation "hello"
             (fn [_] (println "hello world")) nil
             :sleep-time 3000))
    ;; in background you should see every 3s appear the following message
    ;; hello world
    ;; hello world
    ;; hello world
    ;; to stop the thread
    (t)
    (def t (thread-continuation "counter"
             (fn [counter]
                (println "counter:" c)
                ;; return the next value
                (inc c))
              0   ;; initial state
             :sleep-time 1000))
    ;; in background you should see every 1s appear the following message
    ;; counter: 0
    ;; counter: 1
    ;; counter: 2
    ;; counter: 3
    ;; to stop the thread
    (t)
sourceraw docstring

Throwable->dataclj

(Throwable->data t)

Similar to clojure.core/throwable->map but preserving the Throwable chain

Similar to clojure.core/throwable->map but preserving the Throwable chain
sourceraw docstring

thunkcljmacro

(thunk & body)
source

uuidclj

(uuid)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close