Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Completed
    • Affects versions: Release 1.7
    • Fix versions: Release 1.8
    • Labels:
    • Approval:
      Ok
    • Patch:
      Code and Test

      Description

      Programs often want to provide REPLs to users in contexts when a) network communication is desired, b) capturing stdio is difficult, or c) when more than one REPL session is desired. In addition, tools that want to support REPLs and simultaneous conversations with the host are difficult with a single stdio REPL as currently provided by Clojure.

      Tooling and users often need to enable a REPL on a program without changing the program, e.g. without asking author or program to include code to start a REPL host of some sort. Thus a solution must be externally and declaratively configured (no user code changes). A REPL is just a special case of a socket service. Rather than provide a socket server REPL, provide a built-in socket server that composes with the existing repl function.

      For design background, see: http://dev.clojure.org/display/design/Socket+Server+REPL

      Start a socket server by supplying an extra system property (classpath and clojure.main here, but this would generally be starting your own app instead - we won't use the repl it starts):

      java -cp target/classes -Dclojure.server.repl="{:port 5555 :accept clojure.core.server/repl}" clojure.main 
      

      where options are:

      • address = host or address, defaults to loopback
      • port = port, required
      • accept = namespaced function to invoke on socket accept, required
      • args = sequential collection of args to pass to accept
      • bind-err = defaults to true, binds err to out stream
      • server-daemon = defaults to true, socket server thread doesn't block exit
      • client-daemon = defaults to true, socket client threads don't block exit

      Run a repl client using telnet:

      $ telnet 127.0.0.1 5555
      Trying 127.0.0.1...
      Connected to localhost.
      Escape character is '^]'.
      user=> (println "hello")
      hello
      nil
      user=> clojure.core.server/*session*
      {:server "repl", :client "1"}
      user=> (ns foo)
      nil
      foo=> (+ 1 1)
      2
      foo=> 
      

      Patch: clj-1671-13.patch

        Attachments

        1. clj-1671-10.patch
          14 kB
        2. clj-1671-11.patch
          14 kB
        3. clj-1671-12.patch
          13 kB
        4. clj-1671-13.patch
          9 kB
        5. clj-1671-2.patch
          5 kB
        6. clj-1671-3.patch
          11 kB
        7. clj-1671-4.patch
          13 kB
        8. clj-1671-5.patch
          8 kB
        9. clj-1671-6.patch
          8 kB
        10. clj-1671-7.patch
          10 kB
        11. clj-1671-8.patch
          12 kB
        12. clj-1671-9.patch
          14 kB

          Activity

            People

            • Assignee:
              alexmiller Alex Miller
              Reporter:
              alexmiller Alex Miller
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: