Skip to content

Commit

Permalink
Post soft-launch fixes (#526)
Browse files Browse the repository at this point in the history
* Post soft-launch fixes

* cargo readme

* Readme updates

* cargo format

* fix typo

* add og image
  • Loading branch information
paulgb authored Jan 3, 2024
1 parent 5db2264 commit cbe2b3e
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 5 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,52 +36,9 @@ Read more about [Plane’s architecture](https://plane.dev/concepts/architecture

[![Architecture diagram of Plane](./docs/public/arch-diagram.svg)](https://plane.dev/concepts/architecture)

## Example
## Learn more

Imagine a multiplayer document editor. When Sam opens a document with ID `abc123`, the application requests a process from Plane with that key. In this case no process is running, so Plane starts a new one.

When Jane opens the *same* document, the application requests a process from Plane with the same key (`abc123`). This time Plane already has a process running for that key, so it returns a URL which maps to that process.

As long as either Jane or Sam has document `abc123` open, Plane will keep the process associated with that document running. After **both** Jane and Sam have closed the document, Plane will shut down the process.

If Carl later opens the same document, Plane will start a _new_ process for him, possibly on a different machine.

## Quick Start

This repo includes a Docker Compose file that is suitable for running a local development instance of Plane.

This works on Linux and Mac systems with Docker installed.

In the root of this repo, run:

```bash
docker compose -f docker/docker-compose.yml up
```

This tells Docker to run a Postgres database, as well as a minimal Plane stack: one controller, one drone, and one proxy (see below for an explanation).

The Plane Controller will be available at http://localhost:8080, and the Plane Proxy will be available at http://localhost:9090.

### Connecting to a process

The `docker/cli.sh` script runs the Plane CLI, configured to connect to the local Plane Controller.

```bash
docker/cli.sh connect \
--wait \
--cluster 'localhost:9090' \
--image ghcr.io/drifting-in-space/demo-image-drop-four
```

## Running tests

Tests can be run with `cargo test`, but it can be slow because it does not run tests in parallel and some of the tests are slow.

You can use `nextest` to run tests in parallel:

```bash
cargo install nextest
cargo nextest run -j 5
```

The `-j 5` flag tells `nextest` to run 5 tests in parallel. If you set it too high, you may encounter Docker issues.
- Read the [quickstart guide](https://plane.dev/quickstart-guide)
- Learn about [Plane concepts](https://plane.dev/concepts/session-backends)
- See instructions for [building and developing Plane locally](https://plane.dev/developing)
- Read about [production deployment](https://plane.dev/deploy-to-prod)
14 changes: 12 additions & 2 deletions docs/components/logo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
export default function PlaneLogo() {
return <svg height="100%" viewBox="0 0 337 80" fill="none" xmlns="http://www.w3.org/2000/svg">
export type PlaneLogoProps = {
height?: number
}

export default function PlaneLogo(props: PlaneLogoProps) {
let height = props.height
let width
if (typeof height === 'number') {
width = height * 4.2125
}

return <svg height={height || '100%'} width={width} viewBox="0 0 337 80" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M122.831 3.675H89.8611V73.5H100.781V45.99H122.831C138.371 45.99 144.566 36.12 144.566 24.78C144.566 13.65 138.371 3.675 122.831 3.675ZM100.781 37.275V12.39H120.206C130.076 12.39 133.226 17.64 133.226 24.78C133.226 31.92 130.076 37.275 120.206 37.275H100.781ZM163.464 73.5V0H152.964V73.5H163.464ZM189.868 74.865C200.998 74.865 206.773 68.25 208.873 61.635C208.873 65.835 209.083 69.405 209.503 73.5H219.058C218.638 68.565 218.533 65.415 218.533 61.53V35.49C218.533 25.83 211.393 19.215 196.903 19.215C181.993 19.215 173.698 26.25 173.593 37.38H184.093C184.618 30.765 188.713 27.3 197.323 27.3C206.353 27.3 208.873 30.555 208.873 35.28C208.873 38.955 206.563 40.53 201.523 41.37L188.398 43.575C176.638 45.57 172.438 51.03 172.438 59.43C172.438 69.09 179.158 74.865 189.868 74.865ZM192.073 66.78C186.613 66.78 182.938 64.05 182.938 59.01C182.938 54.18 185.773 51.66 192.283 50.19L199.528 48.51C202.678 47.775 206.038 46.935 208.873 44.835V47.985C208.873 58.485 203.098 66.78 192.073 66.78ZM258.405 19.32C248.325 19.32 242.55 24.99 239.4 32.76V21H228.9V73.5H239.4V51.345C239.4 34.65 245.07 28.035 255.36 28.035C261.975 28.035 267.015 30.66 267.015 41.685V73.5H277.515V40.74C277.515 26.985 272.37 19.32 258.405 19.32ZM311.121 67.41C302.091 67.41 295.371 63.42 294.531 50.19H335.901C336.111 48.825 336.111 47.565 336.111 46.2C336.111 31.185 327.501 19.32 310.806 19.32C292.851 19.32 284.241 31.815 284.241 47.145C284.241 62.685 292.116 75.18 310.806 75.18C329.286 75.18 335.061 64.89 336.006 57.645H326.346C324.876 63.105 320.676 67.41 311.121 67.41ZM310.911 27.09C320.256 27.09 325.506 31.92 326.031 42.525H294.636C295.896 30.87 301.881 27.09 310.911 27.09Z" fill="currentColor" />
<path d="M6 4H4C1.79086 4 0 5.79086 0 8V10C0 12.2091 1.79086 14 4 14H6C8.20914 14 10 12.2091 10 10V8C10 5.79086 8.20914 4 6 4Z" fill="currentColor" />
<path d="M31 4H19C16.7909 4 15 5.79086 15 8V10C15 12.2091 16.7909 14 19 14H31C33.2092 14 35 12.2091 35 10V8C35 5.79086 33.2092 4 31 4Z" fill="currentColor" />
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function App({ Component, pageProps }: AppProps) {
<link rel="icon" href="/favicon.png" />
</Head>
<Component {...pageProps} />
<Script defer data-domain="y-sweet.cloud" src="/js/script.js"></Script>
<Script defer data-domain="plane.dev" src="/js/script.js"></Script>
</>
)
}
Binary file added docs/pages/api/OpenSans-SemiBold.ttf
Binary file not shown.
51 changes: 51 additions & 0 deletions docs/pages/api/og-image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { ImageResponse } from 'next/og'
import PlaneLogo from '../../components/logo'
import { NextRequest } from 'next/server';

export const config = {
runtime: 'edge',
}

export default async function handler(request: NextRequest) {
const { searchParams } = new URL(request.url);

const fontData = await fetch(
new URL('OpenSans-SemiBold.ttf', import.meta.url),
).then((res) => res.arrayBuffer());

const title = searchParams.get('title')

return new ImageResponse(
(
<div
style={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
width: '100%',
height: '100%',
background: '#011029',
color: 'white',
fontFamily: 'Open Sans',
}}
>
<PlaneLogo height={180} />
{title && (
<div style={{ marginTop: 50, fontSize: 60, display: 'flex' }}>
<span style={{color: '#555'}}>docs/</span>{title}
</div>
)}
</div>
),
{
fonts: [
{
name: 'Open Sans',
data: fontData,
style: 'normal',
}
]
}
)
}
2 changes: 1 addition & 1 deletion docs/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Use cases include:

<Callout type="warning">
This documentation refers to the 0.4.0 release of Plane, which is a complete rewrite. These docs are
brand new as of January 2024, and still a work in progres. Please mind the wet paint!
brand new as of January 2024, and still a work in progress. Please mind the wet paint!

If anything is unclear in the meantime, please [open a discussion](https://github.com/drifting-in-space/plane/discussions)
on Plane’s GitHub.
Expand Down
20 changes: 20 additions & 0 deletions docs/theme.config.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useRouter } from 'next/router'
import { useConfig } from 'nextra-theme-docs'
import Logo from './components/logo'

export default {
Expand All @@ -9,6 +10,25 @@ export default {
chat: {
link: "https://discord.gg/N5sEpsuhh9"
},
head: () => {
const { frontMatter, title } = useConfig()
const { asPath } = useRouter()

let ogImageUrl = asPath === '/' ? 'https://plane.dev/api/og-image' : `https://plane.dev/api/og-image?title=${encodeURIComponent(title)}`

return <>
<meta
property="og:description"
content={frontMatter.description || 'An open-source distributed system for running WebSocket backends at scale'}
/>
<meta property="og:image" content={ogImageUrl} />
<meta name="twitter:image" content={ogImageUrl} />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@drifting_corp" />
<meta name="twitter:title" content="Plane" />
<meta name="twitter:description" content="An open-source distributed system for scaling WebSocket backends." />
</>
},
useNextSeoProps() {
const { asPath } = useRouter()
if (asPath !== '/') {
Expand Down
11 changes: 9 additions & 2 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
"jsx": "preserve",
"plugins": [
{
"name": "next"
}
],
"strictNullChecks": true
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
Expand Down
5 changes: 3 additions & 2 deletions plane/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[package]
name = "plane"
version = "0.2.0"
version = "0.4.0"
edition = "2021"
default-run = "plane"
description = "Session backend orchestrator for ambitious browser-based apps."
repository = "https://github.com/drifting-in-space/plane"
license = "MIT"
readme = "../README.md"
homepage = "https://plane.dev"
readme = "README.md"

[dependencies]
acme2-eab = "0.5.4"
Expand Down
27 changes: 27 additions & 0 deletions plane/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<a href="https://plane.dev">
<img src="../resources/plane-logo-light.svg" alt="Plane logo" />
</a>

[![GitHub Repo stars](https://img.shields.io/github/stars/drifting-in-space/plane?style=social)](https://github.com/drifting-in-space/plane)
[![Docker image](https://img.shields.io/docker/v/plane/plane)](https://hub.docker.com/r/plane/plane/tags)
[![Build Docker Image](https://github.com/drifting-in-space/plane/actions/workflows/build-image.yml/badge.svg)](https://github.com/drifting-in-space/plane/actions/workflows/build-image.yml)
[![Tests](https://github.com/drifting-in-space/plane/actions/workflows/tests.yml/badge.svg)](https://github.com/drifting-in-space/plane/actions/workflows/tests.yml)
[![Chat on Discord](https://img.shields.io/static/v1?label=chat&message=discord&color=404eed)](https://discord.gg/N5sEpsuhh9)

[Plane](https://plane.dev) is a distributed system for **running stateful WebSocket backends at scale**. Plane is heavily inspired by [Figma’s mulitplayer infrastructure](https://www.figma.com/blog/rust-in-production-at-figma/), which dynamically spawns a process for each active document.

Use cases include:
- Scaling up [authoritative multiplayer backends](https://driftingin.space/posts/you-might-not-need-a-crdt).
- Running isolated code environments (like REPLs, code notebooks, and LLM agent sandboxes).
- Data-intensive applications that need a dedicated high-RAM process for each active user session.

Read more about [Plane’s architecture](https://plane.dev/concepts/architecture).

[![Architecture diagram of Plane](../docs/public/arch-diagram.svg)](https://plane.dev/concepts/architecture)

## Learn more

- Read the [quickstart guide](https://plane.dev/quickstart-guide)
- Learn about [Plane concepts](https://plane.dev/concepts/session-backends)
- See instructions for [building and developing Plane locally](https://plane.dev/developing)
- Read about [production deployment](https://plane.dev/deploy-to-prod)
1 change: 1 addition & 0 deletions plane/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![warn(clippy::unwrap_used)]
#![cfg_attr(test, allow(clippy::unwrap_used))]
#![doc = include_str!("../README.md")]

use serde::{Deserialize, Serialize};

Expand Down

0 comments on commit cbe2b3e

Please sign in to comment.