- commit
- 5fec9cc
- parent
- dc5a309
- author
- Eric Bower
- date
- 2024-10-08 01:29:13 +0000 UTC
docs(pubsub): web copy
2 files changed,
+44,
-8
+1,
-1
1@@ -356,7 +356,7 @@ func WishMiddleware(handler *CliHandler) wish.Middleware {
2 } else if cmd == "sub" {
3 subCmd := flagSet("sub", sesh)
4 public := subCmd.Bool("p", false, "Subscribe to a public topic")
5- keepAlive := subCmd.Bool("k", false, "Keep the subscription alive even after the publisher as died")
6+ keepAlive := subCmd.Bool("k", false, "Keep the subscription alive even after the publisher has died")
7 if !flagCheck(subCmd, topic, cmdArgs) {
8 return
9 }
+43,
-7
1@@ -29,7 +29,8 @@
2 user-defined topics. By default, topics are private to the authenticated
3 ssh user. The default pubsub model is multicast with bidirectional
4 blocking, meaning a publisher (<code>pub</code>) will send its message to all
5- subscribers (<code>sub</code>) on a topic. Further, both <code>pub</code> and
6+ subscribers (<code>sub</code>) for a topic (channels). There can be many publishers
7+ and many subscribers on a topic. Further, both <code>pub</code> and
8 <code>sub</code> will wait for at least one event to be sent or received on the topic.
9 </p>
10
11@@ -46,9 +47,9 @@
12 <li>Configurable blocking for both pubs and subs</li>
13 <li>Paradigms for connecting to a topic:
14 <ol>
15- <li>Read (sub)</li>
16- <li>Write (pub)</li>
17- <li>Read & Write (pipe)</li>
18+ <li>Read (<code>sub</code>)</li>
19+ <li>Write (<code>pub</code>)</li>
20+ <li>Read & Write (<code>pipe</code>)</li>
21 </ol>
22 </li>
23 </ol>
24@@ -102,7 +103,14 @@
25
26 <div>
27 <h2 class="text-xl">Pipe command output</h2>
28- <p>Send command output through our <code>pipe</code> command.</p>
29+ <p>
30+ Send command output through our <code>pipe</code> command. The
31+ <code>pipe</code> command is just like <code>pub</code> except it
32+ is non-blocking and also acts like a <code>sub</code>. So a client
33+ that can read and write to the topic.
34+ </p>
35+ <pre>ssh {{.Site.Domain}} sub htop</pre>
36+ <pre>htop | ssh {{.Site.Domain}} pipe htop</pre>
37
38 <details>
39 <summary>Demo</summary>
40@@ -122,7 +130,10 @@
41 <h2 class="text-xl">Chat</h2>
42 <p>Use our <code>pipe</code> command to have a chat with someone.</p>
43 <pre>ssh {{.Site.Domain}} pipe mychan -p</pre>
44- <p>Now anyone with a <code>pico</code> account can subscribe to this channel using the same command.</p>
45+ <p>
46+ Now anyone with a <code>pico</code> account can subscribe to this
47+ topic using the same command and start typing!
48+ </p>
49
50 <details>
51 <summary>Demo</summary>
52@@ -141,6 +152,8 @@
53 <div>
54 <h2 class="text-xl">Pipe reverse shell</h2>
55 <p>If you squint hard enough you can give users interactive access to your shell.</p>
56+ <pre>mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | ssh {{.Site.Domain}} pipe myshell > /tmp/f</pre>
57+ <pre>ssh {{.Site.Domain}} pipe myshell</pre>
58
59 <details>
60 <summary>Demo</summary>
61@@ -158,6 +171,11 @@
62
63 <div>
64 <h2 class="text-xl">Simple CI/CD</h2>
65+ <p>
66+ I'm always looking for easy ways to simplify deploying apps
67+ automatically. Having an authenticated, zero-install event system
68+ seems handy for this purpose.
69+ </p>
70 <pre>ssh {{.Site.Domain}} sub myimg; docker pull myimg && docker up -d dev</pre>
71 <pre>docker buildx build --push -t myimg .; ssh {{.Site.Domain}} pub myimg -e</pre>
72 </div>
73@@ -166,6 +184,13 @@
74 <h2 class="text-xl">Pubsub interactions</h2>
75
76 <h3 class="text-lg">Multiple subs</h3>
77+ <p>
78+ Have many subscribers, they will all receive the message.
79+ </p>
80+ <pre>ssh {{.Site.Domain}} sub foobar</pre>
81+ <pre>ssh {{.Site.Domain}} sub foobar</pre>
82+ <pre>while true; do echo "foobar1"; sleep 1; done | ssh {{.Site.Domain}} pub foobar</pre>
83+
84 <details>
85 <summary>Demo</summary>
86 <script
87@@ -180,6 +205,11 @@
88 </details>
89
90 <h3 class="text-lg">Multiple pubs</h3>
91+ <p>Have many publishers send messages to subscribers.</p>
92+ <pre>while true; do echo "foobar1"; sleep 1; done | ssh {{.Site.Domain}} pub foobar</pre>
93+ <pre>while true; do echo "foobar2"; sleep 1; done | ssh {{.Site.Domain}} pub foobar</pre>
94+ <pre>ssh {{.Site.Domain}} sub foobar</pre>
95+
96 <details>
97 <summary>Demo</summary>
98 <script
99@@ -194,6 +224,12 @@
100 </details>
101
102 <h3 class="text-lg">Multiple pubs and subs</h3>
103+ <p>Have many publishers send messages to many subscribers.</p>
104+ <pre>ssh {{.Site.Domain}} sub foobar</pre>
105+ <pre>ssh {{.Site.Domain}} sub foobar</pre>
106+ <pre>while true; do echo "foobar1"; sleep 1; done | ssh {{.Site.Domain}} pub foobar</pre>
107+ <pre>while true; do echo "foobar2"; sleep 1; done | ssh {{.Site.Domain}} pub foobar</pre>
108+
109 <details>
110 <summary>Demo</summary>
111 <script
112@@ -211,7 +247,7 @@
113 <div>
114 <h2 class="text-xl">Send a public message</h2>
115 <pre>echo "hello world!" | ssh {{.Site.Domain}} pub mychan -p</pre>
116- <p>Now anyone with a <code>pico</code> account can subscribe to this channel:</p>
117+ <p>Now anyone with a <code>pico</code> account can subscribe to this topic:</p>
118 <pre>ssh {{.Site.Domain}} sub mychan -p</pre>
119 </div>
120