Skip to content

Commit 503735b

Browse files
committed
Add diagrams for session structure and REPL dispatch
The session/dispatch model is hard to grasp from prose alone. Add two ASCII diagrams to the connection-management guide: one showing how a Sesman session groups a clj and a cljs connection over a shared nREPL server (with each connection's eval + tooling nREPL sessions), and one walking through how an operation in a source buffer resolves to a target REPL (pin -> default session -> Sesman/friendly -> type filter -> recency).
1 parent b3fe4a0 commit 503735b

1 file changed

Lines changed: 71 additions & 1 deletion

File tree

doc/modules/ROOT/pages/usage/managing_connections.adoc

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,31 @@ sessions. Each session is a collection of connections which share the same nREPL
4343
server. You can, however, have multiple sessions sharing the same nREPL server (although you're unlikely to
4444
ever need this).
4545

46+
The picture below shows a typical session holding both a Clojure and a
47+
ClojureScript REPL. Remember that a connection and a REPL buffer are the same
48+
thing (see the note at the top of this page), and that each connection is in turn
49+
segregated into two nREPL sessions of its own: an *eval* session that backs the
50+
REPL and a separate *tooling* session that CIDER uses for background requests so
51+
they don't clobber REPL state such as `+*1+`, `+*2+` and `+*3+`.
52+
53+
....
54+
"current session" (a Sesman session, tied to a context)
55+
+----------------------------------------------------------------------+
56+
| |
57+
| clj REPL buffer cljs REPL buffer |
58+
| = nREPL connection = nREPL connection |
59+
| (eval + tooling (eval + tooling |
60+
| nREPL sessions) nREPL sessions) |
61+
| | | |
62+
+-------------|--------------------------------------|-----------------+
63+
| |
64+
+-------------------+------------------+
65+
|
66+
+-----------------+
67+
| nREPL server | (shared by the session)
68+
+-----------------+
69+
....
70+
4671
=== Starting New Sessions
4772

4873
You can start new sessions with the following commands:
@@ -107,7 +132,52 @@ To quit or restart individual connections use CIDER commands
107132
== Current Session
108133

109134
All CIDER commands (evaluation, completion, switching to REPL etc.) operate on
110-
the relevant REPL within the current session. The current session is the most
135+
the relevant REPL within the current session. At a glance, here's how CIDER turns
136+
an operation in a source buffer into a target REPL. The sections that follow
137+
explain each step in detail.
138+
139+
....
140+
operation in a source buffer (eval, completion, ...)
141+
|
142+
v
143+
+--------------------------------------------------+
144+
| 1. Is the buffer pinned to a REPL? |--yes--> use that REPL's
145+
| (e.g. a dependency source visited via M-.) | session
146+
+--------------------------------------------------+
147+
| no
148+
v
149+
+--------------------------------------------------+
150+
| 2. Is a default session set? |--yes--> use it
151+
| (cider-set-default-session) |
152+
+--------------------------------------------------+
153+
| no
154+
v
155+
+--------------------------------------------------+
156+
| 3. Ask Sesman: linked sessions, else friendly |
157+
| ones (file under the project dir). |
158+
| cider-merge-sessions may pool several. |
159+
| -> the most relevant session |
160+
+--------------------------------------------------+
161+
|
162+
v pick a REPL from that session:
163+
+--------------------------------------------------+
164+
| 4. Filter by the source buffer's type: |
165+
| clj buffer -> clj REPLs |
166+
| cljs buffer -> cljs REPLs |
167+
| cljc buffer -> both (multi dispatch) |
168+
+--------------------------------------------------+
169+
|
170+
v
171+
+--------------------------------------------------+
172+
| 5. More than one of that type? |
173+
| -> the most recently viewed REPL |
174+
+--------------------------------------------------+
175+
|
176+
v
177+
target REPL(s)
178+
....
179+
180+
The current session is the most
111181
relevant session among all linked sessions (or friendly sessions when no links
112182
exist). Session relevance is decided by the specificity of the linked contexts
113183
and recency of the REPL buffers.

0 commit comments

Comments
 (0)