Skip to content

Commit

Permalink
docs(pubsub): web copy
Browse files Browse the repository at this point in the history
  • Loading branch information
neurosnap committed Oct 8, 2024
1 parent dc5a309 commit 5fec9cc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pubsub/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func WishMiddleware(handler *CliHandler) wish.Middleware {
} else if cmd == "sub" {
subCmd := flagSet("sub", sesh)
public := subCmd.Bool("p", false, "Subscribe to a public topic")
keepAlive := subCmd.Bool("k", false, "Keep the subscription alive even after the publisher as died")
keepAlive := subCmd.Bool("k", false, "Keep the subscription alive even after the publisher has died")
if !flagCheck(subCmd, topic, cmdArgs) {
return
}
Expand Down
50 changes: 43 additions & 7 deletions pubsub/html/marketing.page.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
user-defined topics. By default, topics are private to the authenticated
ssh user. The default pubsub model is multicast with bidirectional
blocking, meaning a publisher (<code>pub</code>) will send its message to all
subscribers (<code>sub</code>) on a topic. Further, both <code>pub</code> and
subscribers (<code>sub</code>) for a topic (channels). There can be many publishers
and many subscribers on a topic. Further, both <code>pub</code> and
<code>sub</code> will wait for at least one event to be sent or received on the topic.
</p>

Expand All @@ -46,9 +47,9 @@
<li>Configurable blocking for both pubs and subs</li>
<li>Paradigms for connecting to a topic:
<ol>
<li>Read (sub)</li>
<li>Write (pub)</li>
<li>Read & Write (pipe)</li>
<li>Read (<code>sub</code>)</li>
<li>Write (<code>pub</code>)</li>
<li>Read & Write (<code>pipe</code>)</li>
</ol>
</li>
</ol>
Expand Down Expand Up @@ -102,7 +103,14 @@

<div>
<h2 class="text-xl">Pipe command output</h2>
<p>Send command output through our <code>pipe</code> command.</p>
<p>
Send command output through our <code>pipe</code> command. The
<code>pipe</code> command is just like <code>pub</code> except it
is non-blocking and also acts like a <code>sub</code>. So a client
that can read and write to the topic.
</p>
<pre>ssh {{.Site.Domain}} sub htop</pre>
<pre>htop | ssh {{.Site.Domain}} pipe htop</pre>

<details>
<summary>Demo</summary>
Expand All @@ -122,7 +130,10 @@
<h2 class="text-xl">Chat</h2>
<p>Use our <code>pipe</code> command to have a chat with someone.</p>
<pre>ssh {{.Site.Domain}} pipe mychan -p</pre>
<p>Now anyone with a <code>pico</code> account can subscribe to this channel using the same command.</p>
<p>
Now anyone with a <code>pico</code> account can subscribe to this
topic using the same command and start typing!
</p>

<details>
<summary>Demo</summary>
Expand All @@ -141,6 +152,8 @@
<div>
<h2 class="text-xl">Pipe reverse shell</h2>
<p>If you squint hard enough you can give users interactive access to your shell.</p>
<pre>mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | ssh {{.Site.Domain}} pipe myshell > /tmp/f</pre>
<pre>ssh {{.Site.Domain}} pipe myshell</pre>

<details>
<summary>Demo</summary>
Expand All @@ -158,6 +171,11 @@

<div>
<h2 class="text-xl">Simple CI/CD</h2>
<p>
I'm always looking for easy ways to simplify deploying apps
automatically. Having an authenticated, zero-install event system
seems handy for this purpose.
</p>
<pre>ssh {{.Site.Domain}} sub myimg; docker pull myimg && docker up -d dev</pre>
<pre>docker buildx build --push -t myimg .; ssh {{.Site.Domain}} pub myimg -e</pre>
</div>
Expand All @@ -166,6 +184,13 @@
<h2 class="text-xl">Pubsub interactions</h2>

<h3 class="text-lg">Multiple subs</h3>
<p>
Have many subscribers, they will all receive the message.
</p>
<pre>ssh {{.Site.Domain}} sub foobar</pre>
<pre>ssh {{.Site.Domain}} sub foobar</pre>
<pre>while true; do echo "foobar1"; sleep 1; done | ssh {{.Site.Domain}} pub foobar</pre>

<details>
<summary>Demo</summary>
<script
Expand All @@ -180,6 +205,11 @@
</details>

<h3 class="text-lg">Multiple pubs</h3>
<p>Have many publishers send messages to subscribers.</p>
<pre>while true; do echo "foobar1"; sleep 1; done | ssh {{.Site.Domain}} pub foobar</pre>
<pre>while true; do echo "foobar2"; sleep 1; done | ssh {{.Site.Domain}} pub foobar</pre>
<pre>ssh {{.Site.Domain}} sub foobar</pre>

<details>
<summary>Demo</summary>
<script
Expand All @@ -194,6 +224,12 @@
</details>

<h3 class="text-lg">Multiple pubs and subs</h3>
<p>Have many publishers send messages to many subscribers.</p>
<pre>ssh {{.Site.Domain}} sub foobar</pre>
<pre>ssh {{.Site.Domain}} sub foobar</pre>
<pre>while true; do echo "foobar1"; sleep 1; done | ssh {{.Site.Domain}} pub foobar</pre>
<pre>while true; do echo "foobar2"; sleep 1; done | ssh {{.Site.Domain}} pub foobar</pre>

<details>
<summary>Demo</summary>
<script
Expand All @@ -211,7 +247,7 @@
<div>
<h2 class="text-xl">Send a public message</h2>
<pre>echo "hello world!" | ssh {{.Site.Domain}} pub mychan -p</pre>
<p>Now anyone with a <code>pico</code> account can subscribe to this channel:</p>
<p>Now anyone with a <code>pico</code> account can subscribe to this topic:</p>
<pre>ssh {{.Site.Domain}} sub mychan -p</pre>
</div>

Expand Down

0 comments on commit 5fec9cc

Please sign in to comment.