Skip to content

Commit

Permalink
Merge pull request #24 from skytable/octave
Browse files Browse the repository at this point in the history
Implement new protocol
  • Loading branch information
ohsayan committed Dec 5, 2023
2 parents 181af32 + 332635f commit b8fbea3
Show file tree
Hide file tree
Showing 22 changed files with 1,774 additions and 3,860 deletions.
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "skycloud-devspace",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"ghcr.io/devcontainers/features/rust:1": {}
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
10 changes: 1 addition & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build
run: |
cargo build --verbose --no-default-features --features sync
cargo build --verbose --no-default-features --features sync,ssl
cargo build --verbose --no-default-features --features sync,sslv
cargo build --verbose --no-default-features --features aio
cargo build --verbose --no-default-features --features aio,aio-ssl
cargo build --verbose --no-default-features --features aio,aio-sslv
cargo build --verbose --no-default-features --features dbg
cargo build --verbose --no-default-features --features const-gen
run: cargo build --verbose
- name: Run tests
run: cargo test --all-features
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Cargo.lock
.vscode
.DS_Store
examples/target
scripts
scripts
src/bin
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

All changes in this project will be noted in this file.

## Unreleased
## 0.8.0

### New features
#### New features
- Completely up to date for Skyhash 2.0
- New query API interface for Skytable Octave (completely breaking!)
- No longer depends on OpenSSL

- Support for Skyhash 2.0
#### Breaking changes
The enter query interface as changed and is incompatible with previous driver versions. Please consider reading the Skytable
Octave upgrade guide.

## 0.7.0

Expand Down
48 changes: 9 additions & 39 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,15 @@ license = "Apache-2.0"
name = "skytable"
readme = "README.md"
repository = "https://github.com/skytable/client-rust"
version = "0.8.0"
version = "0.8.0-beta.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["sync"]
# sync
sync = ["r2d2"]
# sync TLS
ssl = ["openssl"]
sslv = ["openssl/vendored"]
# async
aio = ["bytes", "tokio", "bb8", "async-trait"]
# async TLS
aio-ssl = ["tokio-openssl", "openssl"]
aio-sslv = ["tokio-openssl", "openssl/vendored"]
# utilities
const-gen = []
dbg = []

[dependencies]
bytes = { version = "1.2.1", optional = true }
openssl = { version = "0.10.42", optional = true }
tokio = { version = "1.21.2", features = [
"net",
"io-util",
"io-std",
], optional = true, default-features = false }
tokio-openssl = { version = "0.6.3", optional = true }
r2d2 = { version = "0.8.10", optional = true }
bb8 = { version = "0.8.0", optional = true }
async-trait = { version = "0.1.58", optional = true }

[dev-dependencies]
tokio = { version = "1.21.2", features = [
"test-util",
"macros",
], default-features = false }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
tokio = { version = "1.34.0", features = ["full"] }
native-tls = "0.2.11"
tokio-native-tls = "0.3.1"
rand = "0.8.5"
r2d2 = "0.8.10"
async-trait = "0.1.74"
bb8 = "0.8.1"
itoa = "1.0.9"
143 changes: 7 additions & 136 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,149 +35,20 @@ cargo new skyapp
First add this to your `Cargo.toml` file:

```toml
skytable = "0.7.0-alpha.4"
skytable = "0.8.0-beta.1"
```

Now open up your `src/main.rs` file and establish a connection to the server while also adding some
imports:
You're ready to go!

```rust
use skytable::{Connection, Query, Element, SkyResult};
fn main() -> SkyResult<()> {
let mut con = Connection::new("127.0.0.1", 2003)?;
Ok(())
}
```

Now let's run a `Query`! Change the previous code block to:

```rust
use skytable::{error, Connection, Query, Element};
fn main() -> Result<(), error::Error> {
let mut con = Connection::new("127.0.0.1", 2003)?;
let query = Query::from("heya");
let res: String = con.run_query(&query)?;
assert_eq!(res, "HEY!");
Ok(())
}
```

