Socket server support
Socket server support
(io-prepl & {:keys [valf] :or {valf pr-str}})
prepl bound to in and out, suitable for use with e.g. server/repl (socket-repl). :ret and :tap vals will be processed by valf, a fn of one argument or a symbol naming same (default pr-str)
Alpha, subject to change.
prepl bound to *in* and *out*, suitable for use with e.g. server/repl (socket-repl). :ret and :tap vals will be processed by valf, a fn of one argument or a symbol naming same (default pr-str) Alpha, subject to change.
(prepl in-reader out-fn & {:keys [stdin]})
a REPL with structured output (for programs) reads forms to eval from in-reader (a LineNumberingPushbackReader) Closing the input or passing the form :repl/quit will cause it to return
Calls out-fn with data, one of: {:tag :ret :val val ;;eval result, or Throwable->map data if exception thrown :ns ns-name-string :ms long ;;eval time in milliseconds :form string ;;iff successfully read :exception true ;;iff exception thrown } {:tag :out :val string} ;chars from during-eval out {:tag :err :val string} ;chars from during-eval err {:tag :tap :val val} ;values from tap>
You might get more than one :out or :err per eval, but exactly one :ret tap output can happen at any time (i.e. between evals) If during eval an attempt is made to read in it will read from in-reader unless :stdin is supplied
Alpha, subject to change.
a REPL with structured output (for programs) reads forms to eval from in-reader (a LineNumberingPushbackReader) Closing the input or passing the form :repl/quit will cause it to return Calls out-fn with data, one of: {:tag :ret :val val ;;eval result, or Throwable->map data if exception thrown :ns ns-name-string :ms long ;;eval time in milliseconds :form string ;;iff successfully read :exception true ;;iff exception thrown } {:tag :out :val string} ;chars from during-eval *out* {:tag :err :val string} ;chars from during-eval *err* {:tag :tap :val val} ;values from tap> You might get more than one :out or :err per eval, but exactly one :ret tap output can happen at any time (i.e. between evals) If during eval an attempt is made to read *in* it will read from in-reader unless :stdin is supplied Alpha, subject to change.
(remote-prepl host
port
in-reader
out-fn
&
{:keys [valf readf]
:or {valf read-string
readf (fn* [p1__5177# p2__5178#]
(read p1__5177# false p2__5178#))}})
Implements a prepl on in-reader and out-fn by forwarding to a remote [io-]prepl over a socket. Messages will be read by readf, a fn of a LineNumberingPushbackReader and EOF value or a symbol naming same (default #(read %1 false %2)), :ret and :tap vals will be processed by valf, a fn of one argument or a symbol naming same (default read-string). If that function throws, :val will be unprocessed.
Alpha, subject to change.
Implements a prepl on in-reader and out-fn by forwarding to a remote [io-]prepl over a socket. Messages will be read by readf, a fn of a LineNumberingPushbackReader and EOF value or a symbol naming same (default #(read %1 false %2)), :ret and :tap vals will be processed by valf, a fn of one argument or a symbol naming same (default read-string). If that function throws, :val will be unprocessed. Alpha, subject to change.
(repl)
REPL with predefined hooks for attachable socket server.
REPL with predefined hooks for attachable socket server.
(repl-init)
Initialize repl in user namespace and make standard repl requires.
Initialize repl in user namespace and make standard repl requires.
(repl-read request-prompt request-exit)
Enhanced :read hook for repl supporting :repl/quit.
Enhanced :read hook for repl supporting :repl/quit.
(start-server opts)
Start a socket server given the specified opts: :address Host or address, string, defaults to loopback address :port Port, integer, required :name Name, required :accept Namespaced symbol of the accept function to invoke, required :args Vector of args to pass to accept function :bind-err Bind err to socket out stream?, defaults to true :server-daemon Is server thread a daemon?, defaults to true :client-daemon Are client threads daemons?, defaults to true Returns server socket.
Start a socket server given the specified opts: :address Host or address, string, defaults to loopback address :port Port, integer, required :name Name, required :accept Namespaced symbol of the accept function to invoke, required :args Vector of args to pass to accept function :bind-err Bind *err* to socket out stream?, defaults to true :server-daemon Is server thread a daemon?, defaults to true :client-daemon Are client threads daemons?, defaults to true Returns server socket.
(start-servers system-props)
Start all servers specified in the system properties.
Start all servers specified in the system properties.
(stop-server)
(stop-server name)
Stop server with name or use the server-name from session if none supplied. Returns true if server stopped successfully, nil if not found, or throws if there is an error closing the socket.
Stop server with name or use the server-name from *session* if none supplied. Returns true if server stopped successfully, nil if not found, or throws if there is an error closing the socket.
(stop-servers)
Stop all servers ignores all errors, and returns nil.
Stop all servers ignores all errors, and returns nil.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close