Skip to content

Commit e5ad8f8

Browse files
authored
Add docs
Signed-off-by: Sayan Nandan <[email protected]>
1 parent cf4c493 commit e5ad8f8

File tree

269 files changed

+18032
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

269 files changed

+18032
-10
lines changed

.gitignore

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
# Generated by Cargo
2-
# will have compiled files and executables
3-
/target/
4-
5-
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6-
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
7-
Cargo.lock
8-
9-
# These are backup files generated by rustfmt
10-
**/*.rs.bk
1+
.DS_Store
2+
.vscode
3+
.idea
4+
*.iml
5+
*.code-workspace
6+
.changelog
7+
node_modules
8+
.yarn
9+
.eslintcache
10+
yarn-error.log
11+
build
12+
.docusaurus
13+
.cache-loader

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3+
};

docs/1.index.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
id: index
3+
title: Introduction
4+
sidebar_label: Home
5+
slug: /
6+
---
7+
Welcome to Skybase's docs! You will find information about how you can get started with Skybase, installation options, configuration and clients.
8+
9+
:::note Caution
10+
This documentation is for Skybase versions built off the `next` branch and is not very stable. To use a pre-built binary and see its corresponding instructions, click on the version dropdown towards the upper left to select a version.
11+
:::
12+
13+
## Users
14+
15+
Since you're building off `next`, you'll have to [build from source](building-from-source). Once you've got everything up and running, you can take a look at the available actions [here](actions/overview) and [configuration files](config-files).
16+
17+
## Developers
18+
19+
You can find information on how to build your own clients [here](Protocol/terrapipe). The primary idea is to implement the Terrapipe Protocol.
20+
21+
## Contributing
22+
23+
If you find any typos, mistakes or any other scope of improvement - please don't hesitate to bring it up [here](https://github.com/skybasedb/docs/issues). Thank you ❤️!
24+
25+
## License
26+
27+
The documentation is licensed under the [CC-BY-SA-4.0 License](https://github.com/skybasedb/docs/tree/master/LICENSE)

docs/2.getting-started.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
id: getting-started
3+
title: Getting Started
4+
---
5+
:::warning
6+
This is for release v0.5.0
7+
:::
8+
Getting started with Skybase is easy 😊 (and fun!). You can get started with [native binaries (recommended)](#get-started-with-bundles) or by using the [docker image](#get-started-with-docker).
9+
10+
## Get started with bundles
11+
12+
### Step 1: Download a bundle
13+
14+
Head over to the [releases page](https://github.com/terrabasedb/terrabase/releases) and download the latest version for your platform.
15+
16+
### Step 2: Make the files runnable
17+
18+
Unzip the `zip` file that you just downloaded. If you're on a *nix system, run `chmod +x tdb skysh` to make the files executable. If you're on Windows, right-click the files and then check the `UNBLOCK` checkbox and click on the `APPLY` button.
19+
20+
### Step 3: Start the database server
21+
22+
In the directory where you extracted the files, run `./tdb` on *nix systems or simply `tdb` on Windows systems. That's all there is to starting the database server!
23+
24+
### Step 4: Run the shell `skysh`
25+
26+
`skysh` is the shell that is shipped with the bundle. Run it, just like you did with the database server. Now enter commands in the shell, and have fun! First run `HEYA` to check if everything is fine - the server should reply with _HEY!_.
27+
See all the available actions [here](actions/overview)
28+
29+
You're done with setting up `tdb` 🎉!
30+
31+
## Get started with Docker
32+
33+
First of all, you need to have Docker installed and available on your `PATH` ; you can read the official guide [here](https://docs.docker.com/get-docker/). Once you've got Docker up and running, follow the steps!
34+
35+
### Step 0: Create a container
36+
37+
Open up a terminal and run:
38+
39+
```
40+
docker create terrabasedb/tdb --name tdbvm
41+
```
42+
43+
:::note
44+
You may need superuser privileges
45+
:::
46+
At the same time, you'll need to set up the bundle by following [Step 1](#step-1-download-a-bundle) and [Step 2](#step-2-make-the-files-runnable) from the previous section.
47+
48+
### Step 1: Start the container
49+
50+
Now run:
51+
52+
```
53+
docker start tdbvm
54+
```
55+
56+
:::note
57+
You may need superuser privileges
58+
:::
59+
### Step 2: Find the IP address of the container
60+
61+
In order to connect to the container (which, to `skysh` is nothing but a remote server), you'll have to run:
62+
63+
``` shell
64+
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' tdbvm
65+
```
66+
67+
:::note
68+
You may need superuser privileges
69+
:::
70+
And you'll get a result like:
71+
72+
``` text
73+
172.17.0.1
74+
```
75+
76+
### Step 3: Start the command line client
77+
78+
Open up a terminal in the directory where you downloaded the command line client and run:
79+
80+
``` shell
81+
skysh -h 172.17.0.1
82+
```
83+
84+
And you're done!

docs/3.building-from-source.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
id: building-from-source
3+
title: Building from source
4+
---
5+
Of course you can build it from source &mdash; but with quite a bit of hassle. The database server is a bit fussy with its builds, so you'll need quite a few tools before you can actually start using it.
6+
7+
### Step 1: Install pre-requisites
8+
As Skybase is written in Rust, you'll have to install the Rust toolchain to build it (a little messy, but not too messy). Go to [this page](https://rustup.rs/) to set up Rust on your local machine.
9+
10+
Besides, the TLS/SSL components are written in C (OpenSSL) &mdash; so you'll need to install:
11+
* A C compiler for your platform
12+
* GNU Make (`make`)
13+
* Perl
14+
15+
### Step 2: Clone the tag
16+
Run this from your terminal:
17+
```
18+
git clone --branch next https://github.com/skybasedb/skybase.git
19+
```
20+
:::tip Bonus tip
21+
If you want to avoid downloading all the version history, run this instead:
22+
```
23+
git clone --depth 1 --branch next https://github.com/skybasedb/skybase.git
24+
```
25+
:::
26+
### Step 3: Build it!
27+
Expecting that you're still in the same directory, run:
28+
```
29+
cd skybase && cargo build --release
30+
```
31+
:::note
32+
This will take **crazy long** at times, so hold on until Cargo finishes building things
33+
:::
34+
:::note Important note
35+
Since you're building off `next`, it's always a good idea to create a debug build than a release build as you'll find some bugs which we'd love you to report [here](https://github.com/skybasedb/skybase).
36+
37+
To create a debug build, just run `cargo build`, omitting the `release` flag.
38+
:::
39+
### Step 4: Get the binaries
40+
You'll need to copy `sdb` and `skysh` (or `sdb.exe` and `skysh.exe` if on Windows) from the `skybase/target/release` folder. Be sure to copy these **exact files** and not something else!
41+
### Step 5: Run it!
42+
Now start the database server by running `./tdb` and then start the interactive shell by running `./tsh`. You're ready to use the [actions](actions/overview)!

docs/4.persistence.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
id: persistence
3+
title: Persistence
4+
---
5+
Skybase supports the persistent storage of data, which is an inherently obvious need for any database. In this document we explore how Skybase's persistence works.
6+
7+
## How TDB stores data
8+
9+
Whenever you start the database, TDB looks for a `data.bin` file, which contains data from the previous run of the database server. This is a binary file and should not be edited by hand: as you might end up corrupting the file.
10+
When you shut down the database, TDB stops stops listening to all incoming connections, and then flushes the entire in-memory table onto disk and then shutting down.
11+
12+
## Automated background saving
13+
14+
Since 0.4.2, Skybase supports automated saving of data in the background, via `BGSAVE` . `BGSAVE` , runs every two minutes to flush all the data in the in-memory table onto disk, unless customized through the [configuration file](config-files/#an-example-configuration).

docs/5.benchmarking.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
id: benchmarking
3+
title: Benchmarking
4+
---
5+
Who doesn't like speed and as a consequence, benchmarks? So here's a guide on benchmarking Skybase with our tool `sky-bench` .
6+
7+
## Step 0: Getting the benchmarking tool
8+
9+
The benchmark tool ( `sky-bench` ) has been shipped as a part of the Skybase bundle ever since 0.3.2. So, you'll need to download a bundle from the [releases page](https://github.com/skybasedb/skybase/releases) and unzip it. In the following steps we'll assume that you have unzipped the archive and you're in that directory.
10+
:::tip
11+
If you're building off `next`, then you will need to copy the `sky-bench` binary from the `target/release` or `target/debug` directory.
12+
:::
13+
## Step 1: Starting the database server
14+
15+
Open a terminal in the current directory and [set executable permissions](getting-started/#step-2-make-the-files-runnable). Now start the server by running `./sdb` (or just `sdb` on Windows).
16+
17+
## Step 2: Run the benchmark tool
18+
19+
Open another terminal in the current directory and then run `sky-bench` with no arguments if you want to use the default options, or run `sky-bench --help` to see available configuration options. Hold tight, you'll know when it happens 🚀.
20+
21+
### Bonus: JSON Output
22+
23+
If you're a bit nerdy, we know it — you'll like some structured data. Well, all you need to do is: run `sky-bench --json` for JSON output!

docs/5.cfg-files.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
id: config-files
3+
title: Configuration Files
4+
---
5+
Skybase supports custom configuration files to let users customize the functioning of TDB. Arguably, TDB has one of the simplest configuration files around. Skybase also allows configuration via [command line arguments](config-cmd).
6+
7+
## An example configuration
8+
9+
A configuration file is a TOML file, which looks like:
10+
11+
``` toml
12+
[server]
13+
host = "127.0.0.1"
14+
port = 2003
15+
noart = false
16+
17+
[bgsave]
18+
enabled = true
19+
every = 120 # Every 120 seconds
20+
```
21+
22+
This is the default configuration used by TDB when you don't specify a configuration file. Let's understand what each of the keys mean:
23+
24+
* `server` :
25+
- `host` : This is the IP address to which you want the database server to bind to. It can be any valid IPv4 *or* IPv6 address, as a quoted string
26+
- `port` : This is the port to which you want TDB to bind to
27+
- `noart` (OPTIONAL): This is **an optional argument** and is recommended for secure environments where displaying terminal artwork might cause problems
28+
* `bgsave`:
29+
- `enabled` : This is an optional key, which is to be set to true to enable BGSAVE or false to disable it. If this key is not specified, TDB will enable BGSAVE by default
30+
- `every` : Run BGSAVE `every` seconds. So, for example, if you set this to 120, BGSAVE will run every two minutes. This is also an optional key, and if you don't provide it, the default BGSAVE duration of 120 seconds is used
31+
* `snapshot` (OPTIONAL): This key can be used to configure snapshots and is not enabled by default. See [this](snapshots) for more information.
32+
33+
## Using a configuration file
34+
35+
To use a configuration file:
36+
37+
1. Create it! We recommend you to name it as `sdb.toml` for easy identification
38+
2. Start the database server with: `sdb -c /path/to/your/file.toml`
39+
3. Done 🎉
40+
41+
If you're confused about creating a configuration file, we always recommend you to download a sample file from [this link](https://github.com/skybasedb/skybase/blob/next/examples/config-files/template.toml). Do note that this file is bleeding-edge and as a result will have new keys as they're created upstream.
42+
43+
That's all that's there for using configuration files!
44+
:::tip Bonus tip
45+
If you're using a custom host/port, then you can bind `skysh` to a custom host/port by starting `skysh` like:
46+
```shell
47+
skysh -h [HOST] -p [PORT]
48+
```
49+
You can do the same for `sky-bench`:
50+
```shell
51+
sky-bench -h [HOST] -p [PORT]
52+
```
53+
:::

docs/Actions/1.actions.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
id: overview
3+
title: Actions overview
4+
---
5+
Actions are like shell commands: they take arguments and do something! Skybase currently supports the following actions:
6+
7+
* [DBSIZE](dbsize)
8+
* [DEL](del)
9+
* [EXISTS](exists)
10+
* [FLUSHDB](flushdb)
11+
* [GET](get)
12+
* [HEYA](heya)
13+
* [KEYLEN](keylen)
14+
* [MGET](mget)
15+
* [MKSNAP](mksnap)
16+
* [MSET](mset)
17+
* [MUPDATE](mupdate)
18+
* [SDEL](sdel)
19+
* [SET](set)
20+
* [SSET](sset)
21+
* [SUPDATE](supdate)
22+
* [UPDATE](update)
23+
* [USET](uset)

docs/Actions/DBSIZE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
id: dbsize
3+
title: DBSIZE
4+
---
5+
:::note About
6+
**Since**: 0.4.3
7+
**Time complexity**: O(1)
8+
**Arguments**: `DBSIZE`
9+
**Returns**: Number of keys that exist in the database as an unsigned int
10+
:::
11+
Number of key/value pairs stored in the database

0 commit comments

Comments
 (0)