## Running actions

As noted [below](#binary-data), the default table is a key/value table with a binary key
type and a binary value type. Let's go ahead and run some actions (we're assuming you're
using the sync API; for async, simply change the import to `use skytable::actions::AsyncActions`).

### `SET`ting a key

```rust
use skytable::actions::Actions;
use skytable::sync::Connection;

let mut con = Connection::new("127.0.0.1", 2003).unwrap();
con.set("hello", "world").unwrap();
```

This will set the value of the key `hello` to `world` in the `default:default` entity.

### `GET`ting a key

```rust
use skytable::actions::Actions;
use skytable::sync::Connection;

let mut con = Connection::new("127.0.0.1", 2003).unwrap();
let x: String = con.get("hello").unwrap();
assert_eq!(x, "world");
```

Way to go &mdash; you're all set! Now go ahead and run more advanced queries!

## Binary data

The `default:default` keyspace has the following declaration:

```text
Keymap { data:(binstr,binstr), volatile:false }
```

This means that the default keyspace is ready to store binary data. Let's say
you wanted to `SET` the value of a key called `bindata` to some binary data stored
in a `Vec<u8>`. You can achieve this with the `RawString` type:

```rust
use skytable::actions::Actions;
use skytable::sync::Connection;
use skytable::types::RawString;

let mut con = Connection::new("127.0.0.1", 2003).unwrap();
let mybinarydata = RawString::from(vec![1, 2, 3, 4]);
assert!(con.set("bindata", mybinarydata).unwrap());
```
use skytable::{Config, query};

## Going advanced

Now that you know how you can run basic queries, check out the [`actions`] module documentation for learning
to use actions and the [`types`] module documentation for implementing your own Skyhash serializable
types. Need to meddle with DDL queries like creating and dropping tables? Check out the [`ddl`] module.
You can also find some [examples here](https://github.com/skytable/client-rust/tree/v0.7.0-alpha.4/examples)

## Connection pooling

This library supports using sync/async connection pools. See the [`pool`] module-level documentation for examples
and information.

## Async API

If you need to use an `async` API, just change your import to:

```toml
skytable = { version = "0.7.0-alpha.4", features=["aio"], default-features = false }
```

You can now establish a connection by using `skytable::AsyncConnection::new()`, adding `.await`s wherever
necessary. Do note that you'll use the [Tokio runtime](https://tokio.rs).

## Using both `sync` and `async` APIs

With this client driver, it is possible to use both sync and `async` APIs **at the same time**. To do
this, simply change your import to:

```toml
skytable = { version="0.7.0-alpha.4", features=["sync", "aio"] }
```

## TLS

If you need to use TLS features, this crate will let you do so with OpenSSL.

### Using TLS with sync interfaces

```toml
skytable = { version="0.7.0-alpha.4", features=["sync","ssl"] }
```

You can now use the async `sync::TlsConnection` object.

### Using TLS with async interfaces

```toml
skytable = { version="0.7.0-alpha.4", features=["aio","aio-ssl"], default-features=false }
let mut db = Config::new_default("username", "password").connect().unwrap();
let query = query!("select username, password from myspace.mytbl WHERE username = ?", your_fn_to_get_user());
let (username, password) = db.query_parse::<(String, String)>(&query).unwrap();
```

You can now use the async `aio::TlsConnection` object.

### _Packed TLS_ setup

If you want to pack OpenSSL with your crate, then for sync add `sslv` instead of `ssl` or
add `aio-sslv` instead of `aio-ssl` for async. Adding this will statically link OpenSSL
to your crate. Do note that you'll need a C compiler, GNU Make and Perl to compile OpenSSL
and statically link against it.

## MSRV

The MSRV for this crate is Rust 1.39. Need const generics? Add the `const-gen` feature to your
dependency!
> **Read [docs here to learn BlueQL](https://docs.skytable.io/)**
## Contributing

Expand Down

0 comments on commit b8fbea3

Please sign in to comment.